# Solving the Heat Equation

This post follows on from my earlier post on the BS Equation from Delta Hedging. In that post, I showed how delta hedging arguments within the BS model lead to the heat equation

${1\over&space;2}\sigma^2&space;{\partial^2&space;D\over&space;\partial&space;y^2}&space;-&space;{\partial&space;D&space;\over&space;\partial&space;\tau}&space;=&space;0$

where $\inline&space;D&space;=&space;C&space;e^{-r&space;\tau}$, C(S,t) is the derivative price, $\inline&space;y&space;=&space;\ln&space;S&space;+&space;\big(&space;r&space;-&space;{1\over&space;2}\sigma^2&space;\big)\tau$, and $\inline&space;\tau&space;=&space;T&space;-&space;t$. In this post I’m going to solve this equation to give the BS option price for a vanilla call. S can only take positive values, but due the the logarithm y runs from $\inline&space;-\infty$ to $\inline&space;\infty$.

In physics, this equation is usually encountered with periodic boundary conditions coming from the boundaries of the region of interest, but here we don’t have that luxury so will need to be more careful. In this post I’m going to solve the equation using the method of separation of variables, in a later post I’ll re-solve it using the method of Fourier transforms.

The heat equation is linear, which means that if $\inline&space;f(y,\tau)$ and $\inline&space;g(y,\tau)$ are both solutions, then so is the sum $\inline&space;\big(&space;f(y,\tau)&space;+&space;g(y,\tau)&space;\big)$. This means that if we can find a selection of possible solutions, we can combine them to match the boundary condition given by the known form of $\inline&space;D(y,\tau&space;=&space;0)$ at expiry (coming from $\inline&space;C(S,\tau&space;=&space;0)&space;=&space;\big(&space;S&space;-&space;K&space;\big)^+$). We look for separable solutions, which are those of the form $\inline&space;f(y,\tau)&space;=&space;Y(y)T(\tau)$, in which case the derivatives in the heat equation only act on their respective terms:

${1\over&space;2}\sigma^2&space;T(\tau){\partial^2&space;Y(y)\over&space;\partial&space;y^2}&space;-&space;Y(y){\partial&space;T(\tau)&space;\over&space;\partial&space;\tau}&space;=&space;0$

${1\over&space;2}\sigma^2&space;Y''T&space;=&space;Y&space;\dot{T}$

${1\over&space;2}\sigma^2&space;{Y''\over&space;Y}&space;=&space;{\dot{T}&space;\over&space;T}&space;=&space;\lambda^2$

where a dash denotes differentiation by y and a dot differentiation by tau, In the final equation, both sides depend only on independent variables y and tau respectively – the only way this can be true is if both sides are equal to some constant, which we call $\inline&space;\lambda^2$.

In general, we should consider the possibilities that $\inline&space;\lambda^2$ is zero or negative, but it turns out that these won’t matter in this example so I ignore them for brevity. Two equations can be extracted, linked by $\inline&space;\lambda^2$

$Y''&space;-&space;2&space;{\lambda^2&space;\over&space;\sigma^2}&space;Y&space;=&space;0$

$\dot{T}&space;-&space;\lambda^2&space;T&space;=&space;0$

Solving these equations,

$Y_\lambda(y)&space;=&space;Y_{0,\lambda}&space;e^{\sqrt{2}{\lambda&space;\over&space;\sigma&space;}y}$

$T_\lambda&space;(\tau)&space;=&space;e^{\lambda^2&space;\tau}$

with any positive value of lambda allowed. We first try to find the fundamental solution of the heat equation, which is the solution that satisfies $\inline&space;f(y,\tau&space;=&space;0)&space;=&space;\delta(y-a)$ where $\inline&space;\delta$ is the Dirac delta function, and I’ll use this to find the particular solution for a vanilla call at the end. At $\inline&space;\tau&space;=&space;0$ all of the functions T are 1, so these can be neglected, and we simply sum up the right number of Y terms, each with a different value of $\inline&space;\lambda$ which we index with n, to produce the delta function:

$\sum_n&space;Y_{0,\lambda_n}&space;e^{\sqrt{2}{\lambda_n&space;\over&space;\sigma&space;}y}&space;=&space;\delta(y-a)$because $\inline&space;\lambda$ can take any value on the continuous interval $\inline&space;-\infty&space;<&space;\lambda&space;<&space;\infty$, we change the sum to an integral, and also express the delta function using its integral representation and compare co-efficient to equate the two expressions

$\int_{-\infty}^{\infty}&space;Y_{0,\lambda_n}&space;e^{\sqrt{2}{\lambda_n&space;\over&space;\sigma&space;}y}dn&space;=&space;{1&space;\over&space;2\pi}&space;\int_{-\infty}^{\infty}&space;e^{in(y-a)}dn$

so

$Y_{0,n}&space;=&space;{1&space;\over&space;2\pi}e^{-in&space;a}&space;\quad&space;;&space;\quad&space;\lambda_n&space;=&space;{1&space;\over&space;\sqrt{2}}\sigma&space;i&space;n$

And plugging these into our earlier expressions for Y and T, and combining these in the same way for $\inline&space;\tau&space;>&space;0$ to provide the temporal behavior, we arrive at

$f(y,\tau)&space;=&space;\int_{-\infty}^{\infty}&space;Y_{\lambda_n}(y)&space;T_{\lambda_n}(\tau)&space;dn$

$=&space;{1\over&space;2\pi}&space;\int_{-\infty}^{\infty}&space;e^{in(y-a)}&space;e^{-{\sigma^2&space;n^2&space;\tau&space;\over&space;2}}dn$

and once again, this is a gaussian integral that we’ll tackle by completing the square…

$=&space;{1\over&space;2\pi}&space;\int_{-\infty}^{\infty}&space;\exp\Big\{&space;-{1&space;\over&space;2}&space;\sigma^2&space;\tau&space;\Big(&space;n^2&space;-&space;2&space;{i(y-a)\over&space;\sigma^2&space;\tau}&space;+&space;\big(&space;{i(y-a)\over&space;\sigma^2&space;\tau}\big)^2-\big(&space;{i(y-a)\over&space;\sigma^2&space;\tau}\big)^2&space;\Big)&space;\Big\}&space;dn$

$=&space;{1\over&space;2\pi}&space;\int_{-\infty}^{\infty}&space;\exp\Big\{&space;-{1&space;\over&space;2}&space;\sigma^2&space;\tau&space;\Big(n-&space;\big(&space;{i(y-a)\over&space;\sigma}\big)&space;\Big)^2&space;\Big\}&space;\cdot&space;\exp{-(y-a)^2&space;\over&space;2&space;\sigma^2&space;\tau}&space;dn$

$=&space;{1\over&space;2\pi}\cdot\sqrt{2\pi&space;\over&space;\sigma^2&space;\tau}\cdot&space;\exp{-(y-a)^2&space;\over&space;2&space;\sigma^2&space;\tau}$

$=&space;{1\over&space;\sqrt{2\pi&space;\sigma^2&space;\tau}}\cdot&space;\exp{-(y-a)^2&space;\over&space;2&space;\sigma^2&space;\tau}$

and this is the fundamental solution given at the end of the first post and also at wikipedia. Note that although we used separation of variables to find the forms of the functions Y and T, the separability hasn’t been carried through the summation of many different T-Y combinations – the fundamental solution that we’ve arrived at ISN’T separable!

The fundamental solution is the time and space evolution of a function that is initially a delta-function, such that the evolution always obeys the heat equation. We can use the following property of the delta function to construct specific solutions for particular payoff functions:

$f(y)&space;=&space;\int_{-\infty}^{\infty}&space;\delta(y-a)&space;f(a)&space;da$

So, because the fundamental solution $\inline&space;f(y,\tau=0)&space;=&space;\delta(y-a)$, we can construct the payoff function using this integral at $\inline&space;\tau&space;=&space;0$

$D(y,\tau=0)&space;=&space;\int_{-\infty}^{\infty}&space;f(a,\tau=0)&space;D(a,\tau=0)&space;da$

and consequently, at later times

$D(y,\tau)&space;=&space;\int_{-\infty}^{\infty}&space;f(a,\tau)&space;D(a,\tau=0)&space;da$and we can solve this for the specific case that $\inline&space;C(S,\tau&space;=&space;0)&space;=&space;\big(&space;S(\tau=0)&space;-&space;K&space;\big)^+$ as follows (denoting a as y’)

$D(y,\tau)&space;=&space;{e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{-\infty}^{\infty}&space;\exp\Big\{&space;-&space;{(y'-y)^2&space;\over&space;2\sigma^2&space;\tau}&space;\Big\}&space;\cdot&space;\big(&space;e^{y'}&space;-&space;K&space;\big)^+&space;dy'$

The second factor is only non-zero when $\inline&space;y'&space;>&space;\ln&space;K&space;=&space;y_L$, so we can absorb this condition into the lower limit

$=&space;{e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;\exp\Big\{&space;-&space;{(y'-y)^2&space;\over&space;2\sigma^2&space;\tau}&space;\Big\}&space;\cdot&space;\big(&space;e^{y'}&space;-&space;K&space;\big)&space;dy'$and splitting this into two integrals, which we do in turn

$=&space;{e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;K\exp\Big\{&space;-&space;{(y'-y)^2&space;\over&space;2\sigma^2&space;\tau}&space;\Big\}&space;dy'&space;=&space;e^{-r\tau}\cdot&space;K\cdot&space;\Phi\Big({y&space;-&space;y_L&space;\over&space;\sigma&space;\sqrt{\tau}}\Big)$

and

${e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;\exp\Big\{&space;-&space;{(y'-y)^2&space;\over&space;2\sigma^2&space;\tau}&space;\Big\}&space;\cdot&space;e^{y'}&space;dy'$

$=&space;{e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;\exp\Big\{&space;-&space;{1\over&space;2\sigma^2&space;\tau}\Big(&space;y'^2&space;+&space;y^2&space;-&space;2y'y&space;-2y'\sigma^2\tau&space;\pm&space;(&space;y&space;+&space;\sigma^2\tau&space;)^2&space;\Big)&space;\Big\}&space;dy'$

$=&space;{e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;\exp\Big\{&space;-&space;{1\over&space;2\sigma^2&space;\tau}\Big(&space;\big(y'-(y+\sigma^2&space;\tau)\big)^2&space;-&space;\big(y&space;+&space;\sigma^2&space;\tau\big)^2&space;+&space;y^2\Big)&space;\Big\}&space;dy'$

$=&space;{e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;\exp\Big\{&space;-&space;{1\over&space;2\sigma^2&space;\tau}\Big(&space;\big(y'-(y+\sigma^2&space;\tau)\big)^2&space;-&space;\sigma^2\tau\big(2y&space;+&space;\sigma^2&space;\tau\big)\Big)&space;\Big\}&space;dy'$

$=&space;{e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;\exp\Big\{&space;-&space;{\big(y'-(y+\sigma^2&space;\tau)\big)^2\over&space;2\sigma^2&space;\tau}\Big\}\cdot&space;S&space;e^{r\tau}&space;dy'$

$=&space;e^{-r\tau}&space;\cdot&space;F&space;\cdot&space;\Phi&space;\Big(&space;{y&space;-&space;y_L&space;+&space;\sigma^2&space;\tau&space;\over&space;\sigma&space;\sqrt{\tau}}&space;\Big)$

where as usual, $\inline&space;\Phi(x)$ is the cumulative normal distribution; and we’ve used the expression $\inline&space;y&space;=&space;\ln&space;S&space;+&space;(r&space;-&space;{1\over&space;2}\sigma^2)\tau$ and also $\inline&space;y&space;+&space;{1&space;\over&space;2}\sigma^2&space;\tau&space;=&space;S&space;e^{r\tau}&space;=&space;F$. Putting all of this together, we finally arrive at the Black-Scholes expression for a vanilla call price,

${e^{-r\tau}&space;\over&space;\sqrt{2\pi\sigma^2\tau}}\int_{y_L}^{\infty}&space;\exp\Big\{&space;-&space;{(y'-y)^2&space;\over&space;2\sigma^2&space;\tau}&space;\Big\}&space;\cdot&space;\big(&space;e^{y'}&space;-&space;K&space;\big)&space;dy'$

$=&space;e^{-r\tau}&space;\Big(&space;F&space;\cdot&space;\Phi(d_1)&space;-&space;K\cdot&space;\Phi(d_2)\Big)$

Wow! Finally! Hopefully this will convince you that the method of risk-neutral valuation is a bit more straight-forward!