solve(prob, alg) solves a problem built by ODEProblem() and the other
problem constructors. It is a method of the base R generic base::solve(),
so solve() keeps working for matrices and for symcompR expressions.
Arguments
- a
A problem.
- b
An algorithm such as
Tsit5();DefaultODEAlgorithm()when missing.- ...
Solver options:
saveat(times to save at),abstol,reltol,dt(initial or fixed step),dtmax,dtmin,maxiters,tstops,callback,save_everystep,save_start,save_end,dense,adaptive,step_limiter(a functionlimiter(u, integ, p, t)returning the state to keep after each accepted step), the controller settingsqmin,qmax,gamma,beta1,beta2, and the step checksisoutofdomain(a function(u, p, t); a step whose state it flags is rejected),unstable_check(a function(dt, u, p, t); the solve ends with "Unstable" when it returnsTRUEafter a step),internalnorm(the error norm, a function(u, t)) andforce_dtmin. An unknown keyword is an error;kwargshandle = "warn"or"silent"warns or ignores it. A problem without unknowns returns its save times without integrating. The solution interpolates derivatives too:sol(t, deriv = 1).
Value
A solution object. Its retcode is one of "Success",
"Terminated", "MaxIters", "DtLessThanMin", "Unstable",
"InitialFailure" or "ConvergenceFailure"; sol$stats counts function
evaluations (nf), Jacobians (njacs), linear solves (nsolve),
factorizations (nw), accepted (naccept) and rejected (nreject)
steps.
Examples
prob <- ODEProblem(function(u, p, t) -p * u, 1, c(0, 1), p = 2)
sol <- solve(prob, Tsit5(), reltol = 1e-8)
sol(1) - exp(-2)
#> [1] 6.972457e-09