# solving the Black-Scholes PDE by finite differences

This entry presents some examples of solving the Black-Scholes partial differential equation in one space dimension:

 $\displaystyle rf=\frac{\partial f}{\partial t}+rx\frac{\partial f}{\partial x}% +\tfrac{1}{2}\sigma^{2}x^{2}\frac{\partial^{2}f}{\partial x^{2}}\,,\quad f=f(t% ,x)\,,$

over the rectangle $0\leq t\leq T$, $X_{\mathrm{L}}\leq x\leq X_{\mathrm{U}}$, with various boundary conditions on the top, bottom, and right sides of the rectangle. The parameters $r$, $\sigma>0$ are arbitrary constants.

The partial differential equation can be solved numerically using the basic methods based on approximating the partial derivatives with finite differences.

## 0.1 Finite-difference formulae

We summarize the equations for the finite differences below.

Let $n$, $m$, $k$ be some chosen positive integers, which determine the grid on which we are approximating the solution of the PDE.

Set $u_{i,j}$ to be the approximation to $f(T-i\Delta t,j\Delta x)$, for $0\leq i\leq m$ and $k\leq j\leq k+n+1$. (For convenience, we have made time move “backwards” as we increase $i$, because the original PDE is really a backwards heat equation, and evolves backwards in time.)

Also set:

 $\Delta t=\frac{T}{m}\,,\quad\Delta x=\frac{X_{\mathrm{U}}-X_{\mathrm{L}}}{n+1}$

Explicit method.

 $\displaystyle\frac{u_{i+1,j}-u_{i,j}}{\Delta t}$ $\displaystyle=-ru_{i,j}+rj\Delta x\,\frac{u_{i,j+1}-u_{i,j-1}}{2\Delta x}$ $\displaystyle\qquad+\frac{1}{2}\sigma^{2}(j\Delta x)^{2}\,\frac{u_{i,j-1}-2u_{% i,j}+u_{i,j+1}}{\Delta x^{2}}$
 $\displaystyle u_{i+1,j}$ $\displaystyle=\Bigl{(}\tfrac{1}{2}(\sigma j)^{2}\Delta t-\tfrac{1}{2}rj\Delta t% \Bigr{)}\,u_{i,j-1}$ $\displaystyle+\Bigl{(}1-(\sigma j)^{2}\Delta t-r\Delta t\Bigr{)}\,u_{i,j}$ $\displaystyle+\Bigl{(}\tfrac{1}{2}(\sigma j)^{2}\Delta t+\tfrac{1}{2}rj\Delta t% \Bigr{)}\,u_{i,j+1}\,.$

Since the PDE to solve is parabolic and time-dependent, we can step through time to numerically approximate it. Given $u_{i,*}$, we can recursively compute $u_{i+1,*}$.

(Add stencil of numerical method here…)

Implicit method.

 $\displaystyle\frac{u_{i+1,j}-u_{i,j}}{\Delta t}$ $\displaystyle=-ru_{i+1,j}+rj\Delta x\,\frac{u_{i+1,j+1}-u_{i+1,j-1}}{2\Delta x}$ $\displaystyle\qquad+\frac{1}{2}\sigma^{2}(j\Delta x)^{2}\,\frac{u_{i+1,j-1}-2u% _{i+1,j}+u_{i+1,j+1}}{\Delta x^{2}}$
 $\displaystyle u_{i,j}$ $\displaystyle=\Bigl{(}-\tfrac{1}{2}(\sigma j)^{2}\Delta t+\tfrac{1}{2}rj\Delta t% \Bigr{)}\,u_{i+1,j-1}$ $\displaystyle+\Bigl{(}1+(\sigma j)^{2}\Delta t+r\Delta t\Bigr{)}\,u_{i+1,j}$ $\displaystyle+\Bigl{(}-\tfrac{1}{2}(\sigma j)^{2}\Delta t-\tfrac{1}{2}rj\Delta t% \Bigr{)}\,u_{i+1,j+1}\,.$

Crank-Nicolson method.

 $\displaystyle\Bigl{(}-\tfrac{1}{4}(\sigma j)^{2}\Delta t+\tfrac{1}{4}rj\Delta t% \Bigr{)}u_{i+1,j-1}\\ \displaystyle+\Bigl{(}1+\tfrac{1}{2}(\sigma j)^{2}\Delta t-\tfrac{1}{2}r\Delta t% \Bigr{)}u_{i+1,j}+\Bigl{(}-\tfrac{1}{4}(\sigma j)^{2}\Delta t-\tfrac{1}{4}rj% \Delta t\Bigr{)}u_{i+1,j+1}\\ \displaystyle=\Bigl{(}\tfrac{1}{4}(\sigma j)^{2}\Delta t-\tfrac{1}{4}rj\Delta t% \Bigr{)}u_{i,j-1}+\Bigl{(}1-\tfrac{1}{2}(\sigma j)^{2}\Delta t-\tfrac{1}{2}r% \Delta t\Bigr{)}u_{i,j}\\ \displaystyle+\Bigl{(}\tfrac{1}{4}(\sigma j)^{2}\Delta t+\tfrac{1}{4}rj\Delta t% \Bigr{)}u_{i,j+1}$

## 0.2 Convergence of methods

(Briefly discuss convergence properties of these methods here…)

## 0.3 Example results

Boundary conditions and parameters:

 $\displaystyle r=0.10\,,\quad\sigma=0.40\,,\quad T=0.5\,,\quad K=50.00\,.$ $\displaystyle X_{\mathrm{L}}=0\,,\quad X_{\mathrm{U}}=100.00\,.$ $\displaystyle\quad m=100\,,\quad n=200\,,\quad\Delta t=0.005\,,\quad\Delta x=0% .4975\,.$
 $\displaystyle f(T,x)$ $\displaystyle=\max(x-K,\>0)\,,$ $\displaystyle X_{\mathrm{L}}\leq x\leq X_{\mathrm{U}}$ $\displaystyle f(t,0)$ $\displaystyle=0\,,$ $\displaystyle 0\leq t\leq T\,,$ $\displaystyle f(t,X_{\mathrm{U}})$ $\displaystyle=x-Ke^{-r(T-t)}\,,$ $\displaystyle 0\leq t\leq T\,.$

(Describe analytic solution here…)

 $\displaystyle r=0.10\,,\quad\sigma=0.40\,,\quad T=0.5\,,\quad K=50.00\,.$ $\displaystyle X_{\mathrm{L}}=0\,,\quad X_{\mathrm{U}}=100.00\,.$ $\displaystyle\quad m=100\,,\quad n=200\,,\quad\Delta t=0.005\,,\quad\Delta x=0% .4975\,.$
 $\displaystyle f(T,x)$ $\displaystyle=\max(x-K,\>0)\,,$ $\displaystyle X_{\mathrm{L}}\leq x\leq X_{\mathrm{U}}$ $\displaystyle f(t,0)$ $\displaystyle=0\,,$ $\displaystyle 0\leq t\leq T\,,$ $\displaystyle f(t,X_{\mathrm{U}})$ $\displaystyle=0\,,$ $\displaystyle 0\leq t\leq T\,.$
• http://svn.gold-saucer.org/math/PlanetMath/SolvingTheBlackScholesPDEByFiniteDifferences/bss.pyPython program that implements the finite-difference methods for the above two problems, and plots the results

Title solving the Black-Scholes PDE by finite differences SolvingTheBlackScholesPDEByFiniteDifferences 2013-03-22 16:30:59 2013-03-22 16:30:59 stevecheng (10074) stevecheng (10074) 6 stevecheng (10074) Example msc 65M06 msc 91B28 msc 35K15