TITLE: How to do If and Else in math?
QUESTION [8 upvotes]: Hello all I would like to learn how to show if/else logic in math notation so here is the problem I'm faced with.
then
If R_x is in [X1, X_end] 
 then: If R_y is f(R_x)
  then If R_z < C
   then 0
Else 
1

How do I convert this into math notation ?

REPLY [11 votes]: If I understand your pseudocode correctly, you can state this as a piecewise-defined function using sets, for example: 
$$
g(x) = \left\{\begin{array}{ll}
0 & x\in S\\
1 & x\notin S
\end{array}\right.
$$
You just have to define the appropriate set $S$.  In your case, it looks like you have 3 numbers i.e.  $x = (R_x,R_y,R_z)$, and your set would look something like 
$$
S = \{(R_x,R_y,R_z):x_1\leq R_x\leq x_{end}\}\cap \{(R_x,R_y,R_z):R_y = f(R_x)\} \cap \{(R_x,R_y,R_z):R_z<C\}
$$ All three sets are subsets of $\Bbb{R}^3$, so $S$ is as well.