How to do If and Else in math?

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.