Is there a way to rewrite these two equations into one equation that would work in both scenarios?
If $x > y$, then the equation is: $$z = \frac{x - y}{1 - y}.$$
If $x < y$, then the equation is: $$z = 1 - \frac{y - x}{y}.$$
Is there a way to rewrite these two equations into one equation that would work in both scenarios?
If $x > y$, then the equation is: $$z = \frac{x - y}{1 - y}.$$
If $x < y$, then the equation is: $$z = 1 - \frac{y - x}{y}.$$
There are at least two ways to do that. One way is to use an "if" construct: $$ z = \begin{cases} (x-y)/(1-y) & x > y, \\ x/y & x < y. \end{cases} $$ But that's like cheating.
The second way is using absolute values to implement the conditional "honestly": $$\frac{|x-y|+x-y}{2|x-y|} \cdot \frac{x-y}{1-y} + \frac{|x-y|+y-x}{2|x-y|} \cdot \frac{x}{y}. $$ You can simplify that if you want by taking common factors, to get $$ \frac{1}{2} \left( \frac{x-y}{1-y} + \frac{x}{y} \right) + \frac{x-y}{2|x-y|} \left( \frac{x-y}{1-y} - \frac{x}{y} \right). $$
This is to expand Yuval's answer so you may understand the idea and tackle it in general.
You need to express the cases in a single equation, in other words you need to find $$z = f(x,y)\; \frac{x - y}{1 - y} + g(x,y)\; \frac{x}{y}$$
Where the properties of $f$ and $g$ are
$$ f(x,y)= \begin{cases} 1 & x > y \\\\ 0 & x < y \end{cases} \quad \mbox{and} \quad g(x,y)= \begin{cases} 0 & x > y \\\\ 1 & x < y \end{cases} $$
It is pretty easy to find $f$ and $g$ out for yourself. For example, if $x\neq y$ then
$$f(x,y) = \theta(x-y)$$ $$g(x,y) = \theta(y-x)$$
Where $\theta(x)$ is the Heaviside theta function. To express it completely algebraically, $\theta(x)$ can be expressed in terms of $sgn(x)$ which can be expressed as $\frac{x}{|x|}$ for $x\neq 0$. So the theta function can be written as ($x\neq y$)$$\theta(z) = \frac{z+|z|}{2|z|}$$
I suppose the easiest way would be a piecewise function:
$$ z= \begin{cases} \frac{x-y}{1-y} & x > y \\\\ \frac{x}{y} & x < y \end{cases} $$
Unless you mean you'd like a single function which would satisfy both conditions, in which case Yuval's got you covered.