ExplicitTaylor2() is the fixed step second order Taylor method: the
second derivative comes from evaluating f on first order Taylor numbers.
ExplicitTaylor(order) is the adaptive Taylor method of the given order
with the error estimate of its last term and the PI controller of that
order. ExplicitTaylorAdaptiveOrder(min_order, max_order) computes the
jet one order above its current order every step and moves to the order,
among the current one and its neighbours, that minimizes the work
(order squared over the proposed step); it starts at max_order - 1.
Usage
ExplicitTaylor2(stage_limiter = NULL, step_limiter = NULL, thread = NULL)
ExplicitTaylor(
order = 1L,
stage_limiter = NULL,
step_limiter = NULL,
thread = NULL
)
ExplicitTaylorAdaptiveOrder(
min_order = 1L,
max_order = 10L,
stage_limiter = NULL,
step_limiter = NULL,
thread = NULL
)Arguments
- stage_limiter
Stored only (not called, as in Julia).
- step_limiter
Optional
function(u, integrator, p, t)applied after every accepted step.- thread
Ignored.
- order
Order of the Taylor expansion (a positive integer).
- min_order, max_order
Bounds of the order of
ExplicitTaylorAdaptiveOrder();max_ordermust exceedmin_order.
Details
The right-hand side f(u, p, t) is evaluated in Taylor mode arithmetic
(TaylorDiff's recurrences): it may use +, -, *, /, ^, exp,
log, sqrt, sin, cos, sum, indexing and c(), and must return its
result built from those (as c(...)). Julia builds the jet once,
symbolically, so the higher order coefficients agree with it up to
rounding; ExplicitTaylor2() matches it exactly. The dense output is the
Taylor polynomial of each step. Function evaluations are counted as in
Julia: 3 per step for ExplicitTaylor2(), order + 1 for
ExplicitTaylor(), the current order plus one for the adaptive order
method.
Examples
prob <- ODEProblem(function(u, p, t) c(u[2], -u[1]), c(0, 1), c(0, 1))
solve(prob, ExplicitTaylor2(), dt = 0.1)$u[[11]]
#> [1] 0.8424729 0.5389707
solve(prob, ExplicitTaylor(order = 6), reltol = 1e-8, abstol = 1e-10)$u[[2]]
#> [1] 0.009900828 0.999950986
sol <- solve(prob, ExplicitTaylorAdaptiveOrder(), reltol = 1e-8, abstol = 1e-10)
sol$u[[length(sol$u)]]
#> [1] 0.8414710 0.5403023