\(\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}} }\)
atomic_four_lin_ode
Atomic First Order Linear ODE Method: Example Implementation
Syntax
atomic_lin_ode
ode ( name )set
( r , step , pattern , transpose )get
( call_id , r , step , pattern , transpose )base_solver
( r , step , pattern , transpose , x , y )z(t, x)
Construct an atomic operation that computes an approximate solution of the first order linear initial value ODE
where \(z : \B{R} \times \B{R}^n \rightarrow \B{R}^m\), \(A : \B{R}^n \rightarrow \B{R}^{m \times m}\), \(b : \B{R}^n \rightarrow \B{R}^m\), and the subscript \(t\) denotes partial differentiation w.r.t \(t\).
call_id
This is a return value (argument) for the set
(get
) routine.
r
This is the value of t at which we are approximating \(z(t, x)\).
This is a argument (return value) for the set
(get
) routine.
step
This is a positive maximum step size to use when solving the ODE.
pattern
This is a sparsity pattern.
This is a argument (return value) for the set
(get
) routine.
nnz
We use nnz to denote pattern . nnz
() .
row
We use row to denote pattern . row
() .
col
We use col to denote pattern . col
() .
transpose
If transpose is true (false) the sparsity pattern is for
\(A(x)^\R{T}\) (\(A(x)\)).
This is a argument (return value) for the set
(get
) routine.
x
We use x to denote the argument to the atomic function.
In the call to base_solver
it is a CppAD vector with elements
of type Base .
n
The size of the vector x is \(n = nnz + m\).
A(x)
This matrix stored in the same order as pattern
at the beginning of the vector x .
To be specific,
if transpose is true (false),
for k = 0, …, nnz -1
,
\(A_{j,i} (x)\) ( \(A_{i,j} (x)\) ) is equal to
\(x[k]\) where i = row [ k ] and j = col [ k ] .
b(x)
This vector is stored at the end of x ; i.e. its j-th element is \(b_j (x) = x[ nnz + j ]\)
y(x)
We use \(y(x)\) to denote the final value of the ODE; i.e., \(y(x) = z(r, x)\).
m
We use m to denote the size of the vector y ( x ) . This is the number of equations in the ODE.
y
In the call to base_solver
,
y is a CppAD vector with elements of type Base .
The input value of its elements does not matter.
Upon return it contains the value \(y(x)\).
ax
In the call to lin_ode , ax
is a simple vector with elements of type AD
< Base > .
The elements of ax have the same meaning as x .
ay
In the call to lin_ode , ay
is a simple vector with elements of type AD
< Base > .
The input value of its elements does not matter.
Upon return it represents the solution y ( ax ) .
vk(x)
We sometimes use the following representation for \(y(x)\):
Define \(v^0 (x) = b(x)\) and for \(k = 1, 2, \ldots\), \(v^k (x) = (r / k) A(x) v^{k-1} (x)\). Using this notation,
Approximations
Rosen34
The Rosen34 routine is used to approximate the solution of the ODE. Any initial value ODE solver can be used for this purpose.
Simpson’s Rule
Simpson’s Rule is used to approximate the integral
Any other approximation for this integral can be used.
Contents
Name |
Title |
---|---|
atomic_four_lin_ode_implement |
|
atomic_four_lin_ode_forward.cpp |
|
atomic_four_lin_ode_reverse.cpp |
|
atomic_four_lin_ode_sparsity.cpp |
|
atomic_four_lin_ode_rev_depend.cpp |
Atomic Linear ODE Reverse Dependency Analysis: Example and Test |