Skip to contents

For du = (A(u, p, t) u + f2(u, p, t)) dt + g(u, p, t) dW given as a SplitSDEProblem() whose f1(u, p, t) returns the matrix A (a number for scalar problems), IIF1M() solves u = exp(A dt) (uprev + g dW) + dt f2(u, p, t + dt) and IIF2M() solves u = exp(A dt) (uprev + dt / 2 f2(uprev, p, t) + g dW) + dt / 2 f2(u, p, t + dt), both of strong order 1/2. IIF1Mil() adds the Milstein correction sum_j (M g(uprev + sqrt(dt) M g_j) - M g(uprev)) / sqrt(dt) I_j with M = exp(A dt) and the iterated integrals I = (dW dW' - dt I) / 2 of commutative noise, for strong order 1. A is evaluated at the start of the step. The implicit equation is solved by the trust region method of SimpleTrustRegion() from the current state; nlsolve is a NLSOLVEJL_SETUP() object, kept for the signature. These methods take a fixed step size dt.

Usage

NLSOLVEJL_SETUP(autodiff = AutoForwardDiff())

IIFNLSolveFunc(f)

IIF1M(nlsolve = NLSOLVEJL_SETUP())

IIF2M(nlsolve = NLSOLVEJL_SETUP())

IIF1Mil(nlsolve = NLSOLVEJL_SETUP())

Arguments

autodiff

The differentiation choice of the inner solve; R uses finite differences.

f

A residual function of u.

nlsolve

The nonlinear solver setup.

Value

An SDE algorithm, an NLSOLVEJL_SETUP object (a function of a wrapped residual and a start value) or an IIFNLSolveFunc object.

Details

IIFNLSolveFunc(f) wraps the residual function f(u) of such an implicit equation, as the Val{:init} call of NLSOLVEJL_SETUP() does upstream, and NLSOLVEJL_SETUP() solves f(u) = 0 from u0 when called as setup(wrapped, u0).

Examples

prob <- SplitSDEProblem(function(u, p, t) -1, function(u, p, t) 0.5 * u,
                        function(u, p, t) 0.2 * u, 1, c(0, 1))
sol <- solve(prob, IIF1M(), dt = 0.1, seed = 1)
sol$u[[11]]
#> [1] 0.6606603
setup <- NLSOLVEJL_SETUP()
setup(IIFNLSolveFunc(function(u) u^2 - 2), 1)
#> [1] 1.414214