## 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!

## BS from Delta-Hedging

Today I’m going to look at another method of getting to the BS equations, by constructing a delta-hedge. This is the way that the equation was in fact first reached historically, and it’s a nice illustration of the principle of hedging. All of the same assumptions are made as in the post that derived the BS equation via Risk Neutral Valuation.

The principle is that because the price of some derivative is a function of the stochastic underlying , then all of the uncertainty in comes from the same source as the uncertainty in . We try to construct a risk-free portfolio made up of the two of these that perfectly cancels out all of the risk. If the portfolio is risk-free, we know it must grow at the risk free rate or else we have an arbitrage opportunity.

Our model for S is the geometric brownian motion, note that we allow the rate of growth in general to be different from

We can express in terms of its derivatives with respect to and using Ito’s lemma, which I discussed in a previous post,

Our portfolio is made up of one derivative worth and a fraction  of the underlying stock, worth ; so the net price is . We combine the above two results to give

We are trying to find a portfolio that is risk-free, which means we would like the stochastic term to cancel. We see immediately that this happens for , which gives

Since this portfolio is risk-free, to prevent arbitrage it must grow deterministically at the risk free rate

and so

This is the BS partial differential equation (pde). Note that despite the fact that the constant growth term for the underlying had a rate , this has totally disappeared in the pde above – we might disagree with someone else about the expected rate of growth of the stock, but no-arbitrage still demands that we agree with them about the price of the option [as long as we agree about , that is!]

As for any pde, we can only solve for a specific situation if we have boundary conditions – in this case, given by the payoff at expiry . At that point we know the exact form the value that must take

Our job is to use the pdf to evolve the value of backwards to . In the case of vanilla options this can be done exactly, while for more complicated payoffs we would need to discretise and solve numerically. This gives us another way of valuing options that is complementary (and equivalent) to the expectations approach discussed previously.

To solve the equation above, it is useful to first make some substitutions. As we are interested in time-to-expiry only, we make the change of variables  which yields

We can eliminate the terms by considering change-of-variables . This means that

Combining these the BS equation becomes

The linear term in can be removed by another transformation  so that

The exponential terms cancel throughout, and we are left with

One final transformation will be needed before putting in boundary conditions. The transformation will be

But unlike the other transformations I’ve suggested so far, this one mixes the two variables that we are using, so a bit of care is required about what we mean. When I most recently wrote the BS equation, was a function of and  – this means that the partial differentials with respect to  were implicitly holding constant and vise versa. I’m now going to write as a function of and instead, and because the relationship features all three variables we need to take a bit of care with our partial derivatives:

where vertical lines indicate the variable that is being held constant during evaluation. Now, to move from to , we expand out the term in the same way as we did for above

We can compare these last two equations to give expressions for the derivatives that we need after the transformation by comparing the coefficients of  and

Computing and inserting these derivatives [I’ve given a graphical representation of the first of these equations below, because the derivation is a little dry at present!] into the BS equation gives

This is the well-known Heat Equation in physics. For the sake of brevity I won’t solve it here, but the solution is well known – see for example the wikipedia page – which gives the general solution:

Where is the payoff condition (it’s now an initial condition, as expiry is at  = 0). The algebra is quite involved so I give the solution its own post, and you can show by substitution that the BS option formulae given previously is a solution to the equation.

As an aside, what was the portfolio that I was considering all of the way through? Comparing to the vanilla greeks, we recognise it as the option delta – the hedging portfolio is just the portfolio of the option with just enough stock to hedge out the local delta risk. Of course, as time goes by this value will change, and we need to constantly adjust our hedge to account for this. This shows the breakdown caused by one of our assumptions – that we could trade whenever we want and without transaction costs. In fact, because we need to re-hedge at every moment to enforce this portfolio’s risk free nature, in the presence of transaction costs the hedging costs in this strategy will be infinite! This demonstrates a significant failing of one of our assumptions, I’ll come back again to the effect of this in the real world in future posts.