# Milstein method in DifferentialEquations.jl or other

**URL:** <https://discourse.julialang.org/t/milstein-method-in-differentialequations-jl-or-other/80107>\
**Category:** General Usage\
**Tags:** question, package, diffeq\
**Created:** [April 27, 2022, 7:54am UTC](https://discourse.julialang.org/t/milstein-method-in-differentialequations-jl-or-other/80107 "2022-04-27T07:54:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [April 27, 2022, 7:54am UTC](https://discourse.julialang.org/t/milstein-method-in-differentialequations-jl-or-other/80107/1 "2022-04-27T07:54:11Z")

</div>

I am trying to use a Milstein method in `DifferentialEquations.jl` to solve a stochastic differential equation \mathrm{d}X(t)=f(X(t))\mathrm{d}t + g(X(t))\mathrm{d}W(t), where the Milstein method is defined by

X\_{n+1}=X\_n+f(X\_n)\Delta t + g(X\_n)\Delta W\_n+\frac12g'(X\_n)g(X\_n)\left[\Delta W\_n^2-\Delta t\right]

for a fixed time step \Delta t. Is this method implemented anywhere in `DifferentialEquations.jl` or elsewhere in Julia? I tried using `RKMil()` based on the list of available solvers in [SDE Solvers · DifferentialEquations.jl](https://diffeq.sciml.ai/stable/solvers/sde_solve/), but it seems to only allow for adaptive time stepping.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 27, 2022, 12:17pm UTC](https://discourse.julialang.org/t/milstein-method-in-differentialequations-jl-or-other/80107/2 "2022-04-27T12:17:33Z")

</div>

All (Julia-based) methods can be made non-adaptive via `adaptive=false`.

[https://diffeq.sciml.ai/stable/basics/common\_solver\_opts/#Basic-Stepsize-Control](https://diffeq.sciml.ai/stable/basics/common_solver_opts/#Basic-Stepsize-Control)

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [April 27, 2022, 12:49pm UTC](https://discourse.julialang.org/t/milstein-method-in-differentialequations-jl-or-other/80107/3 "2022-04-27T12:49:01Z")

</div>

Thank you @ChrisRackauckas - I missed that option, my mistake.

Is there an easy way to check the actual formula being used by the algorithms in your package? I’m new to SDEs so I’m having difficulties understanding which of the many Milstein methods match up with those in the question. Searching through the documentation for a citation, and in the source code itself for `RKMil()`, hasn’t revealed it for me. Apologies in advance if this is obvious.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 27, 2022, 12:53pm UTC](https://discourse.julialang.org/t/milstein-method-in-differentialequations-jl-or-other/80107/4 "2022-04-27T12:53:51Z")

</div>

`?alg` should always give the citation. `?RKMil` reveals:

```julia
Kloeden, P.E., Platen, E., Numerical Solution of Stochastic Differential Equations.
Springer. Berlin Heidelberg (2011)
RKMil: Nonstiff Method
An explicit Runge-Kutta discretization of the strong order 1.0 Milstein method.
Defaults to solving the Ito problem, but RKMil(interpretation=:Stratonovich) makes it solve the Stratonovich problem.
Only handles scalar and diagonal noise.

```

Though I need to update that to be more precise. There’s a bit of influence from [SDELab: A package for solving stochastic differential equations in MATLAB - ScienceDirect](https://www.sciencedirect.com/science/article/pii/S0377042706004195) and with Levy areas from [[2201.08424] An Analysis of Approximation Algorithms for Iterated Stochastic Integrals and a Julia and MATLAB Simulation Toolbox](https://arxiv.org/abs/2201.08424). Then the adaptivity is [ADAPTIVE METHODS FOR STOCHASTIC DIFFERENTIAL EQUATIONS VIA NATURAL EMBEDDINGS AND REJECTION SAMPLING WITH MEMORY - PMC](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5844583/)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 27, 2022, 12:54pm UTC](https://discourse.julialang.org/t/milstein-method-in-differentialequations-jl-or-other/80107/5 "2022-04-27T12:54:21Z")

</div>

> [@DanielVandH](#):
>
> Thank you @ChrisRackauckas - I missed that option, my mistake.

Not your mistake. I’m reworking the common kwarg docs to make them more visible.
