An interest rate far above its usual level tends to drift down, and one far below tends to drift up. A one-line equation for that pull, and its solution, sits inside every short-rate model of Level 5.
A differential equationAn ordinary differential equation (ODE): an equation linking an unknown function of one variable, such as x(t), to its derivatives. does not tell you where something is. It tells you how fast it is moving, given where it is. Draw that rule as a slope fieldA slope field: short line segments drawn at many points, each with the slope the ODE gives there.: at each point, a short line with the slope the equation demands. A solution is any curve that follows the lines.
Each short line has the slope a(b − x) at its point, with a = 0.5 and b = 4% (dashed). The solutions from 0%, 2%, 6% and 8% follow the lines and all close in on b.
Above b the lines point down, below b they point up, and the further from b the steeper they are. Pick a start, the initial conditionAn initial condition: the value of the unknown function at the start, x(0) = x₀. With it, a well-behaved ODE has exactly one solution., and the curve through it is fixed. Every curve here bends in towards b: this is mean reversionMean reversion: dx/dt = a(b − x) with a > 0. x is pulled towards the level b at a rate proportional to the gap..
The rules
What an ODE is.
Growth and decay. The equation whose solution is the exponential.
Mean reversion. A first-order linearA first-order linear ODE: dx/dt + p(t)x = q(t). The unknown x and its derivative appear only to the first power. equation, solved by looking at the gap, with a half-lifeThe half-life of a mean-reverting gap: the time ln 2 / a in which half the distance to b closes..
A first look at a Riccati equation. Add a squared term.
Euler's method. When no formula is at hand, follow the slope one small step at a time.
The formal version
dtdx=f(x,t),x(0)=x0(a unique solution near t=0 if f and ∂f/∂x are continuous)dtdx=kx⇒x(t)=x0ektdtdx+px=q⇒x(t)=pq+(x0−pq)e−pt;dtdx=a(b−x)⇒x(t)=b+(x0−b)e−atdtdy=q0+q1y+q2y2(Riccati);B′=1−κB−21σ2B2,B(0)=0⇒B(τ)=(γ+κ)(eγτ−1)+2γ2(eγτ−1),γ=κ2+2σ2xk+1=xk+hf(xk,tk),tk=kh;∣xn−x(T)∣≤Ch for T=nh
x is the unknown function of time t, x₀ its starting value; k, p, q, a, b, κ and σ are constants, with a, p and κ positive; τ is the variable of the Riccati example (in Level 5, time to maturity); h is the Euler step and C a constant that depends on f and T but not on h. Sources: Boyce, DiPrima and Meade (2017); Press et al. (2007), chapter 17.
Try it
A rate starts at 2% and is pulled towards 4%. Change the pull and the level, then make Euler's step bigger. At h = 1 the dots lag the curve; at h = 2 with a = 0.5 the first step lands exactly on b; push a up to 1.5 with h = 2 and the dots zigzag; above a·h = 2 they fly off.
Try itPulled back to its level
Euler step h (years)
exact solution b + (x₀ − b)e^(−at) Euler's method, step h
The dashed line is b; the dotted line marks the half-life.
Half-life ln 2 / a1.386 years
Exact x(1)2.79%
Exact x(10)3.99%
Euler x(10), 10 steps4%
Largest Euler error on the grid0.2358 points
Each Euler step multiplies the gap to b by 1 − a·h = 0.5.
Between 0 and 1: the gap shrinks every step, like the true solution, but at the wrong rate. A smaller step fixes the rate.
Worked examples
1. Decay, exactly and with Euler
Step 1 of 4
1
The equation
dx/dt = −0.5x with x(0) = 100. The solution is x(t) = 100e−0.5t, so x(2) = 100e−1 = 36.7879.
2. A rate pulled back to its long-run level
Step 1 of 4
1
The set-up
A rate x (in per cent) starts at 2% and follows dx/dt = 0.5(4 − x). At the start it rises at 1 point a year: half the 2-point gap.
3. A Riccati equation, checked numerically
Step 1 of 4
1
The equation
B′(τ) = 1 − 0.5B − 0.18B² with B(0) = 0: the Riccati equation of the rules with κ = 0.5 and σ = 0.6, so ½σ² = 0.18 and γ = √(0.25 + 0.72) = 0.9849.
Press et al., Numerical Recipes (3rd edition, 2007), chapter 17: Runge-Kutta methods, which beat Euler's first-order error. Advanced.
Origins
William E. Boyce, Richard C. DiPrima and Douglas B. Meade, Elementary Differential Equations and Boundary Value Problems, 11th edition, Wiley, 2017 (first-order equations and Euler's method).
William H. Press, Saul A. Teukolsky, William T. Vetterling and Brian P. Flannery, Numerical Recipes: The Art of Scientific Computing, 3rd edition, Cambridge University Press, 2007 (chapter 17, integration of ordinary differential equations).