# How to solve this PDE using Feynman-Kac?

I have the following problem right now: solve $$F_t(t,x) + rxF_x(t,x) + \frac{\sigma^2}{2}F_{xx}(t,x) = rF(t,x), \\ F(T,x) = (x - K)^2.$$

How do I solve this?

There exists a theorem to solve this, which represents $F(t,x)$ as the discounted expected value of $(X - k)^2$ where $dX = rXds + \sigma X dW$ and with $X_t = x$.

However, my issues are mainly centered around how messy my calculations get. If I try to solve the above by first calculating $X_s$ since it satisfies a GBM, and then calculating its expectation after first squaring it in the way I need to $(X - k)^2$, the calculations get incredibly messy, and all I get is a whole lot of $\exp$'s to a bunch of powers that vaguely resemble one another but it still doesn't simplify easily.

Have I made a mistake, or is the answer really that messy?

## Martingale Approach

As you noted, you need to solve

\begin{eqnarray} F(0) & = & e^{-r T} \mathbb{E} \left[ \left( X_T - K \right)^2 \right]\\ & = & e^{-r T} \left( \mathbb{E} \left[ X_T^2 \right] - 2 K \mathbb{E} \left[ X_T \right] + K^2 \right) \end{eqnarray}

Let $Y_t = X_t^2$. Then, by applying the Itō formula, we get

\begin{eqnarray} \mathrm{d}Y_t & = & 2 X_t \mathrm{d}X_t + \mathrm{d} \langle X \rangle_t\\ & = & \left( 2 r + \sigma^2 \right) Y_t \mathrm{d}t + 2 \sigma Y_t \mathrm{d}W_t. \end{eqnarray}

It follows that

\begin{eqnarray} \mathbb{E} \left[ X_T \right] & = & X_0 e^{r T},\\ \mathbb{E} \left[ X_T^2 \right] & = & X_0^2 e^{\left( 2 r + \sigma^2 \right) T}. \end{eqnarray}

Consequently,

$$F(0) = e^{-r T} \left( X_0^2 e^{\left( 2 r + \sigma^2 \right) T} - 2 K X_0 e^{r T} + K^2 \right).$$

## PDE Approach

Alternatively, you can apply a change of variables to the PDE. Define

$$\tau = (T - t), \quad \xi = r - \frac{1}{2} \sigma^2, \quad y = \ln(x) + \xi \tau, \quad F(t, x) = e^{-r \tau} G(\tau, y).$$

After carefully applying the chain rule, we obtain the PDE

$$\frac{\partial G}{\partial \tau} = \frac{1}{2} \sigma^2 \frac{\partial^2 G}{\partial y^2}$$

with initial condition

$$G(0, y) = \left( e^y - K \right)^2.$$

The fundamental solution is the heat kernel given by

$$\phi(\tau, y) = \frac{1}{\sqrt{2 \pi \sigma^2 \tau}} \exp \left\{ -\frac{y^2}{2 \sigma^2 \tau} \right\}.$$

We obtain $G(\tau, y)$ through the convolution

\begin{eqnarray} G(\tau, y) & = & \int_{-\infty}^\infty G(0, z) \phi(\tau, y - z) \mathrm{d}z\\ & = & \int_{-\infty}^\infty \left( e^{2 z} - 2 K e^z + K^2 \right) \phi(\tau, y - z) \mathrm{d}z. \end{eqnarray}

Next note that for some $\alpha \in \mathbb{R}$,

\begin{eqnarray} \int_{-\infty}^\infty e^{\alpha z} \phi(\tau, y - z) \mathrm{d}z & = & e^{\alpha y + \alpha^2 \sigma^2 \tau / 2} \end{eqnarray}

Thus

$$G(\tau, y) = e^{2 y + 2 \sigma^2 \tau} - 2 K e^{y + \sigma^2 \tau / 2} + K^2$$

and substituting back yields

$$F(0, x) = e^{-r T} \left( x^2 e^{\left( 2 r + \sigma^2 \right) T} - 2 K x e^{r T} + K^2 \right)$$

as before.

• Does this satisfy the condition of integrability that the used result takes as given? – Rama Jan 22 '17 at 20:11
• Do you mean if the payoff function satisfies the integrability condition such that the Feynman-Kac theorem can be applied? Yes it does. – LocalVolatility Jan 22 '17 at 21:02