Financial Mathematics · Lecture 5 of 12

Differential Equations: From Compounding to the Heat Equation

How quantities evolve: ordinary differential equations, how to solve them by hand and by computer, and a first look at the partial differential equation Black–Scholes turns into.

November 15, 2026By Diganta Bhattacharya5 min read

Ordinary differential equations

An ODE relates a function to its own rate of change. The money-market account grows in proportion to its size:

$$\frac{dB}{dt}=rB,\qquad B(0)=B_0.$$

Separation of variables: $\frac{dB}{B}=r\,dt\Rightarrow \ln B=rt+c\Rightarrow B(t)=B_0e^{rt}$. That's continuous compounding again, now as the solution of an equation.

A second classic is mean reversion (it reappears as the Vasicek and Ornstein–Uhlenbeck models):

$$\frac{dx}{dt}=\kappa(\theta-x)\;\Rightarrow\;x(t)=\theta+(x_0-\theta)e^{-\kappa t}.$$

The gap to the long-run level θ decays exponentially at speed κ, with half-life $\ln 2/\kappa$.

Numerical solution: Euler's method

Most equations have no closed form. Euler's method replaces $dt$ by a small step $h$:

$$B_{k+1}=B_k+rB_k\,h=B_k(1+rh)\quad\Rightarrow\quad B_n=B_0(1+rh)^{n}.$$

With $h=T/n$ this is exactly discrete compounding, and it converges to $e^{rT}$ as $n\to\infty$. The error is proportional to $h$.

Keep Euler in mind: the stochastic version (Euler–Maruyama, Lecture 7) is how we'll simulate stock prices, and it's the engine behind most Monte Carlo pricers.

Linear ODEs and integrating factors

For $\frac{dy}{dt}+a(t)y=b(t)$, multiply by $e^{\int a}$:

$$\frac{d}{dt}\Big(y\,e^{\int_0^t a}\Big)=b(t)\,e^{\int_0^t a}.$$

The same trick, "multiply by an exponential to make the left side a total derivative", solves the Ornstein–Uhlenbeck SDE and underlies discounting $e^{-rt}V$.

Partial differential equations

When a quantity depends on two variables, say time and position, its evolution is a PDE. The most important one for us is the heat (diffusion) equation:

$$\frac{\partial u}{\partial \tau}=\frac12\frac{\partial^2u}{\partial x^2}.$$

Think of $u(\tau,x)$ as temperature along a rod. Heat flows from hot to cold, smoothing out bumps, and the curvature $u_{xx}$ drives the change. Its fundamental solution is a Gaussian that spreads like $\sqrt{\tau}$:

$$u(\tau,x)=\int \frac{1}{\sqrt{2\pi\tau}}e^{-\frac{(x-y)^2}{2\tau}}\,u_0(y)\,dy.$$
PreviewThe heat equation smooths an initial profile by averaging it against a normal density. In Lecture 11 the Black–Scholes PDE, after a change of variables, becomes this heat equation. The initial profile is the option's payoff, and the Gaussian average is the expectation from Lecture 2. Diffusion of heat and diffusion of prices are the same mathematics.

Boundary and terminal conditions

A PDE needs side conditions. For options we know the value at expiry (the payoff) and solve backwards in time to today. That's why we'll write time-to-expiry τ = T − t, which turns a backward problem into a standard forward heat equation.

Key takeaways

Exercises

  1. Solve dx/dt = 2(5 − x), x(0) = 1. When is x within 1% of 5?
  2. Use Euler with h = 0.5 on dB/dt = 0.1B from t = 0 to 2. Compare with e^{0.2}.
  3. Verify that u(τ,x) = (2πτ)^{−1/2} e^{−x²/(2τ)} satisfies the heat equation.