Function search: f(x) = 1 if x is real and x is in [2n - 5/2, 2n - 3/2], n an integer; -1 otherwise

Joined
May 22, 2024
Messages
15
Hello everyone. I am looking for a function [imath]f[/imath] with these requirements:
[math]f(x):=\begin{cases} 1 &\text{if }\{x\in\R\wedge\exists\,n\in\Z\text{ such that }x\in\left[2n-\frac{5}{2},2n-\frac{3}{2}\right]\}\\ -1 &\text{otherwise} \end{cases}[/math]I believe that [imath]f[/imath] will make heavy use of [imath]\frac{x}{\lvert\,x\rvert}[/imath].
 
Hello everyone. I am looking for a function [imath]f[/imath] with these requirements:
[math]f(x):=\begin{cases} 1 &\text{if }\{x\in\R\wedge\exists\,n\in\Z\text{ such that }x\in\left[2n-\frac{5}{2},2n-\frac{3}{2}\right]\}\\ -1 &\text{otherwise} \end{cases}[/math]I believe that [imath]f[/imath] will make heavy use of [imath]\frac{x}{\lvert\,x\rvert}[/imath].
Have you tried drawing a graph?
 
Hello everyone. I am looking for a function [imath]f[/imath] with these requirements:
[math]f(x):=\begin{cases} 1 &\text{if }\{x\in\R\wedge\exists\,n\in\Z\text{ such that }x\in\left[2n-\frac{5}{2},2n-\frac{3}{2}\right]\}\\ -1 &\text{otherwise} \end{cases}[/math]I believe that [imath]f[/imath] will make heavy use of [imath]\frac{x}{\lvert\,x\rvert}[/imath].
I would first simplify [imath]\left[2n-\frac{5}{2},2n-\frac{3}{2}\right][/imath] a little.

Then, you could use one of the approaches suggested here (with, of course, significant transformations):

 
Hello everyone. I am looking for a function [imath]f[/imath] with these requirements:
[math]f(x):=\begin{cases} 1 &\text{if }\{x\in\R\wedge\exists\,n\in\Z\text{ such that }x\in\left[2n-\frac{5}{2},2n-\frac{3}{2}\right]\}\\ -1 &\text{otherwise} \end{cases}[/math]I believe that [imath]f[/imath] will make heavy use of [imath]\frac{x}{\lvert\,x\rvert}[/imath].
Come to think of it: your original post already defines [imath]f(x)[/imath]. What does your assignment say? Do you need to define it through some other functions like 'mod', 'sign', absolute value, etc. ? What is the set of allowed functions in this case?
 
Last edited:
Come to think of it: your original post already defines [imath]f(x)[/imath]. What does your assignment says? Do you need to define it through some other functions like 'mod', 'sign', absolute value, etc. ? What is the set of allowed functions in this case?
I dunno, I just want the form that is easiest to compute. Also, I do not have any assignment.
 
Hmm, it seems they're using way too many sums, other functions, exponents and complicated trig like arctan
What is it that you want? There are several possibilities there; some are quite simple, but since you haven't said what sort of expression you consider acceptable, it's up to you do decide what fits your own needs.

As @blamocur has wisely pointed out, what you've already defined is (presumably) the function you want; you are looking for some sort of expression for it, but have not said what sort of expression you will accept.
I dunno, I just want the form that is easiest to compute. Also, I do not have any assignment.
"Easiest to compute" in what sense? You have to be specific, or else not bother asking for help. All we can do at this point is to try to help you clarify your request.

For example, do you want to code it in some particular language? or do it by hand? or what?
 
What is it that you want? There are several possibilities there; some are quite simple, but since you haven't said what sort of expression you consider acceptable, it's up to you do decide what fits your own needs.

As @blamocur has wisely pointed out, what you've already defined is (presumably) the function you want; you are looking for some sort of expression for it, but have not said what sort of expression you will accept.

"Easiest to compute" in what sense? You have to be specific, or else not bother asking for help. All we can do at this point is to try to help you clarify your request.

For example, do you want to code it in some particular language? or do it by hand? or what?
I would just like the most simplified expression.
 
I would just like the most simplified expression.
As I often tell students, simplicity is in the eye of the beholder. Please tell us what you want to do with whatever formula you choose. That will determine what is simplest.

For example, which of the ones in Wikipedia looks simplest to you? If none do, then what about them is too complicated for your particular needs? If you want to program it, the language you use will determine the best approach to take (which will likely be an algorithm, not a formula). If you want to work it out on paper, it will be something else (again, more likely an algorithm than a formula).
 
As I often tell students, simplicity is in the eye of the beholder. Please tell us what you want to do with whatever formula you choose. That will determine what is simplest.
Here's my definition of simplest: Least amount of steps, simplified, easiest to evaluate, least advanced operations (ex. derivatives, sigma and integrals are advanced)
 
Here's my definition of simplest: Least amount of steps, simplified, easiest to evaluate, least advanced operations (ex. derivatives, sigma and integrals are advanced)
Define "easiest to evaluate" and "least advanced operations" in your own context. Your link only discusses how a computer might recognize what can be done, not how to decide when you have fully simplified an expression, or which of two expressions is simpler.

That's for you to decide, and you are refusing to decide. You have a list of possibilities (though not exhaustive); if you can't say more, then I'm done.

But I personally would go with either the floor function, or a simple algorithm.
 
Hello everyone. I am looking for a function [imath]f[/imath] with these requirements:
[math]f(x):=\begin{cases} 1 &\text{if }\{x\in\R\wedge\exists\,n\in\Z\text{ such that }x\in\left[2n-\frac{5}{2},2n-\frac{3}{2}\right]\}\\ -1 &\text{otherwise} \end{cases}[/math]I believe that [imath]f[/imath] will make heavy use of [imath]\frac{x}{\lvert\,x\rvert}[/imath].
Have you looked at the "Fourier representation of the continuous time periodic square wave"?
 
Last edited:
Update: I found a formula. Thanks to Dr.Peterson that helped me find a formula by hinting to the floor function, I have found a square wave formula, just as I wanted. Thanks for the help, everyone! I will no longer respond to anyone in this thread because of a satisfactory answer, but I thank you all greatly. Have a perfect day!
[math]2\left\lfloor\frac{\cos(\pi\,x)}{2}\right\rfloor+\frac{1}{2}[/math]
 
Last edited:
Top