Simplify the expression $x+y+|x-y|$

63 Views Asked by At

In our lecture, we were ask to simplify the expression $x+y+|x-y|$.

This is how I simplified it:

If $x\ge y$, $|x-y|=x-y$ and $x+y+|x-y|=x+y+(x-y)=2x$.

If $x<y$, $|x-y|=y-x$ and $x+y+|x-y|=x+y+(y-x)=2y$.

Now

$x+y+|x-y|=\begin{cases}2x&\text{if}~x\geq y\\ 2y&\text{if}~x<y\end{cases}$ .

The solution was correct but our lecturer also continued this by telling that we can now also conclude from the solution that

$x+y+|x-y|=2max(x,y)$.

I'm not sure, however, how we came to this conclusion?

3

There are 3 best solutions below

0
On BEST ANSWER

You came to the same conclusion, because if $x \ge y$, $2x = 2\max(x,y)$ and if $x < y$, $2y = \max(x,y)$ as well.

This is simpler as we use one "formula" instead of two depending on domain. (though $\max$ implicitly also is of this form, of course).

The point of this formula is how we can express the max in this lattice as a formula in terms of the linear operation and the norm: $\max(x,y) = \frac{1}{2}((x+y) + |x-y|)$. For the minimum a related formula exists.

0
On

If $x \geq y$, then what is $\max(x, y)$? In this case, what are $2\max(x, y)$ and $x + y + |x - y|$ equal to?

0
On

You have proved that

$$x+y+|x-y|=\begin{cases}2x&\text{if}~x\geq y\\ 2y&\text{if}~x<y\end{cases}$$

Note that if $x\ge y$ then $x$ is the maximum, so $2x$ is twice the maximum.

Otherwise $ y$ is the maximum and $2y$ is twice the maximum.