Prev Next

Absolute Value Functions

Syntax
y = abs(x)

Purpose
Sets y equal to the absolute value of  x .

x
The argument x can be an instance of float, an a_float, an a2float, or an numpy.array of such objects.

y
If x is an instance of float, y will also be an instance of float . Otherwise y will have the same type as x .

In the case where x is an array, y will the same shape as x and the elements of y will have the same type as the elements of x .

Derivative
pycppad defines the derivative of the absolute value function by  \[
     \R{abs}^{(1)} (x) = \R{sign} (x) = \left\{ \begin{array}{ll} 
          1 & \R{if} \; x > 0
          \\
          0 & \R{if} \; x = 0
          \\
          -1 & \R{if} \; x < 0
     \end{array} \right.
\] 


Directional Derivative
Prior to 2011-12-30 , forward mode computed the directional derivative of the absolute value function which is defined by  \[
     \R{abs}^\circ ( x , d ) = \lim_{\lambda \downarrow 0 } 
          \frac{\R{abs}(x + \lambda d) - \R{abs}(x) }{ \lambda }
\] 
For  x \neq 0 ,  \[
     \R{abs}^\circ ( x , d ) = \R{abs}^{(1)} ( x ) * d
\] 
and  \R{abs}^\circ (0 , d) = |d| .

Example
The file abs.py contains an example and test of this function.
Input File: pycppad/pycppad.cpp