Prev | Next | forward_two |
y2 = f.Forward(1, x2)
f
.
The result of the syntax above is that for
i = 0 , ... , m-1
,
y2[i]
@(@
= F_i^{(1)} (x0) * x2 + \frac{1}{2} x1^T * F_i^{(2)} (x0) * x1
@)@
where
@(@
F^{(1)} (x0)
@)@ is the Jacobian of @(@
F
@)@, and
@(@
F_i^{(2)} (x0)
@)@ is the Hessian of th i
-th component of @(@
F
@)@,
evaluated at
x0
.
f
has prototype
ADFun<Base> f
Note that the ADFun
object
f
is not const
.
Before this call to Forward
, the value returned by
f.size_order()
must be greater than or equal two.
After this call it will be will be three (see size_order
).
x0
in the formula for
y2[i]
corresponds to the previous call to forward_zero
using this ADFun object
f
; i.e.,
f.Forward(0, x0)
If there is no previous call with the first argument zero,
the value of the independent
variables
during the recording of the AD sequence of operations is used
for
x0
.
x1
in the formula for
y2[i]
corresponds to the previous call to forward_one
using this ADFun object
f
; i.e.,
f.Forward(1, x1)
x2
has prototype
const Vector& x2
(see Vector
below)
and its size must be equal to
n
, the dimension of the
domain
space for
f
.
y2
has prototype
Vector y2
(see Vector
below)
The size of
y1
is equal to
m
, the dimension of the
range
space for
f
.
Its value is given element-wise by the formula in the
purpose
above.
Vector
must be a SimpleVector
class with
elements of type
Base
.
The routine CheckSimpleVector
will generate an error message
if this is not the case.
= x0
,
@(@
x^{(1)}
@)@
= x1
,
@(@
X(t) = x^{(0)} + x^{(1)} t + x^{(2)} t^2
@)@, and
@[@
y^{(0)} + y^{(1)} t + y^{(2)} t^2
=
F [ x^{(0)} + x^{(1)} t + x^{(2)} t^2 ] + o(t^2)
@]@
Restricting our attention to the i
-th component, and
taking the derivative with respect to @(@
t
@)@, we obtain
@[@
y_i^{(1)} + 2 y_i^{(2)} t
=
F_i^{(1)} [ x^{(0)} + x^{(1)} t + x^{(2)} t^2 ] [ x^{(1)} + 2 x^{(2)} t ]
+
o(t)
@]@
Taking a second derivative with respect to @(@
t
@)@,
and evaluating at @(@
t = 0
@)@, we obtain
@[@
2 y_i^{(2)}
=
[ x^{(1)} ]^T F_i^{(2)} [ x^{(0)} ] x^{(1)}
+
F_i^{(1)} [ x^{(0)} ] 2 x^{(2)}
@]@
which agrees with the specification for
y2[i]
in the
purpose
above.