Q: Do you know a smooth approximation for max(x,0), and min(x,0)?
This comes from Prof. Ignacio Grossmann (CMU):
Use the approximation
( sqrt( sqr(x) + sqr(epsilon) ) + x ) / 2
for max(x,0), where sqrt is the square root and sqr is the square.
The error err(x) in the above approximation is maximized at 0 (the point of non differentiability), where err(0) = epsilon. As x goes to +/- infinity, err(x) goes to 0. One can reduce the maximum error to epsilon/2 by using the approximation given below. This provides a better approximation near the point of non smoothness but is not so accurate away from this point.
( sqrt( sqr(x) + sqr(epsilon) ) + x - epsilon ) / 2
Because min(x,0) = -max(-x,0), you can use the above approximations for min(x,0) as well. Epsilon is a small positive constant.