Chapter 26
25 min read
Section 226 of 353

Applications: Financial Mathematics

The Heat Equation

Learning Objectives

By the end of this section, you will be able to:

  1. Explain how stock prices are modeled using geometric Brownian motion and its connection to diffusion
  2. Derive the Black-Scholes PDE from no-arbitrage arguments and recognize its structure
  3. Transform the Black-Scholes equation into the standard heat equation through variable substitutions
  4. Interpret the Greeks (Delta, Gamma, Theta, Vega) as partial derivatives analogous to heat equation terms
  5. Visualize option price evolution as a diffusion process converging to the payoff at expiration
  6. Connect the heat kernel solution to the Black-Scholes formula involving normal distributions
  7. Apply these concepts to understand risk management and modern quantitative finance

The Big Picture: Heat Equation Meets Wall Street

"The most important equation in finance is actually the heat equation in disguise."

One of the most remarkable applications of the heat equation is in financial mathematics. The famous Black-Scholes equation for pricing stock options is mathematically equivalent to the heat equation! This discovery earned Myron Scholes and Robert Merton the 1997 Nobel Prize in Economics.

The connection is profound: just as heat diffuses from hot to cold regions, financial uncertainty diffuses through time. The mathematics of thermal equilibrium directly translates to the fair pricing of financial derivatives.

Heat Equation World

  • Temperature u(x, t)
  • Thermal diffusivity α
  • Spatial curvature ∂²u/∂x²
  • Heat flows to equilibrium
  • Initial temperature distribution

Financial World

  • Option price V(S, t)
  • Volatility σ² / 2
  • Gamma: ∂²V/∂S²
  • Prices converge to fair value
  • Payoff at expiration

Historical Context: The Black-Scholes Revolution

The story of options pricing involves some of the greatest minds in mathematics, physics, and economics:

Louis Bachelier (1900)

A French mathematician who first applied Brownian motion to stock prices in his PhD thesis, five years before Einstein's famous work on diffusion! He derived an early version of options pricing but was largely ignored.

Fischer Black & Myron Scholes (1973)

Derived the Black-Scholes PDE using no-arbitrage arguments. They showed that option prices must satisfy a specific partial differential equation to prevent risk-free profits.

Robert C. Merton (1973)

Independently derived the same equation using stochastic calculus. Merton recognized that the Black-Scholes PDE transforms into the heat equation, allowing for analytical solutions.

Nobel Prize (1997)

Scholes and Merton received the Nobel Prize in Economics. Black had passed away in 1995, but the prize committee explicitly acknowledged his fundamental contributions.


The Stock Price Model: Geometric Brownian Motion

Before we can price options, we need a model for how stock prices evolve. The standard model is Geometric Brownian Motion (GBM), which assumes stock prices follow a random walk with drift:

Geometric Brownian Motion

dS=μSdt+σSdWdS = \mu S \, dt + \sigma S \, dW
Stock price change = Drift + Random fluctuation
TermSymbolMeaning
Stock priceSCurrent price of the underlying asset
DriftμExpected return rate (e.g., 8% per year)
VolatilityσStandard deviation of returns (e.g., 20%)
Brownian incrementdWRandom normal shock with variance dt
Geometric Brownian Motion: The Stock Price Model

Stock prices are modeled by Geometric Brownian Motion (GBM). The probability distribution of future prices satisfies the heat equation!

Time (years)Stock Price S0.00.51.0$45$133$220
Sample Mean
$100.00
Expected Value E[St]
$100.00
Paths Simulated
10

The Geometric Brownian Motion SDE

dS = μS dt + σS dW

The probability density p(S, t) of the stock price satisfies a Fokker-Planck equation, which is a generalized heat equation! Under risk-neutral pricing (μ → r), this connects directly to the Black-Scholes PDE.

Why GBM Connects to the Heat Equation

The probability density p(S, t) of the stock price satisfies a Fokker-Planck equation, which is a generalized heat equation:

pt=S(μSp)+122S2(σ2S2p)\frac{\partial p}{\partial t} = -\frac{\partial}{\partial S}(\mu S p) + \frac{1}{2}\frac{\partial^2}{\partial S^2}(\sigma^2 S^2 p)

This is essentially a heat equation with variable coefficients! The volatility σ2/2\sigma^2/2 plays the role of the thermal diffusivity, determining how fast the probability distribution spreads.


The Black-Scholes PDE

The Black-Scholes equation describes how the price V of an option depends on the stock price S and time t remaining to expiration:

The Black-Scholes PDE

Vt+12σ2S22VS2+rSVSrV=0\frac{\partial V}{\partial t} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} + rS\frac{\partial V}{\partial S} - rV = 0
Compare to heat equation: ut=α2ux2\frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2}

Understanding Each Term

TermNameMeaningHeat Equation Analogy
∂V/∂tTime decayHow option value changes with timeRate of temperature change
(1/2)σ²S²∂²V/∂S²DiffusionEffect of stock price curvatureThe Laplacian term driving diffusion
rS∂V/∂SConvectionDrift due to risk-free rateLike advection in heat transport
-rVDiscountingTime value of moneyLike a reaction/sink term

The No-Arbitrage Principle

The Black-Scholes PDE is derived from the principle that there should be no risk-free profit opportunities (no arbitrage). By constructing a portfolio of the option and stock that is risk-free, we can derive this equation. The amazing result is that the option price doesn't depend on the expected return μ, only on the volatility σ!


Transformation to the Heat Equation

The Black-Scholes PDE looks complicated, but through a clever sequence of variable changes, it transforms exactly into the standard heat equation! Follow the interactive demonstration below:

Transforming Black-Scholes to the Heat Equation

Step 1: Black-Scholes PDE

The original Black-Scholes equation for option price V as a function of stock price S and time t.

Vt+12σ2S22VS2+rSVSrV=0\frac{\partial V}{\partial t} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} + rS\frac{\partial V}{\partial S} - rV = 0
Variables: V(S, t): option price, S: stock price, t: time to expiry, r: risk-free rate, σ: volatility

The Complete Transformation

The transformation involves three main steps:

  1. Change to log-price: x=ln(S/K)x = \ln(S/K) removes the S2S^2 coefficient from the second derivative
  2. Reverse and scale time: τ=σ22(Tt)\tau = \frac{\sigma^2}{2}(T - t) so that expiration corresponds to τ=0\tau = 0
  3. Exponential substitution: u=eαx+βτVu = e^{\alpha x + \beta \tau}V eliminates first-derivative and reaction terms

After these substitutions with α=(k1)/2\alpha = -(k-1)/2 and β=(k+1)2/4\beta = -(k+1)^2/4 where k=2r/σ2k = 2r/\sigma^2, we get:

The Transformed Equation

uτ=2ux2\frac{\partial u}{\partial \tau} = \frac{\partial^2 u}{\partial x^2}
This is exactly the heat equation with diffusivity α=1\alpha = 1!

Why This Matters

This transformation means that all our heat equation knowledge applies directly to option pricing:

  • The heat kernel gives explicit formulas (Black-Scholes formula)
  • Maximum principles bound option prices
  • Numerical methods from heat equation work for options
  • Fourier analysis applies to exotic option pricing

The Greeks: Derivatives of Option Price

In finance, the partial derivatives of the option price are called "the Greeks" because they're traditionally denoted by Greek letters. These are directly analogous to the derivatives appearing in the heat equation:

The Greeks: Derivatives of Option Price

The Greeks are partial derivatives of the option price, directly analogous to derivatives in the heat equation. They tell us how sensitive the option price is to various factors.

ΔDelta
Δ=VS=N(d1)\Delta = \frac{\partial V}{\partial S} = N(d_1)

Rate of change of option price with respect to stock price

Heat Equation Analogy: Like ∂u/∂x in heat equation - the spatial gradient
K=$1000.5977$60$80$100$120$140Stock Price S-0.0990.4981.095Delta (Δ)

The Black-Scholes PDE in Terms of Greeks

Θ+12σ2S2Γ+rSΔrV=0\Theta + \frac{1}{2}\sigma^2 S^2 \Gamma + rS\Delta - rV = 0

This is identical to the heat equation in transformed coordinates! The Gamma term (∂²V/∂S²) corresponds to the Laplacian in the heat equation, driving the diffusion of option value.

The Black-Scholes PDE in Terms of Greeks

We can rewrite the Black-Scholes PDE using Greek notation:

Θ+12σ2S2Γ+rSΔrV=0\Theta + \frac{1}{2}\sigma^2 S^2 \Gamma + rS\Delta - rV = 0

This reveals the fundamental balance in option pricing:

  • Theta (Θ): Time decay — options lose value as expiration approaches
  • Gamma (Γ): Convexity benefit — options gain value from stock price volatility
  • Delta (Δ) and V terms: Interest rate effects from holding the position

Hedging with Greeks

Traders use the Greeks to hedge their positions. For example, to create a "delta-neutral" portfolio that doesn't change with small stock movements, you would hold Δ-\Delta shares per option. This is analogous to insulating against temperature changes!


Option Pricing as Heat Diffusion

The most intuitive way to understand Black-Scholes is through the lens of heat diffusion. Watch how option prices "diffuse" toward their payoff as expiration approaches:

Option Price Evolution

Watch how option prices "diffuse" toward the intrinsic value (payoff) as expiration approaches. This mirrors heat diffusing toward equilibrium!

K=$100$50$75$100$125$150Stock Price S$0$15$30$45$60Option Price V
t = 100% of T
t = 75% of T
t = 50% of T
t = 25% of T
t = 1% of T (near expiry)
Intrinsic Value (Payoff)

The Diffusion Analogy

Notice how the option price curve "diffuses" toward the payoff (intrinsic value) as time to expiry decreases. The "time value" of the option (the gap between the curve and the payoff) spreads out and eventually vanishes at expiration. This is exactly like heat diffusing toward equilibrium!

The Payoff as Initial Condition

In the transformed coordinates (where time runs backward), the option payoff at expiration serves as the initial condition for the heat equation:

Call Option Payoff

Payoff=max(SK,0)\text{Payoff} = \max(S - K, 0)

A "hockey stick" shape: zero below strike, linear above

Put Option Payoff

Payoff=max(KS,0)\text{Payoff} = \max(K - S, 0)

Reversed hockey stick: linear below strike, zero above

Just as heat diffuses a sharp temperature boundary into a smooth gradient, the diffusion process smooths the option payoff into a continuous price surface. The "time value" of an option is exactly this smoothing effect!

The Black-Scholes Formula

Solving the heat equation with the call option payoff as initial condition gives the famous Black-Scholes formula:

Black-Scholes Call Price Formula

C=SN(d1)KerTN(d2)C = S \cdot N(d_1) - Ke^{-rT} \cdot N(d_2)
where d1,2=ln(S/K)+(r±σ2/2)TσTd_{1,2} = \frac{\ln(S/K) + (r \pm \sigma^2/2)T}{\sigma\sqrt{T}}
N(·) is the standard normal CDF — the integral of the heat kernel!

The Normal Distribution Connection

The appearance of N(d₁) and N(d₂) is not coincidental! The normal CDF is the integral of the Gaussian heat kernel. The Black-Scholes formula is literally the convolution of the payoff with the heat kernel, evaluated using the error function (cumulative normal).


Machine Learning Connections

The connection between heat equations and finance extends into modern machine learning:

1. Neural Network-Based Option Pricing

Physics-informed neural networks (PINNs) can learn to solve the Black-Scholes PDE directly. The loss function includes:

  • PDE residual: how well the network satisfies Black-Scholes
  • Boundary conditions: matching known payoffs at expiration
  • Market data: fitting to observed option prices

2. Stochastic Volatility Models

Real markets show that volatility σ itself varies randomly. Models like Heston use coupled SDEs:

dS = μS dt + √v S dW₁, dv = κ(θ - v) dt + ξ√v dW₂

These lead to more complex PDEs that are still related to heat equations, solved using finite difference methods or Monte Carlo simulation.

3. Reinforcement Learning for Trading

The hedging problem (maintaining a delta-neutral portfolio) can be framed as a reinforcement learning task. The agent learns an optimal hedging policy by simulating paths from the GBM model.

4. Deep Hedging

Recent approaches train neural networks to hedge complex derivatives directly from market data, bypassing explicit PDE solving. However, understanding the underlying heat equation structure helps design better architectures and loss functions.


Python Implementation

Let's implement Black-Scholes pricing and verify the heat equation connection:

Black-Scholes as Heat Equation
🐍black_scholes_heat.py
3The Black-Scholes Formula

This famous formula gives the price of a European call option. It was derived by transforming the problem into a heat equation and solving it analytically!

19d1 and d2 Parameters

These parameters arise from the heat kernel convolution. d1 appears in the stock price term (delta), and d2 appears in the discounted strike term.

24Normal CDF = Integrated Heat Kernel

N(d) is the integral of the Gaussian (heat kernel). The Black-Scholes solution is a convolution of the payoff with the heat kernel, which produces these normal CDFs.

35The Greeks as Partial Derivatives

Each Greek is a partial derivative of the option price, directly analogous to derivatives appearing in the heat equation.

42Gamma Drives Diffusion

Gamma (∂²V/∂S²) is the key term that appears in the Black-Scholes PDE. It corresponds to the Laplacian in the heat equation and drives the diffusion of option value.

59Numerical Heat Equation Solver

This function prices the option by directly solving the heat equation numerically, demonstrating that Black-Scholes IS the heat equation in transformed coordinates.

78Initial Condition = Payoff

The transformed payoff function serves as the initial condition for the heat equation. The diffusion process smooths this toward the final option price.

100Black-Scholes PDE Verification

We verify that the Greeks satisfy the Black-Scholes PDE: Θ + (1/2)σ²S²Γ + rSΔ - rV = 0. This is the heat equation in disguise!

127 lines without explanation
1import numpy as np
2from scipy.stats import norm
3import matplotlib.pyplot as plt
4
5def black_scholes_call(S, K, T, r, sigma):
6    """
7    Black-Scholes formula for European call option.
8
9    This formula is the solution to the heat equation
10    with transformed coordinates and boundary conditions
11    matching the call option payoff.
12
13    Parameters:
14    - S: Current stock price
15    - K: Strike price
16    - T: Time to maturity (years)
17    - r: Risk-free interest rate
18    - sigma: Volatility (standard deviation of returns)
19    """
20    if T <= 0:
21        return max(S - K, 0)  # Intrinsic value at expiry
22
23    # d1 and d2 arise from the heat kernel convolution!
24    d1 = (np.log(S/K) + (r + sigma**2/2)*T) / (sigma*np.sqrt(T))
25    d2 = d1 - sigma*np.sqrt(T)
26
27    # N(d1) and N(d2) are cumulative normal distributions
28    # These come from integrating the heat kernel (Gaussian)
29    call_price = S * norm.cdf(d1) - K * np.exp(-r*T) * norm.cdf(d2)
30
31    return call_price
32
33
34def black_scholes_greeks(S, K, T, r, sigma):
35    """
36    Calculate the Greeks - partial derivatives of option price.
37
38    These correspond to derivatives in the heat equation!
39    """
40    d1 = (np.log(S/K) + (r + sigma**2/2)*T) / (sigma*np.sqrt(T))
41    d2 = d1 - sigma*np.sqrt(T)
42
43    # Delta = dV/dS (like du/dx in heat equation)
44    delta = norm.cdf(d1)
45
46    # Gamma = d2V/dS2 (like d2u/dx2 - the diffusion driver!)
47    gamma = norm.pdf(d1) / (S * sigma * np.sqrt(T))
48
49    # Theta = dV/dt (like du/dt in heat equation)
50    theta = (-S * norm.pdf(d1) * sigma / (2*np.sqrt(T))
51             - r * K * np.exp(-r*T) * norm.cdf(d2))
52
53    # Vega = dV/dsigma (sensitivity to diffusivity!)
54    vega = S * norm.pdf(d1) * np.sqrt(T)
55
56    return {'delta': delta, 'gamma': gamma,
57            'theta': theta/365, 'vega': vega/100}
58
59
60def heat_equation_pricing(S, K, T, r, sigma, n_steps=100):
61    """
62    Price option by solving heat equation numerically.
63
64    This demonstrates that Black-Scholes IS the heat equation!
65    We transform to heat equation coordinates, solve,
66    then transform back.
67    """
68    # Transform parameters
69    k = 2*r / sigma**2  # Dimensionless interest rate
70
71    # Set up spatial grid in log-price space
72    x_min, x_max = -3, 3  # Covers ~3 std deviations
73    n_x = 200
74    x = np.linspace(x_min, x_max, n_x)
75    dx = x[1] - x[0]
76
77    # Time grid in transformed time
78    tau_max = sigma**2 * T / 2
79    dt = tau_max / n_steps
80
81    # Stability condition for explicit scheme
82    alpha = dt / dx**2
83    if alpha > 0.5:
84        raise ValueError("Time step too large for stability")
85
86    # Initial condition: transformed payoff at tau=0
87    # For call: payoff is max(S-K, 0) = max(e^x - 1, 0) * K
88    u = np.maximum(np.exp(x * (k+1)/2) - np.exp(x * (k-1)/2), 0)
89
90    # Solve heat equation: du/dtau = d2u/dx2
91    for _ in range(n_steps):
92        u_new = u.copy()
93        for i in range(1, n_x-1):
94            # Central difference for d2u/dx2
95            laplacian = (u[i+1] - 2*u[i] + u[i-1]) / dx**2
96            u_new[i] = u[i] + dt * laplacian
97        u = u_new
98
99    # Transform back to get option price
100    # V = K * e^(-alpha*x - beta*tau) * u
101    alpha_transform = -(k-1)/2
102    beta_transform = -(k+1)**2/4
103
104    x_S = np.log(S/K)  # Log-moneyness
105    idx = np.argmin(np.abs(x - x_S))
106
107    V = K * np.exp(-alpha_transform * x[idx] - beta_transform * tau_max) * u[idx]
108
109    return V
110
111
112# Example: Compare analytical and numerical solutions
113S, K, T, r, sigma = 100, 100, 0.5, 0.05, 0.2
114
115# Analytical Black-Scholes
116bs_price = black_scholes_call(S, K, T, r, sigma)
117print("Black-Scholes (analytical): $" + str(round(bs_price, 4)))
118
119# Heat equation (numerical)
120heat_price = heat_equation_pricing(S, K, T, r, sigma)
121print("Heat equation (numerical): $" + str(round(heat_price, 4)))
122
123# The Greeks
124greeks = black_scholes_greeks(S, K, T, r, sigma)
125print("\nThe Greeks (at S=K=" + str(K) + "):")
126print("  Delta (dV/dS):    " + str(round(greeks['delta'], 4)))
127print("  Gamma (d2V/dS2):  " + str(round(greeks['gamma'], 4)))
128print("  Theta (dV/dt):    " + str(round(greeks['theta'], 4)) + " per day")
129print("  Vega (dV/dsigma): " + str(round(greeks['vega'], 4)) + " per 1% vol")
130
131# Verify the Black-Scholes PDE: Theta + (1/2)*sigma^2*S^2*Gamma + r*S*Delta - r*V = 0
132V = bs_price
133pde_lhs = (greeks['theta']*365 + 0.5*sigma**2*S**2*greeks['gamma']
134           + r*S*greeks['delta'] - r*V)
135print("\nBlack-Scholes PDE check: " + str(round(pde_lhs, 6)) + " (approx 0)")

Common Pitfalls

Time Runs Backward!

In the transformed coordinates, time runs from expiration (τ = 0) backward to the present. The payoff is the initial condition, not the final condition. This is crucial for understanding why option prices converge to their payoff.

The Drift Disappears

A remarkable feature of Black-Scholes: the expected return μ doesn't appear in the formula! Under risk-neutral pricing, we replace μ with the risk-free rate r. This is called the "risk-neutral measure" and is essential for no-arbitrage pricing.

Model Limitations

The Black-Scholes model assumes:

  • Constant volatility (markets show volatility smile/skew)
  • Log-normal returns (markets have fat tails)
  • Continuous trading (gaps and jumps occur)
  • No transaction costs (real trading has costs)

Despite these limitations, Black-Scholes remains the foundation for more sophisticated models.

American Options

The Black-Scholes formula applies to European options (exercise only at expiration). American options (can exercise early) lead to a free-boundary problem that's more difficult to solve analytically.


Test Your Understanding

Test Your UnderstandingQuestion 1 of 6

What transformation converts the Black-Scholes PDE into the standard heat equation?


Summary

We've discovered that the Black-Scholes equation for option pricing is the heat equation in disguise. This profound connection brings all our heat equation knowledge to bear on financial mathematics.

Key Equations

NameFormulaHeat Equation Connection
Black-Scholes PDE∂V/∂t + (1/2)σ²S²∂²V/∂S² + rS∂V/∂S - rV = 0Transforms to heat equation
Geometric Brownian MotiondS = μS dt + σS dWFokker-Planck is generalized heat eq.
Call Price FormulaC = SN(d₁) - Ke^(-rT)N(d₂)Heat kernel convolution solution
Greeks PDE FormΘ + (1/2)σ²S²Γ + rSΔ - rV = 0Derivatives balance equation

Key Takeaways

  1. The Black-Scholes equation transforms exactly into the heat equation through logarithmic price, time reversal, and exponential substitutions
  2. Volatility σ²/2 plays the role of thermal diffusivity, controlling how fast option prices "diffuse"
  3. The Greeks are partial derivatives analogous to those in the heat equation: Gamma is the Laplacian driving diffusion
  4. Option prices diffuse backward in time from the payoff at expiration toward the current price
  5. The Black-Scholes formula uses the normal CDF because it's the integral of the heat kernel (Gaussian)
  6. This connection enables using heat equation techniques for option pricing: finite differences, Fourier methods, and more
  7. Modern quantitative finance and ML build on this foundation for more complex models and hedging strategies
The Heat Equation in Finance:
"Option prices diffuse through time just as heat diffuses through space. The mathematics of thermal equilibrium is the mathematics of fair pricing."
Chapter Complete: You've now seen the heat equation's applications in thermal analysis, biological diffusion, and financial mathematics. This remarkable equation appears wherever quantities spread from high to low concentration — making it one of the most universal models in applied mathematics!
Loading comments...