![]() |
Prev | Next |
y = abs(
x)
const AD<
Base> &
x
const VecAD<
Base>::reference &
x
AD<
Base>
y
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
).
x > 0
and minus one for
x < 0
.
The subtitle issue is
how 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.
\]