<s>[INST] Nice expression for minimum of three variables? As we saw here, the minimum of two quantities can be written using elementary functions and the absolute value function.
$\min(a,b)=\frac{a+b}{2} - \frac{|a-b|}{2}$
There's even a nice intuitive explanation to go along with this: If we go to the point half way between two numbers, then going down by half their difference will take us to the smaller one. So my question is: "Is there a similar formula for three numbers?"
Obviously $\min(a,\min(b,c))$ will work, but this gives us the expression:
$$\frac{a+\left(\frac{b+c}{2} - \frac{|b-c|}{2}\right)}{2} - \frac{\left|a-\left(\frac{b+c}{2} - \frac{|b-c|}{2}\right)\right|}{2},$$
which isn't intuitively the minimum of three numbers, and isn't even symmetrical in the variables, even though its output is. Is there some nicer way of expressing this function?
 [/INST] First, define
$$
\Delta=|a-b|+|b-c|+|c-a|\newcommand{\Mu}{\mathrm{M}}\tag{1}
$$
It is somewhat intuitive that
$$
\frac{\Delta}{2}=\max(a,b,c)-\min(a,b,c)\tag{2}
$$
For example, if $a\ge b\ge c$ then $|a-b|+|b-c|+|c-a|=2a-2c$.
Next, define
$$
\Sigma=a\left(1-\frac{|b-c|}{\Delta}\right)+b\left(1-\frac{|c-a|}{\Delta}\right)+c\left(1-\frac{|a-b|}{\Delta}\right)\tag{3}
$$
Again, if $a\ge b\ge c$, then
$$
\begin{align}
\Sigma
&=a\left(\frac{2a-b-c}{2(a-c)}\right)+b\left(\frac{a-c}{2(a-c)}\right)+c\left(\frac{a+b-2c}{2(a-c)}\right)\\
&=a+c
\end{align}
$$
Thus, considering the symmetry of $(3)$, it is evident that
$$
\Sigma=\max(a,b,c)+\min(a,b,c)\tag{4}
$$
Combining $(2)$ and $(4)$ yields
$$
\max(a,b,c)=\frac{\Sigma}{2}+\frac{\Delta}{4}\tag{5}
$$
and
$$
\min(a,b,c)=\frac{\Sigma}{2}-\frac{\Delta}{4}\tag{6}
$$
At least $(5)$ and $(6)$ are symmetric in $a$, $b$, and $c$ since $(1)$ and $(3)$ are. That is,
$$
\begin{align}
\max(a,b,c)
&=\frac{a}{2}\left(\frac{|c-a|+|a-b|}{|a-b|+|b-c|+|c-a|}\right)\\
&+\frac{b}{2}\left(\frac{|a-b|+|b-c|}{|a-b|+|b-c|+|c-a|}\right)\\
&+\frac{c}{2}\left(\frac{|b-c|+|c-a|}{|a-b|+|b-c|+|c-a|}\right)\\
&+\frac{|a-b|+|b-c|+|c-a|}{4}\tag{7}
\end{align}
$$
and
$$
\begin{align}
\min(a,b,c)
&=\frac{a}{2}\left(\frac{|c-a|+|a-b|}{|a-b|+|b-c|+|c-a|}\right)\\
&+\frac{b}{2}\left(\frac{|a-b|+|b-c|}{|a-b|+|b-c|+|c-a|}\right)\\
&+\frac{c}{2}\left(\frac{|b-c|+|c-a|}{|a-b|+|b-c|+|c-a|}\right)\\
&-\frac{|a-b|+|b-c|+|c-a|}{4}\tag{8}
\end{align}
$$
</s>