Is there any simple math expression that returns $-1$ if $x > a$ or $1$ if $x < a$?
Asked
Active
Viewed 81 times
3
-
What if $x=a$?? – Marc van Leeuwen Oct 24 '13 at 13:19
-
It can either be undefined at x = a, or -1 or 1. Doesn't matter to me. – Alon Gubkin Oct 24 '13 at 13:20
-
1Is $\dfrac{a-x}{\lvert a-x\rvert}$ to your liking? – Daniel Fischer Oct 24 '13 at 13:24
-
@DanielFischer Yeah, can you post that as an answer? – Alon Gubkin Oct 24 '13 at 13:26
2 Answers
4
To convert Daniel Fischer's perfectly good comment-answer into an actual answer: $$\frac{a-x}{|a-x|}$$
Cameron Buie
- 102,994
-
Hey, that's not true. I do that a lot. I just can't keep up with them all. – Daniel Fischer Oct 24 '13 at 18:13
-
Fair enough. It always strikes me that you (and David Mitra) leave a whole bunch of comment-answers, but I haven't seen many of your actual answers. – Cameron Buie Oct 24 '13 at 19:23
-
3
The simplest I know is $$f(x)= \begin {cases} 1 &x \lt a\\-1&x\gt a \end {cases}$$ This is a fine expression
Ross Millikan
- 374,822