<s>[INST] simplifying $\min(\max(A,B),C) $ In a larger problem, I have to make use of the following
$$\min(\max(A,\ B),\ C)$$  
Please how do I simplify?
 [/INST] For $a, b ∈ \Bbb R:$
$$\max\left(a,b\right) = \frac{a+b+\left|a-b\right|}{2}$$
$$\min\left(a,b\right) = \frac{a+b-\left|a-b\right|}{2}$$
Therefore, if  $a,b,c ∈ \Bbb R:$
$$\min\left(\max\left(a,b\right),c\right) =
 \min\left(\frac{a+b+\left| a-b\right|}{2},c\right)  = $$
$$=\frac{\frac{a+b+\left| a-b\right|}{2}+c-\left|\frac{a+b+\left|a-b\right|}{2}-c\right|}{2}=
\frac{a+b+\lvert a-b\rvert}{4}+\frac{c}{2}-\left|\frac{a+b+|a-b|}{4}-\frac{c}{2}\right|=$$
$$=\frac{a+b+\left|a-b\right|+2c}{4}-\left|\frac{a+b+|a-b|-2c}{4}\right|=$$
$$=\frac{a+b+\left|a-b\right|+2c-\Big|a+b+\left|a-b\right|-2c\Big|}{4}$$
</s>