Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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}.$$

share|improve this question
1  
The second is just z=x/y –  Ross Millikan Jun 18 '11 at 2:31
    
Why do you want to? In any case, $z$ is not continuous in $x$ and $y$, so the combined expression would be not be very nice (no offence to Yuval). –  Rahul Jun 18 '11 at 4:44
add comment

3 Answers 3

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). $$

share|improve this answer
1  
Haha, +1 for not cheating, @Yuval. –  Jack Henahan Jun 18 '11 at 2:47
add comment

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|}$$

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.