Absolute Value

The absolute value is one of the most useful functions that have a discontinuity in the first derivative and are therefore not available in optimisation programs based on derivatives. There are three types of approximations of the absolute value in PINS.

Approximation with erf

The erf function is very versatile to approximate those kind of functions. The regularised absolute value is controlled by the parameter \(h\) so that for \(x=0\) the function takes the value \(h\). The expression of the function is:

\[ |x|_{\erf}\DEF x\erf(\kappa x) + \dfrac{2}{\kappa \sqrt{\pi}} \mathrm{e}^{-\kappa^2 x^2},\]

where \(\kappa\DEF \frac{2}{h\sqrt{\pi}}\) is a constant once \(h\) is fixed. The first and second derivative of this function are:

\[\dfrac{\dd }{\dx} |x|_{\erf} = \erf(\kappa x), \qquad \dfrac{\dd^2 }{\dx^2}|x|_{\erf} = \dfrac{2\kappa}{\sqrt{\pi}}e^{-\kappa^2 x^2}.\]

Approximation with sin(atan())

It is possible to approximate the absolute value with the function sinus of the arctangent:

\[|x|_{\mathrm{sa}}\DEF \frac{x}{\sin\arctan(x/h)} = \sqrt{h^2+x^2}.\]

The shape parameter of this function is \(h\) and is chosen such that for \(x=0\) the function \(|x|_{\mathrm{sa}}\) assumes the value \(h\). The first and second derivatives are:

\[\dfrac{\dd }{\dx} |x|_{\mathrm{sa}}= \dfrac{x}{\sqrt{h^2+x^2}}, \qquad \dfrac{\dd^2 }{\dx^2}|x|_{\mathrm{sa}} = h^2(h^2+x^2)^{-3/2}.\]

Approximation with polynomials

A third way to approximate the absolute value function is with a smooth connection of two straight lines with a polynomial.

** TO BE COMPLTED **