Modus Operandi. Formulae for Maximum and Minimum of two numbers with a + b and $|a - b|$

I came across the following problem in my self-study of real analysis:

For any real numbers $a$ and $b$, show that $$\max \{a,b \} = \frac{1}{2}(a+b+|a-b|)$$ and $$\min\{a,b \} = \frac{1}{2}(a+b-|a-b|)$$

So $a \geq b$ iff $a-b \ge0$ and $b \ge a$ iff $b-a \ge 0$. At first glance, it seems like an average of distances. For the first case, go to the point $a+b$, add $|a-b|$ and divide by $2$. Similarly with the second case.

Would you just break it up in cases and verify the formulas? Or do you actually need to come up with the formulas?


How can you come up with the formulas if they're already given? :)

Yes, you're right, it is a good idea to look at this formula as strongly related to an average. I find it more intuitive to look at it as $$\max{\{a,b\}} = \frac{a+b}{2} + \frac{|a-b|}{2},$$ so go to the midpoint of $a$ and $b$ and add half the distance $|a-b|$ between them to get to the larger among them. Similarly for the second formula.

Yes, the proof is probably easiest if you break it into the two cases you suggest and use the definition of the absolute value.


The formulas can be thought of in geometric terms. First you know that the distance between the points $a, b$ is just the absolute value of their difference, that is $d = |a - b|$. Now, the midpoint between $a, b$ is just $\frac{a+b}{2}$. Then each formula just tells you the following:

  1. To get the maximum $\max{(a, b)}$ you step on the midpoint $\frac{a+b}{2}$ and then "walk" half the distance between them on the positive direction on real line, that is, you add $\frac{|a-b|}{2}$ so you get $$\max{(a, b)} = \frac{a+b + |a-b|}{2}$$
  2. To get the minimum $\min{(a, b)}$ you would do the same thing, but you would "walk" now in the negative direction, so you would subtract $\frac{|a-b|}{2}$ to get now $$\min{(a, b)} = \frac{a+b - |a-b|}{2}$$

It is easy once you realize that always

$$a+b = \max(a,b) + \min(a,b) $$ because you are adding the smallest and the largest if you add both and $$|a-b| = \max(a,b) - \min(a,b) $$ because you calculate the distance by taking the largest and subtracting the smallest.

To compute the formula given, you just add or subtract the two equations.