Solution (source code)

= Solution

For the <stochastic differential equation> $dX_s=b(s,X_s)\,ds+\Sigma(s,X_s)\,dB_s$, the <diffusion generator> on smooth functions is
$$
(\mathcal L_sg)(x)=\sum_jb_j(s,x)\partial_jg(x)
+\frac12\sum_{j,k}(\Sigma\Sigma^{\mathsf T})_{jk}(s,x)\partial_{jk}g(x).
$$
One form of the <Feynman-Kac formula> is the following. Suppose the <stochastic differential equation> is well posed and nonexplosive, $c\geq0$ is bounded, the terminal data $g$ and source $h$ are bounded, and $F$ is a <classical solution> bounded on finite time intervals of
$$
\partial_tF+\mathcal L_tF-cF+h=0,\qquad F(T,x)=g(x).
$$
With the regularity needed for the <Itô formula>, the <parabolic Feynman-Kac formula with a source> states
$$
\boxed{\begin{aligned}
F(t,x)=\mathbb E_{t,x}\bigg[&e^{-\int_t^Tc(r,X_r)\,dr}g(X_T)\\
&+\int_t^Te^{-\int_t^sc(r,X_r)\,dr}h(s,X_s)\,ds\bigg].
\end{aligned}}
$$
Here $\mathbb E_{t,x}$ means expectation for the <diffusion process> started at $X_t=x$. Under hypotheses ensuring existence of a <classical solution>, this representation also identifies that solution uniquely in the stated bounded class. In the remaining parts, $c=h=0$, so $F(t,x)=\mathbb E_{t,x}g(X_T)$ solves the terminal-value <Kolmogorov backward equation> $F_t+\mathcal L_tF=0$. Complex terminal data are allowed by applying the real formula to their <real part> and <imaginary part> separately.