|
Prev | Next |
# include <cppad/rosen_34.hpp>
xf = Rosen34(F, M, ti, tf, xi)
xf = Rosen34(F, M, ti, tf, xi, e)
We use
n
for the size of the vector xi.
Let
\R
denote the real numbers
and let
F : \R \times \R^n \rightarrow \R^n
be a smooth function.
The return value xf contains a 5th order
approximation for the value
X(tf)
where
X : [ti , tf] \rightarrow \R^n
is defined by
the following initial value problem:
\[
\begin{array}{rcl}
X(ti) & = & xi \\
X'(t) & = & F[t , X(t)]
\end{array}
\]
If your set of ordinary differential equations are not stiff
an explicit method may be better (perhaps Runge45
.)
cppad/rosen_34.hpp is included by cppad/cppad.hpp
but it can also be included separately with out the rest of
the CppAD routines.
Vector xf
and the size of xf is equal to n
(see description of Vector
below).
\[
X(tf) = xf + O( h^5 )
\]
where
h = (tf - ti) / M
is the step size.
If xf contains not a number nan
,
see the discussion of f
.
Fun &F
This must support the following set of calls
F.Ode(t, x, f)
F.Ode_ind(t, x, f_t)
F.Ode_dep(t, x, f_x)
const Scalar &t
(see description of Scalar
below).
const Vector &x
and has size n
(see description of Vector
below).
F.Ode has prototype
Vector &f
On input and output, f is a vector of size n
and the input values of the elements of f do not matter.
On output,
f is set equal to
F(t, x)
(see F(t, x) in Description
).
F.Ode_ind has prototype
Vector &f_t
On input and output, f_t is a vector of size n
and the input values of the elements of f_t do not matter.
On output, the i-th element of
f_t is set equal to
\partial_t F_i (t, x)
(see F(t, x) in Description
).
F.Ode_dep has prototype
Vector &f_x
On input and output, f_x is a vector of size n*n
and the input values of the elements of f_x do not matter.
On output, the [i*n+j] element of
f_x is set equal to
\partial_{x(j)} F_i (t, x)
(see F(t, x) in Description
).
nan,
the routine Rosen34 returns with all the
elements of xf and e equal to nan.
& in the prototype for
f, f_t and f_x.
F.Ode_ind(t, x, f_t)
is directly followed by a call of the form
F.Ode_dep(t, x, f_x)
where the arguments t and x have not changed between calls.
In many cases it is faster to compute the values of f_t
and f_x together and then pass them back one at a time.
size_t M
It specifies the number of steps
to use when solving the differential equation.
This must be greater than or equal one.
The step size is given by
h = (tf - ti) / M
, thus
the larger M, the more accurate the
return value xf is as an approximation
for
X(tf)
.
const Scalar &ti
(see description of Scalar
below).
It specifies the initial time for t in the
differential equation; i.e.,
the time corresponding to the value xi.
const Scalar &tf
It specifies the final time for t in the
differential equation; i.e.,
the time corresponding to the value xf.
const Vector &xi
and the size of xi is equal to n.
It specifies the value of
X(ti)
Vector &e
If e is present,
the size of e must be equal to n.
The input value of the elements of e does not matter.
On output
it contains an element by element
estimated bound for the absolute value of the error in xf
\[
e = O( h^4 )
\]
where
h = (tf - ti) / M
is the step size.
| Operation | Description |
a < b |
less than operator (returns a bool object)
|
cppad/rosen_34.hpp.