Hexa Scholar

Simulating an SDE with Euler–Maruyama

A gold bead beside a row of pale wooden markers on a dark navy board.
The wooden markers stand for the times when you record the bead’s position.

The question

If you double the number of steps along the same Brownian path, how much does the simulation error change?

  1. 1 SeePredict how much the error changes.
  2. 2 TryChange the grid on one path.
  3. 3 ProveBuild an exact error formula.
  4. 4 ApplySolve step and error problems.
Before you start · 3 quick checks on slopes, standard deviation and absolute distance, about 3 min

Two ideas before you start

2 ideas

Start each step at the current value

A straight segment shows how far a fixed slope moves the state during one time step.

For the drift alone, multiply the slope at the start by the time step. The segment shows the move that this frozen slope gives.

Exact definition

A scalar Itô stochastic differential equation (SDE) has the form \(dX_t=a(X_t)\,dt+b(X_t)\,dW_t\) here. The state is \(X_t\), \(W_t\) is standard Brownian motion, and the functions \(a\) and \(b\) give the drift and the diffusion coefficient. The notation describes a time integral of the drift and an Itô integral of the diffusion coefficient against \(W\).

Divide a fixed duration \(T\gt0\) into \(N\) equal steps of length \(h=T/N\), with \(t_n=nh\). Let \(Y_n\) approximate \(X_{t_n}\), starting at \(Y_0=X_0\). Euler–Maruyama evaluates both coefficients at \(Y_n\):

\[\begin{aligned} Y_{n+1} &= Y_n+a(Y_n)h\\ &\quad +b(Y_n)\Delta W_n . \end{aligned}\]

Here \(\Delta W_n=W_{t_{n+1}}-W_{t_n}\). When \(b\) is identically zero, the update reduces to forward Euler.

The noise can move either way

The endpoint moves below or above the start as the chosen noise increment changes sign.

This example holds the diffusion coefficient positive and sets the drift to zero. Change the sign of the Brownian increment and watch the endpoint.

Exact definition

Over an interval of length \(h\), a standard Brownian motion has a normal increment with mean zero and variance \(h\). Increments over disjoint intervals are independent. You can simulate one as \(\Delta W_n=\sqrt h\,Z_n\) using a standard normal draw \(Z_n\), which has variance one.

The increment \(b(Y_n)\Delta W_n\), given the state and the past, has variance \(b(Y_n)^2 h\). Its standard deviation is \(|b(Y_n)|\sqrt h\). The two figure choices are example increments, not the two possible outcomes of a normal draw.

Fine print on solutions and simulated paths

For this time-independent scalar equation, globally Lipschitz drift and diffusion with at most linear growth and a fixed finite starting value ensure a strong solution on every finite interval, unique up to indistinguishability. A strong solution is built on the given probability space with the given Brownian motion and uses no future increments. A weak solution allows the probability space and driving Brownian motion to be chosen as part of the solution. These uses of “strong” and “weak” concern what it means to solve the equation.

Without the conditions, consider two deterministic SDEs (diffusion zero). On the nonnegative state space, \(dX=\sqrt X\,dt\) from zero has both \(X_t=0\) and \(X_t=t^2/4\) for \(t\ge0\), as direct differentiation shows. The slope \(\sqrt x\) is not Lipschitz at zero. For \(dX=X^2\,dt\) starting at \(x_0\gt0\), the exact solution \(x_0/(1-x_0t)\) grows without bound as \(t\) approaches \(1/x_0\) from below. The explicit formulas establish the two behaviors. A simulated path that grows rapidly cannot by itself establish explosion or nonuniqueness.

At a fixed step size with fresh independent increments, \(Y_n\) is a time-homogeneous Markov chain on the real line. The distribution of its next state, given its history, depends on its current state alone. The Markov chains lesson illustrates this property on a finite state space.

1 See

Halve the time step

2 Try

One update, then a whole path

3 Prove

An exact squared-error formula

Theorem

Assume \(dX_t=\sigma X_t\,dW_t\) for a constant \(\sigma\gt0\), a deterministic \(X_0=x_0\gt0\), standard Brownian motion and fixed \(T\gt0\). Use \(N\ge1\) equal steps of size \(h=T/N\) and drive the exact and numerical paths with the same increments. Set \(k=\sigma^2 h\gt0\). Then

\[\begin{aligned} &\mathbb E[(Y_N-X_T)^2]\\ &=x_0^2\big[e^{Nk}-(1+k)^N\big]. \end{aligned}\]

Applying Itô’s lemma to the exponential shows that \(X_t=x_0\exp(\sigma W_t-\sigma^2t/2)\) solves the equation. The diffusion coefficient is linear in \(X\), so the existence and uniqueness conditions from Start apply. The proof multiplies one-step factors, using independence across intervals and sharing the increment within each pair.

Write \(A=1+U\) and \(B=\exp(U-k/2)\) for the Euler and exact factors on one step, where \(U=\sigma\Delta W\) is normal with mean zero and variance \(k\). The corresponding factors on interval \(j\) are \(A_j,B_j\). Completing the square in the normal density gives \(\mathbb E[e^{sU}]=e^{ks^2/2}\) for real \(s\), and \(\mathbb E[Ue^{sU}]=ks e^{ks^2/2}\) by differentiating. An exponential times a polynomial is integrable against the normal density for all real \(s\), so the derivative may pass inside the expectation.

4 Apply

Problems

Use the step rule or the paired error formula. Each problem has hints and a full solution.

Key point For a simulated update, multiply each coefficient by its own increment. For a paired accuracy check, hold the driving Brownian motion fixed and state which error statistic you are measuring.
Level Intermediate Prerequisites Euler’s method, Brownian increments and Itô’s lemma Time ~30 min

Further reading