# Solving a partial differential equation (Feynman-Kac )

I have the following PDE

\begin{aligned} \frac{\partial}{\partial t} f(t, x)+\mu x \frac{\partial}{\partial x} f(t, x)+\frac{1}{2} \sigma^{2} x^{2} \frac{\partial^{2}}{\partial x^{2}} f(t, x) &=0 \\ f(T, x) &=\log \left(x^{2}\right) \end{aligned}

with $$\mu$$ and $$\sigma$$ some fixed parameters.

Now, I know through Feynman-Kac that I can write $$f(t,X_t) = E_t [ log(X_T^2) ]$$

where $$X_t$$ is geometric brownian motion ($$dX_t = \mu dt + \sigma dB_t$$).

Now the question is, how do I find the function $$f(t,x)$$?

I tried applying Itto's rule on $$X_t^2$$, and I get (not sure if it is correct):

$$d(X_t^2) = (2 \mu X_t + \sigma^2 )dt + 2 \sigma X_t dB_t$$

I'm not sure how to proceed from here...

As $$X$$ is a geometric Brownian motion, we know the SDE solved by $$X$$ has a unique solution: $$\begin{equation} X_t = X_0 e^{(\mu - \frac12\sigma^2 )t + \sigma B_t} \end{equation}$$ where $$\left\{B_t\right\}_{t \geq 0}$$ is $$\mathcal{F}_t$$-Brownian motion. We can also rewrite the above quantity at time $$T$$: $$\begin{equation} X_T = X_te^{(\mu - \frac12\sigma^2 )(T-t) + \sigma (B_T - B_t)} \end{equation}$$ Using Feynam-Kac theorem (verifying we fill in the conditions), the solution of the PDE can be written as : \begin{align} f(t,X_t) &= \mathbb{E}_t [ \log(X_T^2) ]\\ &=2\mathbb{E}_t [ \log(X_T) ]\\ &=2\mathbb{E}_t [ \log(X_t) + (\mu - \frac12\sigma^2)(T-t) + \sigma (B_T - B_t) ]\\ &=2\log(X_t) + (2\mu - \sigma^2)(T-t) + 2\sigma \mathbb{E}_t [B_T - B_t]\\ &=2\log(X_t) + (2\mu - \sigma^2)(T-t) \end{align}
Where in the last equation, we used that $$B_T - B_t \sim\mathcal{N}(0, T-t)$$ and is independent of $$\mathcal{F}_t$$
You can remark that the function $$f$$ verifies the PDE.