# Using Logical Operators in One Line

I am looking for a function that has this meaning:

f(x)= if x>10 x+1 else x-1


or

f(x)=x>10 : x+1 ? x-1


Similar to the ternary operator in computer programming. What syntax should I use to express this as a mathematical function?

-

$\forall x [(x>10 \rightarrow f(x) = (x + 1))] \land \forall x[(x\leq 10 \rightarrow f(x) = x-1)]$

I saw the "logic" tag, and assumed you wanted a means to express this in logic.

Essentially, there are two cases: $$f(x)=\begin{cases}x+1 &\text{ if}\; x>10\\ \\ x-1 &\text{ if}\; x\leq10\end{cases}$$

This is a perfectly legitimate mathematical function, known as a Piecewise Function.

-
Nice reference too +1 –  Amzoti May 8 '13 at 2:42

You could use the Iverson bracket, defined for a predicate $P$, as $$[P] =\begin{cases} 1 & \text{if }P\text{ is true,}\\ 0 & \text{otherwise} \end{cases}$$ Then for your function you'd have $$f(x)=x-1+2[x>10]$$ This notation comes from the programming language APL. The only downside to this notation is that a fair number of mathematicians haven't been exposed to it, so you'll have to explain it before you use it.

-
That's assuming I'm a mathematician. –  user1919496 Feb 4 '13 at 1:35
@user1919496 Actually, from your use of the compound conditional, I had assumed you were coming from the CS side. –  Rick Decker Feb 4 '13 at 13:09