atomic_four_lin_ode

View page source

Atomic First Order Linear ODE Method: Example Implementation

Syntax

atomic_lin_ode ode ( name )
call_id = lin_ode . set ( r , step , pattern , transpose )
lin_ode . get ( call_id , r , step , pattern , transpose )
lin_ode . base_solver ( r , step , pattern , transpose , x , y )
lin_ode ( call_id , ax , ay )

z(t, x)

Construct an atomic operation that computes an approximate solution of the first order linear initial value ODE

\[z_t (t, x) = A(x) z(t, x) \W{,} z(0, x) = b(x)\]

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)\):

\[y(x) = \exp [ r A(x) ] b(x) = \sum_{k=0}^\infty \frac{r^k}{k!} A(x)^k b(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,

\[y(x) = \sum_{k=0}^\infty v^k (x)\]

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

\[\int_0^r \lambda_i (t, x) z_j (r, x) \R{d} t\]

Any other approximation for this integral can be used.

Contents

Name

Title

atomic_four_lin_ode_implement

Implementing Atomic Linear ODE

atomic_four_lin_ode_forward.cpp

Atomic Linear ODE Forward Mode: Example and Test

atomic_four_lin_ode_reverse.cpp

Atomic Linear ODE Reverse Mode: Example and Test

atomic_four_lin_ode_sparsity.cpp

Atomic Linear ODE Sparsity Calculations: Example and Test

atomic_four_lin_ode_rev_depend.cpp

Atomic Linear ODE Reverse Dependency Analysis: Example and Test