1
$\begingroup$

Assume a function

$$f(x,y) = 2\vert x \vert + 2\vert y\vert - \vert x-y \vert - \vert x+y \vert$$ If $x>y$ then $f(x,y) = 2y$, If $x<y$ then $f(x,y) = 2\vert x \vert$

How to prove this? If $x>y$ then for $x>0$, $$f(x,y) = 2x + 2y -x + y -x - y = 2y $$ for $x<0$, we have $$f(x,y) = -2x + 2y + x + y +x - y = 2y $$

Now for $y>x$, can I write $f(x,y) = 2\vert x \vert + 2\vert y\vert - \vert y-x \vert - \vert x+y \vert$, such that for $y>0$, we have $$f(x,y) = 2x + 2y - y + x -x - y = 2x$$ and for $y<0$, we have $$f(x,y) = 2x - 2y + y + x - x + y = - 2x $$

Is my logic of proof sound?

$\endgroup$

1 Answer 1

2
$\begingroup$

It is a bit easier to consider this equality first:

$$\max(|x|,|y|)=\frac{|x+y|+|x-y|}2$$

Indeed let $y=cx$ ($x\neq 0$, it is trivially verified for $x=0$), then let consider $|x+y|+|x-y|=|x|\,(|1+c|+|1-c|)$

This transformation $y=cx$ allows us to deal only with one variable $c$ instead of two $x,y$ and to reduce the number of subcases to study.

  • $c\ge 1\implies |x|(1+c+c-1)=2c|x|=2|y|$
  • $c\le -1\implies |x|(-1-c+1-c)=-2c|x|=2|y|$
  • $-1\le c\le 1\implies |x|(1+c+1-c)=2|x|$

The first two cases correspond to $|c|\ge 1\iff |y|\ge|x|$ and the third one to $|y|\le |x|$, hence the result.

As a consequence the original problem's expression becomes:

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

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .