SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 6.3.1 What a partial differential equation isConcept · 30 min
      2. 6.3.2 Initial, boundary and terminal conditionsConcept · 30 min
      3. 6.3.3 Practice set: partial differential equationsPractice set · 20 min
      4. 6.3.4 Case study: an option value fixed by its payoffCase study · 35 min

Level 6, Differential equations 6.3 PDE basics Lesson 1 of 4

ConceptLesson 6.3.1 in Level 6, Differential equations. About 30 minutes.

What a partial differential equation is

From one variable to two

Lesson 6.1.1 met ordinary differential equations (ODEs): an unknown function of one variable, y(t)y(t), and an equation linking it to its derivatives. For example, dydt=−2y\frac{dy}{dt} = -2y has the solutions y=Ce−2ty = Ce^{-2t}, one for each number CC.

A partial differential equation (PDE) does the same for a function of two or more variables. The unknown is a function such as u(x,t)u(x, t), where xx is a position and tt a time. The equation links uu to its partial derivatives, written as in lesson 4.1.2: ut=∂u∂tu_t = \frac{\partial u}{\partial t}, ux=∂u∂xu_x = \frac{\partial u}{\partial x} and uxx=∂2u∂x2u_{xx} = \frac{\partial^2 u}{\partial x^2}.

A solution is a function whose partial derivatives make the equation true at every point of a region of the (x,t)(x, t) plane. The order of the equation is the order of its highest partial derivative, in any of the variables.

Rule: Three partial differential equations

ut=uxxheatut+c ux=0transportuxx+uyy=0Laplace\begin{gathered} u_t = u_{xx} \quad \text{heat} \\[4pt] u_t + c\,u_x = 0 \quad \text{transport} \\[4pt] u_{xx} + u_{yy} = 0 \quad \text{Laplace} \end{gathered}

The heat equation and Laplace's equation have order 2; the transport equation has order 1. In the transport equation cc is a fixed number, a speed. In Laplace's equation both variables are positions, xx and yy, and nothing depends on time.

Units

Every term of an equation must have the same units. In the heat equation, utu_t is in units of uu per unit of time. But uxxu_{xx} is in units of uu per unit of length squared.

So a physical heat equation carries a constant: ut=k uxxu_t = k\,u_{xx}, with k>0k > 0 in length² per unit of time. This lesson takes k=1k = 1, which amounts to choosing the unit of time. In the transport equation, cc is in length per unit of time.

The heat equation

The heat equation ut=uxxu_t = u_{xx} describes heat spreading along a thin rod, with u(x,t)u(x, t) the temperature at position xx and time tt. It says: the temperature rises where the profile bends up (uxx>0u_{xx} > 0) and falls where it bends down. Module 6.4 studies it in depth.

A candidate. Take u=e−tsin⁡xu = e^{-t}\sin x. Holding xx fixed, ut=−e−tsin⁡xu_t = -e^{-t}\sin x; holding tt fixed, ux=e−tcos⁡xu_x = e^{-t}\cos x and uxx=−e−tsin⁡xu_{xx} = -e^{-t}\sin x. The two sides agree at every point, so it is a solution.

A solution of the heat equation at four times. Where the profile bends down, at the top, it falls; the arch keeps its shape and shrinks by the factor e−te^{-t}.

A candidate that fails. Try u=e−tsin⁡2xu = e^{-t}\sin 2x. Now ut=−e−tsin⁡2xu_t = -e^{-t}\sin 2x, but by the chain rule uxx=−4e−tsin⁡2xu_{xx} = -4e^{-t}\sin 2x. The residual, the left side minus the right side, is ut−uxx=3e−tsin⁡2xu_t - u_{xx} = 3e^{-t}\sin 2x: not zero, so this is not a solution.

The wiggle sin⁡2x\sin 2x bends four times as sharply as sin⁡x\sin x, so it must die four times as fast: e−4tsin⁡2xe^{-4t}\sin 2x is a solution. In general e−k2tsin⁡kxe^{-k^2 t}\sin kx solves the equation for every number kk. So does a polynomial such as x2+2tx^2 + 2t, with ut=2u_t = 2 and uxx=2u_{xx} = 2.

Rule: Checking a solution

residual=left side−right sideheat: ut−uxx=0 at every point\begin{gathered} \text{residual} = \text{left side} - \text{right side} \\[4pt] \text{heat: } u_t - u_{xx} = 0 \text{ at every point} \end{gathered}

Compute each partial derivative, holding the other variable fixed (lesson 4.1.2), and substitute, as lesson 6.1.1 did for an ODE. A solution makes the residual zero everywhere in the region, not just at one point.

Try it

SymPy computes each partial derivative exactly. Each line prints uu, then utu_t, then uxxu_{xx}, then the residual ut−uxxu_t - u_{xx}.

The first two candidates are solutions. The third leaves 3e−tsin⁡2x3e^{-t}\sin 2x.

⌘/Ctrl + Enter runs the cell

Checking by central differences

When uu is a program rather than a formula, estimate each partial by lesson 2.8.1's central differences, with a step hh. For utu_t, move tt by ±h\pm h and keep xx fixed; for uxxu_{xx}, use the second difference in xx.

With h=0.01h = 0.01, at three points:

point (x,t)(x, t)utu_t estimateuxxu_{xx} estimateresidualresidual for e−tsin⁡2xe^{-t}\sin 2x
(0.5,0.25)(0.5, 0.25)−0.373383-0.373383−0.373374-0.373374−9.3×10−6-9.3 \times 10^{-6}1.9659
(1,0.5)(1, 0.5)−0.510386-0.510386−0.510374-0.510374−1.3×10−5-1.3 \times 10^{-5}1.6545
(2,1)(2, 1)−0.334517-0.334517−0.334509-0.334509−8.4×10−6-8.4 \times 10^{-6}−0.8352-0.8352

For the solution the residual is tiny, and it shrinks like h2h^2. At (1,0.5)(1, 0.5) it is −1.3×10−3-1.3 \times 10^{-3}, −1.3×10−5-1.3 \times 10^{-5} and −1.3×10−7-1.3 \times 10^{-7} for hh = 0.1, 0.01 and 0.001: truncation error, not a failure. For e−tsin⁡2xe^{-t}\sin 2x the residual closes in on its true value, 3e−0.5sin⁡2≈1.65463e^{-0.5}\sin 2 \approx 1.6546, and stays there.

Try it

heat_residual returns the two estimates and the residual. The loop is the table: each line prints the point, the estimates, the residual, and the residual of the failing candidate.

The last loop shrinks the step at (1,0.5)(1, 0.5).

⌘/Ctrl + Enter runs the cell

Where a candidate fails: a corner

The heat equation needs uxxu_{xx}, so a candidate must be smooth enough to have it. The profile u=∣x∣u = |x|, frozen in time, has ut=0u_t = 0 and uxx=0u_{xx} = 0 everywhere except at x=0x = 0, where it has a corner.

There the second difference is h−0+hh2=2h\frac{h - 0 + h}{h^2} = \frac{2}{h}: 20, 200 and 2,000 for hh = 0.1, 0.01 and 0.001. It grows without limit, so ∣x∣|x| does not solve the heat equation at its corner. Module 6.4 shows that heat smooths such a corner at once.

Try it

The second difference of ∣x∣|x| at its corner, for three steps. Each estimate is 2h\frac{2}{h}.

⌘/Ctrl + Enter runs the cell

The transport equation

The transport equation ut+c ux=0u_t + c\,u_x = 0 describes a shape that moves at speed cc without changing, such as dye carried along by a steady stream. Take any differentiable function ff of one variable, and set u(x,t)=f(x−ct)u(x, t) = f(x - ct).

By the chain rule (lesson 2.3.3), with the inside x−ctx - ct having slope −c-c in tt and 1 in xx:

ut=−c f′(x−ct),ux=f′(x−ct)ut+c ux=−c f′+c f′=0\begin{gathered} u_t = -c\,f'(x - ct), \quad u_x = f'(x - ct) \\[4pt] u_t + c\,u_x = -c\,f' + c\,f' = 0 \end{gathered}

So every f(x−ct)f(x - ct) is a solution. Its value depends only on x−ctx - ct, so it is the same all along each line x=ct+constantx = ct + \text{constant}. Whatever is at x=0x = 0 at t=0t = 0 is at x=cx = c at t=1t = 1.

An example by numbers. Take c=2c = 2 and the bump u=e−(x−2t)2u = e^{-(x - 2t)^2}, whose peak is at x=2tx = 2t.

x=0x = 0x=1x = 1x=2x = 2x=3x = 3
t=0t = 010.36790.01830.0001
t=0.5t = 0.50.367910.36790.0183
t=1t = 10.01830.367910.3679

Each row is the row above moved one place to the right. The bump moves 1 in half a unit of time: a speed of 2.

A solution of the transport equation with c=2c = 2 at four times. The bump keeps its shape and moves right by 1 every half unit of time.

Both directions, and a corner

The sign of cc sets the direction. For c>0c > 0 the shape moves right; for c<0c < 0 it moves left; for c=0c = 0 the equation is ut=0u_t = 0, and the shape stays put.

A shape written the other way round, f(x+ct)f(x + ct), moves left. For example (x+2t)2(x + 2t)^2 gives ut+2ux=8x+16tu_t + 2u_x = 8x + 16t, not zero: it solves ut−2ux=0u_t - 2u_x = 0 instead.

The function ff may have a corner, such as u=∣x−2t∣u = |x - 2t|. Then the partial derivatives fail on the line x=2tx = 2t, and the equation holds everywhere else; the corner simply travels with the shape.

Try it

SymPy confirms f(x−2t)f(x - 2t) for a function ff it knows nothing about: the residual is 0. The loop prints the table.

The last lines check the bump by central differences with h=0.001h = 0.001: the residual is about 4×10−64 \times 10^{-6}, truncation error again. Then the wrong-way candidate (x+2t)2(x + 2t)^2, with c=2c = 2 and c=−2c = -2.

⌘/Ctrl + Enter runs the cell

Laplace's equation

Laplace's equation uxx+uyy=0u_{xx} + u_{yy} = 0 has no time in it. It describes a steady state, such as the temperature across a metal plate once it has stopped changing.

It says the bend of the slice in xx cancels the bend of the slice in yy. Where one bends up, the other bends down as much.

The saddle x2−y2x^2 - y^2 of lesson 4.1.1 is a solution: uxx=2u_{xx} = 2 and uyy=−2u_{yy} = -2. The bowl x2+2y2x^2 + 2y^2 is not, since both its slices bend up: 2+4=62 + 4 = 6. Two more solutions are xyxy, whose slices are straight lines, and exsin⁡ye^x\sin y, with uxx=exsin⁡yu_{xx} = e^x\sin y and uyy=−exsin⁡yu_{yy} = -e^x\sin y.

Try it

Each line prints uu, uxxu_{xx}, uyyu_{yy} and the residual uxx+uyyu_{xx} + u_{yy}. Only the bowl fails.

⌘/Ctrl + Enter runs the cell

Linear equations and adding solutions

An equation is linear if uu and its partials appear only on their own, each times a number or a function of the variables. They are never multiplied together, squared, or put inside another function. The heat, transport and Laplace equations are linear.

The equation ut+u ux=0u_t + u\,u_x = 0 is not: it multiplies uu by uxu_x. Neither is ut=(ux)2u_t = (u_x)^2.

Rule: Adding solutions

u1,u2 solutions⇒a u1+b u2 a solution\begin{gathered} u_1, u_2 \text{ solutions} \\[4pt] \Rightarrow a\,u_1 + b\,u_2 \text{ a solution} \end{gathered}

Take a linear equation in which every term contains uu or one of its partials. Then any combination of its solutions, with numbers aa and bb, is a solution. Each partial derivative of a sum is the sum of the partials, so the residuals add up to 0+00 + 0.

For example, e−tsin⁡x+3e−4tsin⁡2xe^{-t}\sin x + 3e^{-4t}\sin 2x solves the heat equation, because each part does. Module 6.4 builds solutions from many such parts.

The rule fails in two ways. For the nonlinear ut+u ux=0u_t + u\,u_x = 0, the function u=x1+tu = \frac{x}{1 + t} is a solution, but 2u2u leaves the residual 2x(1+t)2\frac{2x}{(1 + t)^2}.

It also fails for a term without uu, such as the +1+1 in ut=uxx+1u_t = u_{xx} + 1. There u=tu = t is a solution, but 2t2t leaves a residual of 1: the +1+1 is not doubled.

Try it

heat and nonlinear return the residuals of ut=uxxu_t = u_{xx} and ut+u ux=0u_t + u\,u_x = 0. The first line checks two solutions of the heat equation and their combination.

The second line checks x1+t\frac{x}{1 + t} and its double.

⌘/Ctrl + Enter runs the cell

Every equation in this lesson has many solutions: e−k2tsin⁡kxe^{-k^2 t}\sin kx for every kk, or f(x−ct)f(x - ct) for every ff. Lesson 6.3.2 adds the conditions that pick out one of them. Case study 6.3.4 checks in the same way that the Black–Scholes formula solves the Black–Scholes equation.

Common mistakes

  1. Hold the other variable fixed. In utu_t of e−tsin⁡xe^{-t}\sin x, the factor sin⁡x\sin x is a constant.
  2. Check everywhere, not at one point. The residual 3e−tsin⁡2x3e^{-t}\sin 2x of e−tsin⁡2xe^{-t}\sin 2x is zero at x=0x = 0, yet the candidate fails.
  3. Keep the chain-rule factor. For u=f(x−ct)u = f(x - ct), ut=−c f′(x−ct)u_t = -c\,f'(x - ct), not f′(x−ct)f'(x - ct). For sin⁡2x\sin 2x, uxxu_{xx} carries a factor 4.
  4. Mind the direction. f(x−ct)f(x - ct) moves right when c>0c > 0; f(x+ct)f(x + ct) moves left and solves ut−c ux=0u_t - c\,u_x = 0.
  5. The order is the highest partial in any variable. ut=uxxu_t = u_{xx} has order 2, though it is first order in tt.
  6. Adding solutions needs a linear equation with no term free of uu.
  7. A small residual from central differences is a pass if it shrinks like h2h^2. A residual that settles on a nonzero value is a fail. At a corner, the second difference grows like 1h\frac{1}{h}.

Partial differential equations

0 of 13 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
  13. 13.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • A partial differential equation links an unknown function of several variables, such as u(x,t)u(x, t), to its partial derivatives. Its order is that of its highest partial; every term has the same units.
  • Heat, ut=uxxu_t = u_{xx}: uu rises where the profile bends up. Solutions include e−k2tsin⁡kxe^{-k^2t}\sin kx and x2+2tx^2 + 2t.
  • Transport, ut+c ux=0u_t + c\,u_x = 0: every f(x−ct)f(x - ct) is a solution, a shape moving at speed cc (right for c>0c > 0).
  • Laplace, uxx+uyy=0u_{xx} + u_{yy} = 0: the bends in xx and yy cancel, as for the saddle x2−y2x^2 - y^2.
  • To check a candidate, compute its partials and substitute: the residual must be zero at every point. By central differences it shrinks like h2h^2 for a solution.
  • For a linear equation with every term containing uu, sums and multiples of solutions are solutions. A nonlinear term or a term free of uu breaks this.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.