If statements in equations?

153 Views Asked by At

When creating an equation is there any way to let someone know that if this number doesn't fit into this then use this other equation? Ex: $x>1$ then use $x+y$, or if $x<1$ then use $x-y$. Or do you just have to find an equation that works for both probability?

4

There are 4 best solutions below

0
On

Like this:

$$ f(x,y)=\begin{cases} x+y & X>1 \\ x-y & X<1 \end{cases} $$

0
On

Yes, you can set up a function like this. For example, like this:

$f(x,y) =\,$ for $x>1\,$ use $x+y\,$ and for $x<1\,$ use $x-y$

0
On

A good example is the Kronecker delta.

0
On

You could also say $f(x,y) = x + \frac{x-1}{|x-1|}y$ for your particular example.