# Simple condition in a Math expression

Is there any simple math expression that returns $-1$ if $x > a$ or $1$ if $x < a$?

• 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
• Is $\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

To convert Daniel Fischer's perfectly good comment-answer into an actual answer: $$\frac{a-x}{|a-x|}$$
The simplest I know is $$f(x)= \begin {cases} 1 &x \lt a\\-1&x\gt a \end {cases}$$ This is a fine expression