detools::modode
-- modified
equationdetools::modode
implements the method of the modified
equation for the analysis of numerical integration methods applied to
ordinary differential equations.
detools::modode(Psi, depvars, indvar, step, order)
detools::modode(F, method, depvars, indvar, step,
order)
Psi |
- | the step function for the numerical method applied to the given differential equation: a list of expressions |
depvars |
- | the names of the unknown functions: a list of (indexed) identifiers. |
indvar |
- | the name of the independent variable: an (indexed) identifier. |
step |
- | the name of the step size: an (indexed) identifier. |
depvars |
- | the order (in step ) to which the modified
equation should be computed: a positive integer. |
F |
- | the right hand side of the differential equation: a
procedure of the same form as required by numeric::odesolve . |
method |
- | the name of the chosen numerical method: a string. |
a list of expressions representing the right hand side of the modified equation.
step
. Their analysis allows statements about the
properties of the chosen numerical method applied to the given
equation.numeric::odesolve
it is not
necessary to give explicitly the step function Psi
.
Instead one can give to detools::modode
the right hand
side F
of the differential equation in the form used by
numeric::odesolve
and the name method
of the integrator one is interested
in. detools::modode
will then call numeric::odesolve
with the option
Symbolic and thus automatically derive the step
function Psi
.The following input determines the modified equation of order 3 for the (forward) Euler method applied to the differential equation diff(y,t)=z and diff(z,t)=-y.
>> detools::modode([z, - y], [y, z], t, h, 3)
-- 2 3 2 3 -- | h y h z h y h z h y h z | | z + --- - ---- - ----, --- - y + ---- - ---- | -- 2 3 4 2 3 4 --
The same result is obtained with the following sequence of commands.
>> F := proc(t,y) begin [y[2], - y[1]] end_proc: detools::modode(F, EULER1, [y, z], t, h, 3)
-- 2 3 2 3 -- | h y h z h y h z h y h z | | z + --- - ---- - ----, --- - y + ---- - ---- | -- 2 3 4 2 3 4 --