WorkPrecision(prob, alg, abstols, reltols, dts) solves the problem
with each pair of tolerances (and time step, if dts is given) and
records the errors (against the analytic solution, or against appxsol
through appxtrue()) and the best of numruns timings. A solve that
fails or takes longer than timeout seconds gets NaN errors and time.
The errors computed by default depend on error_estimate: timeseries
errors for l2, l_inf, L2, L_inf and dense errors for L2,
L_inf. For a nonlinear problem the error is the l2 (default) or
l_inf norm of the residual, or of the difference with appxsol.
Arguments
- prob
A problem, or a list of problems selected by the option
prob_choice.- alg
The algorithm.
- abstols, reltols
Tolerances.
- dts
Time steps, or
NULL.- ...
Options:
name(default"WP-Alg"),appxsol,error_estimate(default"final","l2"for nonlinear problems),numruns(default 20),seconds(default 2),timeout,timeseries_errors,dense_errors,tags,auto_tags(defaultTRUE) and solver options; or, with the fields form, the remaining fields.- dt, p
The solver options
dtandp, named in the signature so that they do not partially matchdtsandprob.- abstol, reltol
Ignored: each run uses its own tolerances, as in Julia (named so that they do not partially match
abstolsandreltols).- x
A
WorkPrecision.- xlab, ylab, log, type, lwd
Plot settings.
Value
A WorkPrecision: a list with prob, abstols, reltols,
errors, times, dts, stats, name, error_estimate, N and
tags.
Details
WorkPrecision(prob, abstols, reltols, errors, times, dts, stats, name, error_estimate, N, tags) builds one from its fields (with errors a
named list of vectors or a list of named lists, one per tolerance).
length(wp) is the number of tolerances and wp[[i]] the ith time;
plot(wp) draws the time against the error on log scales.
Examples
fn <- ODEFunction(function(u, p, t) -u, analytic = function(u0, p, t) u0 * exp(-t))
prob <- ODEProblem(fn, 1, c(0, 1))
wp <- WorkPrecision(prob, Tsit5(), c(1e-4, 1e-6), c(1e-4, 1e-6), numruns = 1)
wp$errors$final
#> [1] 3.77027e-08 2.44366e-09