Unit 8, lesson 62

Finite difference PDE methods

How a pricing PDE becomes the heat equation and is solved on a spatial grid by the finite difference method, and how explicit, implicit and Crank-Nicolson schemes differ in stability and the discrete maximum principle.

  • Video 62
  • PDE, regression and Fourier methods

A desk that needs a European option value across many spot levels and dates, together with delta and gamma, can solve the pricing PDE once on a grid instead of evaluating an expectation at every point. Whether the grid numbers can be trusted depends on the step sizes. In a constructed case with volatility 0.20.2 and a log-price step of 0.10.1, the simplest scheme with a time step of 0.10.1 year keeps the smoothing of the PDE, while a step of 0.30.3 year makes the values oscillate and grow without bound. This lesson reduces the Black-Scholes equation to the heat equation, derives the explicit, implicit and Crank-Nicolson schemes, and explains the stability condition and the discrete maximum principle that separate them.

Key terms

Heat equation

Definition Assume the Black-Scholes setting with constant rr, qq and σ>0\sigma > 0, and let V(t,S)V(t, S) be the value of a European claim with payoff h(ST)h(S_T), solving

Vt+12σ2S2VSS+(r−q)SVS−rV=0\begin{aligned} &V_t + \tfrac12 \sigma^2 S^2 V_{SS} \\[0.4em] &\quad + (r - q) S V_S - rV = 0 \end{aligned}

for t<Tt < T and S>0S > 0, with V(T,S)=h(S)V(T, S) = h(S). In the remaining time τ=T−t\tau = T - t and the log price x=ln⁡Sx = \ln S, the chain rule gives SVS=VxS V_S = V_x and S2VSS=Vxx−VxS^2 V_{SS} = V_{xx} - V_x, so

Vτ=aVxx+bVx−rV,a=12σ2,b=r−q−12σ2.\begin{aligned} V_\tau &= a V_{xx} + b V_x - rV, \\[0.4em] a &= \tfrac12 \sigma^2, \\[0.4em] b &= r - q - \tfrac12 \sigma^2 . \end{aligned}

Writing V(τ,x)=e−rτu(τ,y)V(\tau, x) = e^{-r\tau} u(\tau, y) with y=x+bτy = x + b\tau gives Vτ=e−rτ(uτ+buy−ru)V_\tau = e^{-r\tau}(u_\tau + b u_y - r u), Vx=e−rτuyV_x = e^{-r\tau} u_y and Vxx=e−rτuyyV_{xx} = e^{-r\tau} u_{yy}. The discount and drift terms cancel and leave the heat equation

uτ=a uyy,u(0,y)=h(ey),u_\tau = a\, u_{yy}, \qquad u(0, y) = h(e^{y}),

which runs forward in τ\tau, starting from the payoff. With a>0a > 0 it is well posed forward in time and smooths its initial data, while running it backward would be the ill-posed backward heat problem. When h(ey)h(e^y) grows at most exponentially in yy, the solution given by Feynman-Kac is the Gaussian average u(τ,y)=E[h(ey+στ Z)]u(\tau, y) = \mathbb{E}\bigl[h(e^{y + \sigma\sqrt{\tau}\, Z})\bigr] with ZZ standard normal, since 2aτ=σ2τ2a\tau = \sigma^2 \tau. With coefficients that depend on the state this reduction is not available, and a scheme has to discretize the full operator.

In plain words Measuring time backward from maturity turns the pricing equation into one that starts from the payoff and moves forward, and the log price together with a moving coordinate absorbs the discounting and the carry. What remains is pure diffusion, which spreads the payoff out more and more as the time to maturity grows.

Example A long forward with delivery price KK has the value V=Se−qτ−Ke−rτV = S e^{-q\tau} - K e^{-r\tau}. Since r−q−b=ar - q - b = a,

u(τ,y)=erτ V(τ,y−bτ)=ey+(r−q−b)τ−K=ey+aτ−K.\begin{aligned} u(\tau, y) &= e^{r\tau}\, V(\tau, y - b\tau) \\[0.4em] &= e^{y + (r - q - b)\tau} - K \\[0.4em] &= e^{y + a\tau} - K . \end{aligned}

Then uτ=a ey+aτ=a uyyu_\tau = a\, e^{y + a\tau} = a\, u_{yy}, and u(0,y)=ey−Ku(0, y) = e^y - K is the payoff S−KS - K at S=eyS = e^y. With the constructed inputs r=0.05r = 0.05, q=0.02q = 0.02 and σ=0.2\sigma = 0.2, the coefficients are a=0.02a = 0.02 and b=0.01b = 0.01. The rates have disappeared from the heat equation itself and enter only through the coordinate yy and the factor e−rτe^{-r\tau}.

Finite difference method

Definition The finite difference method replaces derivatives by difference quotients on a grid and solves the resulting algebraic equations. A uniform spatial grid cuts the line down to an interval [ymin⁡,ymax⁡][y_{\min}, y_{\max}] with the nodes yj=ymin⁡+j Δyy_j = y_{\min} + j\,\Delta y for j=0,…,Jj = 0, \dots, J, together with the time levels τn=n Δτ\tau_n = n\,\Delta\tau, and ujnu_j^n denotes the approximation of u(τn,yj)u(\tau_n, y_j). For a function with four continuous derivatives, Taylor expansion gives

u(y−h)−2u(y)+u(y+h)h2=uyy(y)+h212 uyyyy(ξ)\begin{aligned} &\frac{u(y - h) - 2u(y) + u(y + h)}{h^2} \\[0.4em] &\quad = u_{yy}(y) + \frac{h^2}{12}\, u_{yyyy}(\xi) \end{aligned}

for some ξ\xi between y−hy - h and y+hy + h, and a one-sided difference in τ\tau has an error of order Δτ\Delta\tau. The values at y0y_0 and yJy_J come from boundary conditions that approximate the contract far from the strike. The computed answer therefore carries a domain truncation error, which shrinks as the interval widens, besides the errors in Δy\Delta y and Δτ\Delta\tau, which shrink as the grid is refined. A scheme is consistent when its difference equations approach the PDE as Δτ,Δy→0\Delta\tau, \Delta y \to 0, and stable when, over a fixed horizon, it amplifies perturbations of its data by at most a fixed factor that does not grow as the grid is refined. For a well-posed linear initial value problem, the Lax equivalence theorem, stated here without proof, says that a consistent scheme converges exactly when it is stable.

In plain words The grid turns the PDE into a large set of linear equations, one for each node and time level. Three separate errors arise, from the spacing in space, from the step in time and from cutting off the unbounded range of prices, and each one has to be controlled on its own.

Example For u=eyu = e^y and h=0.1h = 0.1, the second difference equals

2cosh⁡0.1−20.01 ey≈1.000834 ey,\begin{aligned} &\frac{2\cosh 0.1 - 2}{0.01}\, e^y \\[0.4em] &\quad \approx 1.000834\, e^y, \end{aligned}

a relative error close to h2/12≈0.00083h^2/12 \approx 0.00083. For a call with K=100K = 100, a grid in yy from ln⁡100−3\ln 100 - 3 to ln⁡100+3\ln 100 + 3 covers prices from about 4.984.98 to about 20092009 at τ=0\tau = 0. The boundary values u=0u = 0 at y0y_0 and u=eyJ+aτ−Ku = e^{y_J + a\tau} - K at yJy_J, the forward value of the previous card, differ from the exact call values there by less than 10−4010^{-40} for σ=0.2\sigma = 0.2 and τ≤1\tau \le 1.

Explicit scheme

Definition The explicit scheme, forward Euler in τ\tau, evaluates the second difference at the old level,

ujn+1−ujnΔτ=a uj−1n−2ujn+uj+1n(Δy)2.\begin{aligned} &\frac{u_j^{n+1} - u_j^n}{\Delta\tau} \\[0.4em] &\quad = a\, \frac{u_{j-1}^n - 2u_j^n + u_{j+1}^n}{(\Delta y)^2} . \end{aligned}

With the ratio λ=a Δτ/(Δy)2\lambda = a\,\Delta\tau/(\Delta y)^2 this becomes

ujn+1=λ uj−1n+(1−2λ) ujn+λ uj+1n\begin{aligned} u_j^{n+1} &= \lambda\, u_{j-1}^n + (1 - 2\lambda)\, u_j^n \\[0.4em] &\quad + \lambda\, u_{j+1}^n \end{aligned}

for 1≤j≤J−11 \le j \le J - 1, with boundary values at j=0j = 0 and j=Jj = J. Each new value comes directly from three old ones, with no linear system, and the local truncation error is of order Δτ+(Δy)2\Delta\tau + (\Delta y)^2 for smooth solutions. The stability condition of this scheme, in this heat scaling, is

λ=a Δτ(Δy)2≤12,\lambda = \frac{a\,\Delta\tau}{(\Delta y)^2} \le \frac12 ,

equivalently Δτ≤(Δy)2/σ2\Delta\tau \le (\Delta y)^2/\sigma^2. Von Neumann analysis on an infinite grid inserts the Fourier mode ujn=gneijθu_j^n = g^n e^{\mathrm{i} j\theta}, with i\mathrm{i} the imaginary unit, and finds the amplification factor

g(θ)=1−4λsin⁡2(θ/2),g(\theta) = 1 - 4\lambda \sin^2(\theta/2),

which satisfies ∣g(θ)∣≤1\lvert g(\theta) \rvert \le 1 for every θ\theta exactly when λ≤12\lambda \le \tfrac12. Above one half the alternating mode θ=π\theta = \pi, the pattern 1,−1,1,…1, -1, 1, \dots, is multiplied by 1−4λ<−11 - 4\lambda < -1 at every step and grows without bound. On a fixed bounded grid with fixed boundary values the largest stable ratio is slightly above one half, and it tends to one half as Δy→0\Delta y \to 0, so λ≤12\lambda \le \tfrac12 is the condition that works for every grid.

In plain words The explicit step replaces each value by a weighted average of itself and its two neighbors. If the time step is too large for the space step, the center weight turns negative and the scheme amplifies the finest zigzag in the data instead of smoothing it. Halving Δy\Delta y forces Δτ\Delta\tau down by a factor of four.

Example With σ=0.2\sigma = 0.2, so a=0.02a = 0.02, a space step Δy=0.1\Delta y = 0.1 and a time step Δτ=0.1\Delta\tau = 0.1 year, the ratio is λ=0.02⋅0.1/0.01=0.2\lambda = 0.02 \cdot 0.1/0.01 = 0.2. Starting from the values 0,1,00, 1, 0 with zeros beyond them, one step gives 0.2,0.6,0.20.2, 0.6, 0.2, and the alternating mode is multiplied by 1−4⋅0.2=0.21 - 4 \cdot 0.2 = 0.2 per step. With Δτ=0.3\Delta\tau = 0.3 year the ratio is λ=0.6\lambda = 0.6, the same data give the center value 1−1.2=−0.21 - 1.2 = -0.2, and the alternating mode is multiplied by 1−2.4=−1.41 - 2.4 = -1.4 per step, so after ten steps it has grown by the factor 1.410≈28.91.4^{10} \approx 28.9. For this grid the largest stable step is (0.1)2/0.04=0.25(0.1)^2/0.04 = 0.25 year, and with Δy=0.05\Delta y = 0.05 it is 0.06250.0625 year.

Discrete maximum principle

Definition A scheme satisfies the discrete maximum principle when every new interior value lies between the smallest and the largest of the values it is computed from, which are the old interior values and the boundary values used in the step. For the explicit scheme with 0≤λ≤120 \le \lambda \le \tfrac12, the weights λ\lambda, 1−2λ1 - 2\lambda and λ\lambda are nonnegative and add to 11, so each new value is a convex combination of old values and

min⁡0≤k≤Jukn≤ujn+1≤max⁡0≤k≤Jukn,\min_{0 \le k \le J} u_k^n \le u_j^{n+1} \le \max_{0 \le k \le J} u_k^n ,

where u0nu_0^n and uJnu_J^n are the boundary values. As consequences, nonnegative data stay nonnegative, data between two bounds stay between them when the boundary values do too, and with zero boundary values the largest absolute value never increases, which proves stability in the maximum norm. For λ>12\lambda > \tfrac12 the center weight is negative and the principle fails. The implicit scheme satisfies the principle for every λ>0\lambda > 0, and for Crank-Nicolson λ≤1\lambda \le 1 is a sufficient condition. The property is especially useful for comparison arguments and for American obstacle problems, whose algorithms lie beyond this lesson.

In plain words A heat flow cannot create a temperature hotter than the hottest point it started from, and a good grid scheme should not either. Option values computed by such a scheme never turn negative when the payoff and the boundary values are nonnegative, and never leave the range that those values set.

Example With λ=0.2\lambda = 0.2 the spike 0,1,00, 1, 0 becomes 0.2,0.6,0.20.2, 0.6, 0.2, inside [0,1][0, 1]. With λ=0.6\lambda = 0.6 the explicit step gives −0.2-0.2 at the center, a negative value from nonnegative data. The implicit scheme with the same λ=0.6\lambda = 0.6, on a long grid with zero values far away, gives about 0.54230.5423 at the center and 0.16090.1609 at the neighbors, all inside [0,1][0, 1], with the total still 11. Crank-Nicolson with λ=5\lambda = 5 gives about −0.397-0.397 at the center, a negative value from a scheme that is nevertheless stable.

Implicit scheme

Definition The implicit scheme, backward Euler in τ\tau, evaluates the second difference at the new level. With the discrete operator (Lhu)j=a (uj−1−2uj+uj+1)/(Δy)2(L_h u)_j = a\,(u_{j-1} - 2u_j + u_{j+1})/(\Delta y)^2 at the interior nodes it reads

(I−Δτ Lh) un+1=un,(I - \Delta\tau\, L_h)\, u^{n+1} = u^n ,

where the boundary values λu0n+1\lambda u_0^{n+1} and λuJn+1\lambda u_J^{n+1} move to the right-hand side of the first and last rows. Each interior row is

−λ uj−1n+1+(1+2λ) ujn+1−λ uj+1n+1=ujn.\begin{aligned} &-\lambda\, u_{j-1}^{n+1} + (1 + 2\lambda)\, u_j^{n+1} \\[0.4em] &\quad - \lambda\, u_{j+1}^{n+1} = u_j^n . \end{aligned}

The matrix is tridiagonal with diagonal 1+2λ1 + 2\lambda and off-diagonal entries −λ-\lambda, so it is strictly diagonally dominant with nonpositive off-diagonal entries. It is therefore an M-matrix, whose inverse has only nonnegative entries, and the system is solved in a number of operations proportional to JJ by the tridiagonal (Thomas) algorithm. The amplification factor

g(θ)=11+4λsin⁡2(θ/2)g(\theta) = \frac{1}{1 + 4\lambda \sin^2(\theta/2)}

lies in (0,1](0, 1] for every λ>0\lambda > 0, so the scheme is stable with no restriction on Δτ\Delta\tau, and it satisfies the discrete maximum principle for every λ\lambda. Its error is of order Δτ+(Δy)2\Delta\tau + (\Delta y)^2 for smooth solutions, only first order in time, so a large stable step can still be inaccurate. Unconditional stability is not unconditional accuracy.

In plain words The implicit step asks which new values, smoothed by one step of diffusion, give back the old values. That needs a linear system at every step, but a cheap one, and in return the time step is limited only by accuracy, never by stability.

Example With λ=0.6\lambda = 0.6, where the explicit scheme failed, one implicit step on a long grid turns the spike 0,1,00, 1, 0 into about 0.0478,0.1609,0.5423,0.1609,0.04780.0478, 0.1609, 0.5423, 0.1609, 0.0478 around the center, positive values below 11 that add to 11. The alternating mode is multiplied by 1/(1+2.4)≈0.2941/(1 + 2.4) \approx 0.294 per step, while the exact heat flow multiplies the same grid mode by

e−λπ2=e−0.6π2≈0.0027,e^{-\lambda \pi^2} = e^{-0.6\pi^2} \approx 0.0027,

so the implicit step damps the finest zigzag correctly in sign but far too weakly in size.

Crank-Nicolson scheme

Definition The Crank-Nicolson scheme averages the explicit and implicit spatial differences,

(I−12Δτ Lh) un+1=(I+12Δτ Lh) un,\begin{aligned} &\bigl(I - \tfrac12 \Delta\tau\, L_h\bigr)\, u^{n+1} \\[0.4em] &\quad = \bigl(I + \tfrac12 \Delta\tau\, L_h\bigr)\, u^n , \end{aligned}

with the boundary values moved to the right-hand side. Each interior row is

−12λ uj−1n+1+(1+λ) ujn+1−12λ uj+1n+1=12λ uj−1n+(1−λ) ujn+12λ uj+1n.\begin{aligned} &-\tfrac12\lambda\, u_{j-1}^{n+1} + (1 + \lambda)\, u_j^{n+1} \\[0.4em] &\quad - \tfrac12\lambda\, u_{j+1}^{n+1} \\[0.4em] &= \tfrac12\lambda\, u_{j-1}^{n} + (1 - \lambda)\, u_j^{n} \\[0.4em] &\quad + \tfrac12\lambda\, u_{j+1}^{n} . \end{aligned}

Its error is of order (Δτ)2+(Δy)2(\Delta\tau)^2 + (\Delta y)^2 for sufficiently smooth solutions. The amplification factor

g(θ)=1−2λsin⁡2(θ/2)1+2λsin⁡2(θ/2)g(\theta) = \frac{1 - 2\lambda \sin^2(\theta/2)}{1 + 2\lambda \sin^2(\theta/2)}

satisfies ∣g(θ)∣≤1\lvert g(\theta) \rvert \le 1 for every λ\lambda, so the scheme is stable in the discrete ℓ2\ell^2 norm with no restriction on Δτ\Delta\tau. Stability does not give the maximum principle. The left matrix is an M-matrix for every λ\lambda, and the right-hand weights 12λ\tfrac12\lambda, 1−λ1 - \lambda and 12λ\tfrac12\lambda are nonnegative when λ≤1\lambda \le 1, so λ≤1\lambda \le 1 is a sufficient condition for the discrete maximum principle. For large λ\lambda the alternating mode has g(π)=(1−2λ)/(1+2λ)g(\pi) = (1 - 2\lambda)/(1 + 2\lambda), close to −1-1, so it flips sign at every step and decays slowly, while the exact heat flow removes it almost at once. Near the kink of a call payoff this appears as oscillations in the value and especially in delta and gamma. A common remedy, Rannacher smoothing, takes a few implicit steps, often with half the step size, before switching to Crank-Nicolson.

In plain words Crank-Nicolson centers the time step, which makes it more accurate than either Euler step for smooth data. Its weakness is rough data with large steps, where it keeps the sign-flipping zigzag alive for many steps instead of smoothing it away.

Example With λ=5\lambda = 5 the alternating mode is multiplied by (1−10)/(1+10)=−9/11≈−0.818(1 - 10)/(1 + 10) = -9/11 \approx -0.818 per step, so after ten steps its amplitude is still about 0.1340.134 of the original. The implicit factor is 1/21≈0.0481/21 \approx 0.048 per step, and the exact factor is e−5π2≈3.7×10−22e^{-5\pi^2} \approx 3.7 \times 10^{-22}. On a long grid with zero values far away, one Crank-Nicolson step with λ=5\lambda = 5 turns the spike 0,1,00, 1, 0 into a profile with center about −0.397-0.397 and neighbors about 0.3240.324. With λ=1\lambda = 1 the center stays positive at about 0.1550.155, and with λ=2\lambda = 2 it is already negative at about −0.106-0.106.

Check yourself

  1. With σ=0.3\sigma = 0.3 and Δy=0.05\Delta y = 0.05, find the heat coefficient aa, the largest stable time step of the explicit scheme, and the ratio and the three weights for Δτ=0.02\Delta\tau = 0.02 year. How many explicit steps does one year need at least?
Show the answer

The coefficient is a=12⋅0.09=0.045a = \tfrac12 \cdot 0.09 = 0.045. Stability needs λ≤12\lambda \le \tfrac12, that is

Δτ≤(0.05)22⋅0.045=136≈0.0278\begin{aligned} \Delta\tau &\le \frac{(0.05)^2}{2 \cdot 0.045} \\[0.4em] &= \frac{1}{36} \approx 0.0278 \end{aligned}

year. For Δτ=0.02\Delta\tau = 0.02 the ratio is λ=0.045⋅0.02/0.0025=0.36\lambda = 0.045 \cdot 0.02/0.0025 = 0.36, and the weights are 0.360.36, 1−0.72=0.281 - 0.72 = 0.28 and 0.360.36, nonnegative and adding to 11, so the step is stable and satisfies the discrete maximum principle. One year needs at least 3636 steps, taken with Δτ=1/36\Delta\tau = 1/36 and λ=12\lambda = \tfrac12 exactly, where the center weight is 00. With Δτ=0.02\Delta\tau = 0.02 it takes 5050 steps.

  1. With σ=0.2\sigma = 0.2, a colleague uses Δy=0.01\Delta y = 0.01 and Δτ=0.025\Delta\tau = 0.025 year. Find λ\lambda and decide whether the explicit scheme would be stable. The colleague then switches to Crank-Nicolson and argues that, since it is unconditionally stable, its values near the strike of a call cannot oscillate. Check the claim with the amplification factor of the alternating mode and the condition for the discrete maximum principle.
Show the answer

The ratio is λ=0.02⋅0.025/0.0001=5\lambda = 0.02 \cdot 0.025/0.0001 = 5. The explicit scheme would need Δτ≤0.0001/0.04=0.0025\Delta\tau \le 0.0001/0.04 = 0.0025 year, and with λ=5\lambda = 5 its alternating mode would be multiplied by 1−20=−191 - 20 = -19 per step, so it would be unstable. For Crank-Nicolson

g(π)=1−101+10=−911≈−0.818,\begin{aligned} g(\pi) &= \frac{1 - 10}{1 + 10} = -\frac{9}{11} \\[0.4em] &\approx -0.818 , \end{aligned}

which is bounded, so the scheme is stable, but negative and close to −1-1. A zigzag flips sign at every step and after ten steps still keeps about 0.1340.134 of its size. The sufficient condition λ≤1\lambda \le 1 fails, since the center weight 1−λ=−41 - \lambda = -4 on the right-hand side is negative, and indeed one step from the spike 0,1,00, 1, 0 gives about −0.397-0.397 at the center. The kink of the call payoff contains such high-frequency components, so oscillations near the strike, most visible in gamma, are to be expected. Stability only bounds their size. A few implicit steps at the start, or smaller steps with λ≤1\lambda \le 1 there, are the usual ways to damp them.

  1. Take σ=0.2\sigma = 0.2, a call with K=100K = 100 in heat coordinates, u(0,y)=(ey−100)+u(0, y) = (e^y - 100)^{+}, and a grid with a node at y=ln⁡100y = \ln 100, Δy=0.1\Delta y = 0.1 and Δτ=0.1\Delta\tau = 0.1 year. Compute one explicit step at the strike node and compare it with the exact heat solution there. What happens when Δy\Delta y is halved repeatedly with λ\lambda fixed?
Show the answer

Here λ=0.2\lambda = 0.2. At the strike node the payoff and its left neighbor are 00, and the right neighbor is 100(e0.1−1)≈10.517100(e^{0.1} - 1) \approx 10.517, so one step gives 0.2⋅10.517≈2.10340.2 \cdot 10.517 \approx 2.1034. The exact solution is the Gaussian average of the payoff, which at the strike, with στ=0.20.1≈0.063246\sigma\sqrt{\tau} = 0.2\sqrt{0.1} \approx 0.063246 and eσ2τ/2=e0.002e^{\sigma^2\tau/2} = e^{0.002}, is

u(0.1,ln⁡100)=100 e0.002 Φ(στ)−100 Φ(0)≈2.6266.\begin{aligned} &u(0.1, \ln 100) \\[0.4em] &\quad = 100\, e^{0.002}\, \Phi(\sigma\sqrt{\tau}) \\[0.4em] &\qquad - 100\, \Phi(0) \approx 2.6266 . \end{aligned}

The error of one coarse step is about −0.523-0.523, roughly 2020 percent, because the grid is coarse compared with the spread στ≈0.063\sigma\sqrt{\tau} \approx 0.063 and the payoff has a kink at the node, where the Taylor argument behind the local error estimate does not apply. Keeping λ=0.2\lambda = 0.2, so that Δτ\Delta\tau falls by four whenever Δy\Delta y halves, gives 2.50342.5034 with Δy=0.05\Delta y = 0.05 and 44 steps, and 2.59682.5968 with Δy=0.025\Delta y = 0.025 and 1616 steps. The errors −0.523-0.523, −0.123-0.123 and −0.030-0.030 fall by about four per halving in this computation. That is an observation for this grid with the strike on a node, not a convergence theorem. Only σ\sigma enters uu, so rr and qq are not needed.

How this lesson connects