For two variables, their maximum
$\max\{x\_1,x\_2\}$ can be expressed using one $|\cdot|$ operation:
$$
\max\{x\_1,x\_2\} = \frac12(x\_1+x\_2+|x\_1-x\_2|).
$$
For $3$ variables, it seems fairly clear that three $|\cdot|$ operations are necessary, though I can only demonstrate sufficiency:
$$
\max\{x\_1,x\_2,x\_3\}
=
\frac14\left[
2x\_1+x\_2+x\_3+|x\_2-x\_3|+2\left|x\_1-\frac12(x\_2+x\_3+|x\_2-x\_3|)\right|
\right]
.
$$
For $5$ variables, it has been claimed here
<https://twitter.com/ereliuer_eteer/status/1669081421007454209>
that the minimum number of
$|\cdot|$ operations is 54, though I have verified neither sufficiency nor necessity.


Question: How many $|\cdot|$ operations are necessary for $n$ variables?
To be explicit about the rules, in addition to $|\cdot|$, the 4 arithmetic operations are allowed.


Update. That twitter post I linked is actually computing the median, not the max of 5 variables. So the analogous question for abs-operation complexity, but now for the median, is quite natural.



Minimum number of $|\cdot|$ operations necessary to express $\max$
Let $f(k)$ be the minimum number of $|\cdot|$ operations to express the maximum of $2^k$ variables. Using the identities
$$\max\{x\_1,x\_2\} = (x\_1+x\_2+|x\_1-x\_2|)/2,$$
$$\max\{x\_1,\ldots,x\_{2^{k+1}}\} = 
\max\{\max\{x\_1,\ldots,x\_{2^k}\},\max\{x\_{2^k+1},\ldots,x\_{2^{k+1}}\}\},$$
it is clear that $f(1)=1$ and $f(k+1)\leq 4f(k)+1$. Hence it follows by induction that
$$f(k)\leq (4^k-1)/3.$$
Now let us consider the case of $n$ variables. If $2^{k-1}<n\leq 2^k$, then the minimal number of corresponding $|\cdot|$ operations is less than $4^k/3$, which is less than $(4/3)n^2$.


**Added.** In fact that minimal number of $|\cdot|$ operations is less than $(3/8)n^2$. For details, see AspiringMat's response and the comments below it.


