Quant techniques · simulation

Simulating SDEs: Euler, Milstein and the order of convergence

Most stochastic models in finance can’t be solved in closed form, so we simulate them in small time steps. The simplest scheme, Euler–Maruyama, copies the ordinary Euler method: take the drift times dt and the volatility times a normal increment. It works, but its paths drift away from the true ones faster than you might expect. The reason, and the fix, come from a term that ordinary calculus doesn’t have.

0dXt=a(Xt) dt+b(Xt) dWtdX_t = a(X_t)\,dt + b(X_t)\,dW_t A general one-dimensional SDE with drift a and diffusion b.
1Xn+1=Xn+a Δt+b ΔWX_{n+1} = X_n + a\,\Delta t + b\,\Delta W Euler–Maruyama. Strong order ½: path error ∝ (Δt)^½. Weak order 1: error in expectations ∝ Δt.
2Xn+1=Xn+a Δt+b ΔW+12 b b′ (ΔW2−Δt)X_{n+1} = X_n + a\,\Delta t + b\,\Delta W + \tfrac12\,b\,b'\,\big(\Delta W^2 - \Delta t\big) Milstein. The extra term is the next Itô–Taylor term. Strong order 1: path error ∝ Δt.
3GBM: b=σX,  b b′=σ2X\text{GBM: } b = \sigma X,\ \ b\,b' = \sigma^2 X For geometric Brownian motion the correction is 12σ2X(ΔW2−Δt)\tfrac12\sigma^2 X(\Delta W^2 - \Delta t).
Two kinds of error

Strong and weak convergence

There are two ways to measure how good a scheme is:

  • Strong error E[∣XT−XTΔt∣]E\big[\lvert X_T - X^{\Delta t}_T\rvert\big]: how close the simulated path ends to the true path driven by the same Brownian motion. This matters for path-dependent quantities, multilevel Monte Carlo, and hedging simulations.
  • Weak error ∣E[f(XT)]−E[f(XTΔt)]∣\big\lvert E[f(X_T)] - E[f(X^{\Delta t}_T)]\big\rvert: how close expectations are. This is what matters for pricing a European payoff.

Euler has weak order 1 but only strong order ½. For pricing with Euler, halving the step halves the bias. For anything that needs pathwise accuracy, you need four times as many steps to halve the error.

Where the extra term comes from

The Itô–Taylor expansion

Over one step, Xt+h=Xt+∫a ds+∫b(Xs) dWsX_{t+h} = X_t + \int a\,ds + \int b(X_s)\,dW_s. Euler freezes b(Xs)b(X_s) at b(Xt)b(X_t). Expanding b(Xs)≈b(Xt)+b′(Xt) (Xs−Xt)b(X_s) \approx b(X_t) + b'(X_t)\,(X_s - X_t) and keeping the largest piece, Xs−Xt≈b (Ws−Wt)X_s - X_t \approx b\,(W_s - W_t), gives an extra term

b b′∫tt+h(Ws−Wt) dWs=12 b b′ (ΔW2−h)b\,b' \int_t^{t+h} (W_s - W_t)\,dW_s = \tfrac12\,b\,b'\,\big(\Delta W^2 - h\big)

by Itô’s formula applied to W2W^2. Its size is of order ΔW2∼h\Delta W^2 \sim h, the same as the drift term, so dropping it, as Euler does, leaves an error of order h per step in a random direction. Those errors add up like a random walk, to order h\sqrt{h} overall: strong order ½. Milstein keeps the term and gets strong order 1.

Note the term has mean zero: E[ΔW2]=hE[\Delta W^2] = h. That’s why dropping it doesn’t hurt the weak order.

steps over one yearvolatility

Same Brownian path, three ways

Average |error| at T vs steps (log–log)

exact solutionEulerMilstein

At 80% volatility with 16 steps, the Euler polyline visibly wanders off the exact path while Milstein stays on it. The log–log plot measures the strong error over 600 paths: Euler’s slope is about ½, Milstein’s about 1. At 20% volatility both are much more accurate, because the error terms scale with σ², but the slopes are the same.

import numpy as np

def simulate_gbm(S0, mu, sigma, T, n_steps, dW):
    """Euler and Milstein end values for GBM, driven by given Brownian increments dW (shape: paths x n_steps)."""
    dt = T / n_steps
    euler = np.full(dW.shape[0], S0, dtype=float)
    milst = euler.copy()
    for i in range(n_steps):
        w = dW[:, i]
        euler = euler + mu * euler * dt + sigma * euler * w
        milst = milst + mu * milst * dt + sigma * milst * w + 0.5 * sigma**2 * milst * (w**2 - dt)
    exact = S0 * np.exp((mu - 0.5 * sigma**2) * T + sigma * dW.sum(axis=1))
    return np.abs(euler - exact).mean(), np.abs(milst - exact).mean()

In a run with 4,000 paths at σ = 80%, going from 8 to 1,024 steps cut Euler’s mean error from 0.134 to 0.012 (11×) and Milstein’s from 0.018 to 0.00018 (100×).

In practice

When to bother

  • If an exact scheme exists, use it. For GBM, simulate ln⁡S\ln S with Euler: the log-price has constant coefficients, so the scheme is exact. Same for OU (exact Gaussian transition).
  • Additive noise needs no correction. If b doesn’t depend on X, then b′=0b' = 0 and Milstein is Euler.
  • Pricing European payoffs: Euler’s weak order 1 is usually fine; Richardson extrapolation (combine runs at Δt and Δt/2) removes most of the bias.
  • Square-root processes (CIR, Heston variance): Euler can go negative. Milstein helps, b b′=12σ2b\,b' = \tfrac12\sigma^2 for b=σxb = \sigma\sqrt{x}, but practitioners usually use full truncation or Andersen’s QE scheme.
  • Several Brownian motions: Milstein needs Lévy areas (iterated integrals of different Brownian motions), which are hard to simulate. That’s why it’s mostly used in one dimension or with commutative noise.

Where people slip in interviews

  • Confusing strong and weak order. Euler is order 1 for expectations, order ½ for paths.
  • Thinking more steps always fix a biased scheme quickly. With strong order ½, a 10× smaller error needs 100× the steps.
  • Simulating GBM with Euler on S. It’s unnecessary error, and S can even go negative with big steps. Simulate log S instead.
  • Forgetting the −Δt in the Milstein term. Without it the correction has a non-zero mean and biases the drift.
Practice

Try these before you open the answer

Warm-upWrite the Milstein scheme for an OU process dX = θ(μ − X)dt + σ dW.
Show answer

b=σb = \sigma is constant, so b′=0b' = 0 and Milstein is just Euler: Xn+1=Xn+θ(μ−Xn)Δt+σΔWX_{n+1} = X_n + \theta(\mu - X_n)\Delta t + \sigma\Delta W.

CIRWhat's the Milstein correction term for dX = κ(θ − X)dt + σ√X dW?
Show answer

b=σXb = \sigma\sqrt X, b′=σ/(2X)b' = \sigma/(2\sqrt X), so b b′=σ2/2b\,b' = \sigma^2/2. The term is 14σ2(ΔW2−Δt)\tfrac14\sigma^2(\Delta W^2 - \Delta t).

StepsEuler's strong error is 0.04 with 100 steps. Roughly how many steps for 0.01? With Milstein, if it's 0.004 at 100 steps, how many for 0.001?
Show answer

Euler, order ½: error × ¼ needs steps × 16, so 1,600. Milstein, order 1: error × ¼ needs steps × 4, so 400.

ItôShow that ∫ₜ^{t+h} (W_s − W_t) dW_s = ½(ΔW² − h).
Show answer

Apply Itô’s formula to Ys=(Ws−Wt)2Y_s = (W_s - W_t)^2: dY=2(Ws−Wt) dWs+dsdY = 2(W_s - W_t)\,dW_s + ds. Integrate from t to t + h: ΔW2=2∫(Ws−Wt) dWs+h\Delta W^2 = 2\int (W_s - W_t)\,dW_s + h. Rearrange.

ExactWhy is Euler on log S exact for GBM?
Show answer

dln⁡S=(μ−12σ2) dt+σ dWd\ln S = (\mu - \tfrac12\sigma^2)\,dt + \sigma\,dW has constant coefficients, so ln⁡St+h−ln⁡St=(μ−12σ2)h+σΔW\ln S_{t+h} - \ln S_t = (\mu - \tfrac12\sigma^2)h + \sigma\Delta W exactly. The Euler step is the exact transition.

The convergence numbers were measured on 4,000 simulated GBM paths with σ = 80%. The figure recomputes the error curve on 600 paths in your browser.