How to invert $\max()$ and $\min()$ operators in equations Let the following equation is given:
$$a=\max[\min(c,gy+s),f]$$
where $a$, $c$, $y$, $s$ and $f$ are real numbers.
I would like to get $y$ in closed form moving variables from the right-hand side to the left-hand side of the above equation.
Is it possible and how?
 A: Hint: try to prove that
1.
$$\min\{a,b\}=\frac{a+b-|a-b|}{2}$$
2.
$$\max\{a,b\}=\frac{a+b+|a-b|}{2}$$
Added:
Here is an expression for $\max\{\min\{c,gy+s\},f\}$:
$$a=\max\{\min\{c,gy+s\},f\}=\max\{\frac{c+gy+s-|c-gy-s|}{2}, f\}$$
$$=\frac{\frac{c+gy+s-|c-gy-s|}{2}+f+|\frac{c+gy+s-|c-gy-s|}{2}-f|}{2}$$
A: You can't, because whenever $f>gy+s$ (whatever the value of $y$) then $a=f$ so there is no way to invert.
One could say, more formally, that the functions $x\to\max(x,c)$ and $x\to\min(x, c)$ are not invertible, so there is no general way to find the inverse.
If you are able to spearate your domain into different parts, then it would be different, as you would analyze each of the different cases:
Suppose first that $f < c$, so $f ≤ a ≤ c$.


*

*$f < a < c$. From $f<a$, one can deduce that $a = \min(c,gy+s)$ and from $a<c$ one can deduce that $a=gy+s$.

*$a = f < c$. Then $a = f = \max(\min(c,gy+s), f)$, so you deduce that $f ≥ \min(c,gy+s)$ which means that either $f ≥ c$ (against our hypothesis) or $f ≥ gy+s$. That's the best you can get in this case.

*$f < c = a$. Then, being $a\neq f$, $a = c = \min(c,gy+s)$ so $c = \min(c,gy+s)$, so $c≤gy+s$.
Now suppose $f ≥ c$. Then $f ≥ \min(c, gy+s)$ so $a=f$. No further information can be deduced about $g$, $y$ or $s$.
