Prev Next

Evaluate a Function Defined in Terms of an ODE

Syntax
# include <cppad/speed/ode_evaluate.hpp>
ode_evaluate(xmfm)

Purpose
This routine evaluates a function that is defined by the following initial value problem:  \[
\begin{array}{rcl}
     y(x, 0)                & = & b(x)
     \\
     \partial_t y ( x , t ) & = & g[ x , y(x,t) , t ]
\end{array}
\] 
where  b : \R^n \rightarrow \R^n and  g : \R^n \times \R^n \times \R \rightarrow \R are not any further specified. A numerical method is used to solve the ode and obtain an accurate approximation for  y(x, 1) . This in turn is used to compute values and gradients for the function  f : \R^n \rightarrow \R defined by  \[
     f(x) = y_n ( x , 1)
\] 


Inclusion
The template function ode_evaluate is defined in the CppAD namespace by including the file cppad/speed/ode_evaluate.hpp (relative to the CppAD distribution directory). It is only intended for example and testing purposes, so it is not automatically included by cppad.hpp .

Float
The type Float must be a NumericType . In addition, if y and z are Float objects,
     
y = exp(z)
must set the y equal the exponential of z , i.e., the derivative of y with respect to z is equal to y .

Operation Sequence
The functions  b(x) ,  g(x, y, t) and the ODE solver are chosen so that the Float operation sequence does not depend on the value of  x .

x
The argument x has prototype
     const CppAD::vector<
Float> &x
It contains he argument value for which the function, or its derivative, is being evaluated. The value  n is determined by the size of the vector x .

m
The argument m has prototype
     size_t 
m
It is either zero or one and specifies the order of the derivative of  f(x) , with respect to  x , that is being evaluated.

m = 1
In the case where  m = 1 , the following extended system is solved:  \[
\begin{array}{rcl}
y(x, 0)                & = & b(x)
\\
\partial_t y ( x , t ) & = & g[ x , y(x,t) , t ]
\\
y_x (x, 0)             & = & b^{(1)} (x)
\\
partial_t y_x (x,  t)  & = & \partial_x g[ x , y(x,t) , t ] 
                         +   \partial_y g[ x , y(x,t) , t ] y_x
\end{array}
\] 


fm
The argument fm has prototype
     CppAD::vector<
Float> &fm
The input value of the elements of fm does not matter.

Function
If m is zero, fm has size equal to one and fm[0] is the value of  y(x, 1) .

Gradient
If m is one, fm has size equal to n and for  j = 0 , \ldots , n-1  \[
     \D{y}{x[j]} (x, 1) = fm [ j ]
\] 


Example
The file ode_evaluate.cpp contains an example and test of ode_evaluate.hpp. It returns true if it succeeds and false otherwise.

Source Code
The file ode_evaluate.hpp contains the source code for this template function.
Input File: cppad/speed/ode_evaluate.hpp