I'm supposed to get the maximum of two unknown numbers.
I used this equation to do this task:
$${x+y\over 2} + {\vert x-y\vert\over 2} $$
Let's get the maximum by substituting any two values e.g. $$x = 5$$ and $$y = 10$$
So:
$${5+10\over 2} + {\vert 5-10\vert\over 2} = 7.5 + 2.5 = 10 $$
My questions are:
- What's the mathematical explanation behind this?
- How can I simplify this equation?
I can't simplify it because absolute value is confusing.
You are adding two values together $${x+y\over 2} + {\vert (x-y)\vert\over 2}$$
The first is the average which gives you the midpoint.
The second part is half the total distance between $x$ and $y.$
What happens if you start at the midpoint and add half the distance to that? You get to the larger one.
If you subtract the half distance you get to the smaller one.
Thus you can also find the minimum by changing the plus sign to a minus sign.
$${x+y\over 2} -{\vert (x-y)\vert\over 2}$$