TITLE: Solve a PDE with Feynman-Kac Formula
QUESTION [5 upvotes]: So there is the following PDE given:
$\frac{\partial}{\partial t}f(t,x) + rx\frac{\partial}{\partial x}f(t,x)+\frac{\sigma^2 x^2}{2}\frac{{\partial}^2}{\partial x^2}f(t,x) = rf(t,x)$
With boundary condition $f(T,x) = x^{\frac{2r}{\sigma^2}}$
Here $r$ and $\sigma$ are positive constants.
From what I have learned, I the solution is from the boundary condition $f(t,x) =e^{-r(T-t)}E[x^{\frac{2r}{\sigma^2}}]$
So first I look fro the stochastic representation which I find as:
$dX(t) = rdt + \sigma dW(t)$ with X(t) = x
The solution is:
$X(T) = x + r(T-t) + \sigma(W(T)-W(t))$
This is normally distributed with mean $x + r(T-t)$ and variance $\sigma \sqrt{T-t}$
Now from boundary condition I have $f(t,x) =e^{-r(T-t)}E[(x + r(T-t) + \sigma(W(T)-W(t)))^{\frac{2r}{\sigma^2}}]$
However I don't know if this method is correct. If it is correct, how should I calculate this expectation? By the way, I take this expectation under $Q$ martingale measure.
Thanks

REPLY [2 votes]: Define
$$
f(x,t):=\mathbb E[e^{-r(T-t)}X_T^{\frac{2r}{\sigma^2}} \vert X_t=x]\,,
$$
where the Ito-process, $\text dX_u = rX_u\text du + \sigma X_u\text dW_u\ $ (with $X_t=x$), and the Weiner process, $W_u$, have been defined with respect to some suitable underlying filtered probability space (with filtration $\{\mathcal F_t\}_{t\geqslant 0}$). Now, by solving the SDE defining the process $X_u$, we obtain
$$
X_u=xe^{(r-\frac{1}{2}\sigma^2)(u-t)+\sigma (W_{u}-W_{t})}\ \ (\text{for }u\geqslant t).
$$
Thus, by considering conditional expectations with respect to the sigma-algebra $\mathcal F_t$,
$$
\mathbb E[e^{-r(T-t)}X_T^{\frac{2r}{\sigma^2}} \vert \mathcal F_t] = e^{-r(T-t)}\mathbb E[X_T^{\frac{2r}{\sigma^2}} \vert \mathcal F_t] = e^{-r(T-t)}\mathbb E[(xe^{(r-\frac{1}{2}\sigma^2)(T-t)+\sigma (W_{T}-W_{t})})^{\frac{2r}{\sigma^2}} \vert \mathcal F_t] = e^{-r(T-t)}x^{\frac{2r}{\sigma^2}}e^{\frac{2r}{\sigma^2}(r-\frac{1}{2}\sigma^2)(T-t)}\mathbb E[(e^{\sigma (W_{T}-W_{t})})^{\frac{2r}{\sigma^2}} \vert \mathcal F_t] = e^{-r(T-t)}x^{\frac{2r}{\sigma^2}}e^{\frac{2r}{\sigma^2}(r-\frac{1}{2}\sigma^2)(T-t)}\mathbb E[e^{\frac{2r}{\sigma} (W_{T}-W_{t})}]\,,
$$
where $\mathbb E[e^{\frac{2r}{\sigma} (W_{T}-W_{t})}\vert \mathcal F_t] = \mathbb E[e^{\frac{2r}{\sigma} (W_{T}-W_{t})}]$ since $(W_{T}-W_{t})$ is independent of $\mathcal F_t$. 
So,

$$
f(x,t) = x^{\frac{2r}{\sigma^2}}e^{-2r(T-t)}e^{2\frac{r^2}{\sigma^2}(T-t)}\mathbb E[e^{\frac{2r}{\sigma} (W_{T}-W_{t})}]\,.
$$

We are almost done; we simply need to evaluate $\mathbb E[e^{\frac{2r}{\sigma} (W_{T}-W_{t})}]$ using the fact that $W_{T}-W_{t}\sim\mathcal N(0,T-t)$. Note that,
$$
\begin{eqnarray*}
\mathbb E[e^{\frac{2r}{\sigma} (W_{T}-W_{t})}] &=& \frac{1}{\sqrt{2\pi(T-t)}}\int_{-\infty}^{\infty}e^{\frac{2r}{\sigma} w-\frac{1}{2}w^2/(T-t)}\text dw \\ && \\& =  &\ldots  \\ && \\
& = & e^{2\frac{r^2}{\sigma^2}(T-t)}\,.
\end{eqnarray*}
$$ 
Therefore,

$$
f(x,t) = x^{\frac{2r}{\sigma^2}}e^{-2r(T-t)}e^{4\frac{r^2}{\sigma^2}(T-t)}\,.
$$


If you are curious, you can convince yourself that the solution above is correct by showing that it satisfies the given PDE: simply compute each of the partial derivatives and plug them in the PDE.