Hello,


I have the following function form as one of my constraints :


f(x) = MIN(0, x)


Because of the MIN, it is non-differentiable.


As I would like to use an optimizer that uses derivative based methods, I need my objective function and constraints to be differentiable.


How could I convert (or approximate) this function into a differentiable one?


Here is an [example of data and the function chart](https://i.stack.imgur.com/W17xA.png), even if it is trivial.



Converting (or approximating) a non-differentiable function to a differentiable function
You can try


$f(\xi) = \frac{\xi}{2}+\frac{\ln 2}{2k} + \frac{\ln(\cosh(k \xi)}{2k},$


whose derivative is


$f'(\xi) = \frac{1}{2} [\tanh(k \xi) + 1].$


This function approaches the maximum as $k\rightarrow \infty$ (change as needed for the minimum). Will this help solve your problem? Perhaps, if the lack of smoothness is not its essential feature - a question related to the domain of application, not strictly a mathematical issue.


