|
Prev | Next |
y = abs(x)
x
has one of the following prototypes
const AD<Base> &x
const VecAD<Base>::reference &x
y
has prototype
AD<Base> y
Base
atomic operation
and hence is part of the current
AD of
Base
operation sequence
.
abs is not defined for the AD type sequences
above std::complex<float> or std::complex<double>
because the complex abs function is not complex differentiable
(see complex types faq
).
abs function is
the sign
function; i.e.,
\[
{\rm abs}^{(1)} ( x ) = {\rm sign} (x ) =
\left\{ \begin{array}{rl}
+1 & {\rm if} \; x > 0 \\
0 & {\rm if} \; x = 0 \\
-1 & {\rm if} \; x < 0
\end{array} \right.
\]
This used to be different;
see old derivative
below.
x > 0
and minus one for
x < 0
.
CppAD used to compute its directional derivative
what
x = 0
.
The function corresponding to the argument
x
and the result
y
are represented
by their Taylor coefficients; i.e.,
\[
\begin{array}{rcl}
X(t) & = & x^{(0)} (t) + x^{(1)} t + \cdots + x^{(p)} t^p
\\
Y(t) & = & y^{(0)} (t) + y^{(1)} t + \cdots + y^{(p)} t^p
\end{array}
\]
Note that
x^{(0)} = X(0)
is the value of
x
and
y^{(0)} = Y(0)
is the value of
y
.
In the equations above, the order
p
is specified
by a call to Forward
or Reverse
as follows:
f.Forward(p, dx)
f.Reverse(p+1, w)
If all of the Taylor coefficients of
X(t)
are zero,
we define
k = p
.
Otherwise, we define
k
to be the minimal index such that
x^{(k)} \neq 0
.
Note that if
x \neq 0
,
k = 0
.
The Taylor coefficient representation of
Y(t)
(and hence it's derivatives) are computed as
\[
y^{(\ell)}
=
\left\{ \begin{array}{ll}
x^{(\ell)} & {\rm if} \; x^{(k)} > 0 \\
0 & {\rm if} \; x^{(k)} = 0 \\
- x^{(\ell)} & {\rm if} \; x^{(k)} < 0
\end{array} \right.
\]