Prev Next

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@
Multiple Order Forward Mode

Syntax
yq = f.Forward(qxq )
yq = f.Forward(qxqs)

Purpose
We use @(@ F : B^n \rightarrow B^m @)@ to denote the AD function corresponding to f . Given a function @(@ X : B \rightarrow B^n @)@, defined by its Taylor coefficients , forward mode computes the Taylor coefficients for the function @[@ Y (t) = F [ X(t) ] @]@

Function Values
If you are using forward mode to compute values for @(@ F(x) @)@, forward_zero is simpler to understand than this explanation of the general case.

Derivative Values
If you are using forward mode to compute values for @(@ F^{(1)} (x) * dx @)@, forward_one is simpler to understand than this explanation of the general case.

Notation

n
We use n to denote the dimension of the domain space for f .

m
We use m to denote the dimension of the range space for f .

f
The ADFun object f has prototype
     ADFun<
Basef
Note that the ADFun object f is not const. After this call we will have
     
f.size_order()     == q + 1
     
f.size_direction() == 1

One Order
If xq.size() == n , then we are only computing one order. In this case, before this call we must have
     
f.size_order()     >= q
     
f.size_direction() == 1

q
The argument q has prototype
     size_t 
q
and specifies the highest order of the Taylor coefficients to be calculated.

xq
The argument xq has prototype
     const 
Vectorxq
(see Vector below). As above, we use n to denote the dimension of the domain space for f . The size of xq must be either n or n*(q+1) . After this call we will have
     
f.size_order()     == q + 1

One Order
If xq.size() == n , the q-th order Taylor coefficient for @(@ X(t) @)@ is defined by
     
@(@ x^{(q)} = @)@ xq . For @(@ k = 0 , \ldots , q-1 @)@, the Taylor coefficient @(@ x^{(k)} @)@ is defined by xk in the previous call to
     
f.Forward(kxk)

Multiple Orders
If xq.size() == n*(q+1) , For @(@ k = 0 , \ldots , q @)@, @(@ j = 0 , \ldots , n-1 @)@, the j-th component of the k-th order Taylor coefficient for @(@ X(t) @)@ is defined by
     
@(@ x_j^{(k)} = @)@ xq[ (q+1) * j + k ]

Restrictions
Note if f uses old_atomic functions, the size of xq must be n .

s
If the argument s is not present, std::cout is used in its place. Otherwise, this argument has prototype
     std::ostream& 
s
If order zero is begin calculated, s specifies where the output corresponding to PrintFor will be written. If order zero is not being calculated, s is not used

X(t)
The function @(@ X : B \rightarrow B^n @)@ is defined using the Taylor coefficients @(@ x^{(k)} \in B^n @)@: @[@ X(t) = x^{(0)} * t^0 + x^{(1)} * t^1 + \cdots + x^{(q)} * t^q @]@ Note that for @(@ k = 0 , \ldots , q @)@, the k-th derivative of @(@ X(t) @)@ is related to the Taylor coefficients by the equation @[@ x^{(k)} = \frac{1}{k !} X^{(k)} (0) @]@

Y(t)
The function @(@ Y : B \rightarrow B^m @)@ is defined by @(@ Y(t) = F[ X(t) ] @)@. We use @(@ y^{(k)} \in B^m @)@ to denote the k-th order Taylor coefficient of @(@ Y(t) @)@; i.e., @[@ Y(t) = y^{(0)} * t^0 + y^{(1)} * t^1 + \cdots + y^{(q)} * t^q + o( t^q ) @]@ where @(@ o( t^q ) * t^{-q} \rightarrow 0 @)@ as @(@ t \rightarrow 0 @)@. Note that @(@ y^{(k)} @)@ is related to the k-th derivative of @(@ Y(t) @)@ by the equation @[@ y^{(k)} = \frac{1}{k !} Y^{(k)} (0) @]@

yq
The return value yq has prototype
     
Vector yq
(see Vector below).

One Order
If xq.size() == n , the vector yq has size m . The q-th order Taylor coefficient for @(@ Y(t) @)@ is returned as
     
yq
@(@ = y^{(q)} @)@.

Multiple Orders
If xq.size() == n*(q+1) , the vector yq has size m*(q+1) . For @(@ k = 0 , \ldots , q @)@, for @(@ i = 0 , \ldots , m-1 @)@, the i-th component of the k-th order Taylor coefficient for @(@ Y(t) @)@ is returned as
     
yq[ (q+1) * i + k ]
@(@ = y_i^{(k)} @)@

Vector
The type 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.

Zero Order
The case where @(@ q = 0 @)@ and xq.size() == n , corresponds to the zero order special case .

First Order
The case where @(@ q = 1 @)@ and xq.size() == n , corresponds to the first order special case .

Second Order
The case where @(@ q = 2 @)@ and xq.size() == n , corresponds to the second order special case .

Example
The file forward.cpp ( forward_order.cpp ) contains an example and test using one order (multiple orders). They return true if they succeed and false otherwise.
Input File: omh/forward/forward_order.omh