# Feynman–Kac formula

The Feynman–Kac formula named after Richard Feynman and Mark Kac, establishes a link between parabolic partial differential equations (PDEs) and stochastic processes. It offers a method of solving certain PDEs by simulating random paths of a stochastic process. Conversely, an important class of expectations of random processes can be computed by deterministic methods. Consider the PDE

$\frac{\partial u}{\partial t}(x,t) + \mu(x,t) \frac{\partial u}{\partial x}(x,t) + \tfrac{1}{2} \sigma^2(x,t) \frac{\partial^2 u}{\partial x^2}(x,t) -V(x,t) u(x,t) + f(x,t) = 0,$

defined for all x in R and t in [0, T], subject to the terminal condition

$u(x,T)=\psi(x),$

where μ, σ, ψ, V, f are known functions, T is a parameter and $u:\mathbb{R}\times[0,T]\to\mathbb{R}$ is the unknown. Then the Feynman–Kac formula tells us that the solution can be written as a conditional expectation

$u(x,t) = E^Q\left[ \int_t^T e^{- \int_t^r V(X_\tau,\tau)\, d\tau}f(X_r,r)dr + e^{-\int_t^T V(X_\tau,\tau)\, d\tau}\psi(X_T) \Bigg| X_t=x \right]$

under the probability measure Q such that X is an Itō process driven by the equation

$dX = \mu(X,t)\,dt + \sigma(X,t)\,dW^Q,$

with WQ(t) is a Wiener process (also called Brownian motion) under Q, and the initial condition for X(t) is X(t) = x.

## Proof

Let u(x, t) be the solution to above PDE. Applying Itō's lemma to the process

$Y(s) = e^{-\int_t^s V(X_\tau,\tau)\, d\tau} u(X_s,s)+ \int_t^s e^{-\int_t^r V(X_\tau,\tau)\, d\tau}f(X_r,r) \, dr$

one gets

\begin{align} dY = {} & d\left(e^{- \int_t^s V(X_\tau,\tau)\, d\tau}\right) u(X_s,s) + e^{- \int_t^s V(X_\tau,\tau)\, d\tau}\,du(X_s,s) \\[6pt] & {} + d\left(e^{- \int_t^s V(X_\tau,\tau)\, d\tau}\right)du(X_s,s) + d\left(\int_t^s e^{- \int_t^r V(X_\tau,\tau)\, d\tau} f(X_r,r) \, dr\right) \end{align}

Since

$d\left(e^{- \int_t^s V(X_\tau,\tau)\, d\tau}\right) =-V(X_s,s) e^{- \int_t^s V(X_\tau,\tau)\, d\tau} \,ds,$

the third term is $O(dt \, du)$ and can be dropped. We also have that

$d\left(\int_t^s e^{- \int_t^r V(X_\tau,\tau)\, d\tau}f(X_r,r)dr\right) = e^{- \int_t^s V(X_\tau,\tau)\, d\tau} f(X_s,s) ds.$

Applying Itō's lemma once again to $du(X_s,s)$, it follows that

\begin{align} dY= {} & e^{-\int_t^s V(X_\tau,\tau)\, d\tau}\,\left(-V(X_s,s) u(X_s,s) +f(X_s,s)+\mu(X_s,s)\frac{\partial u}{\partial X}+\frac{\partial u}{\partial s}+\tfrac{1}{2}\sigma^2(X_s,s)\frac{\partial^2 u}{\partial X^2}\right)\,ds \\[6pt] & {} + e^{- \int_t^s V(X_\tau,\tau)\, d\tau}\sigma(X,s)\frac{\partial u}{\partial X}\,dW. \end{align}

The first term contains, in parentheses, the above PDE and is therefore zero. What remains is

$dY=e^{-\int_t^s V(X_\tau,\tau)\, d\tau}\sigma(X,s)\frac{\partial u}{\partial X}\,dW.$

Integrating this equation from t to T, one concludes that

$Y(T) - Y(t) = \int_t^T e^{- \int_t^s V(X_\tau,\tau)\, d\tau}\sigma(X,s)\frac{\partial u}{\partial X}\,dW.$

Upon taking expectations, conditioned on Xt = x, and observing that the right side is an Itō integral, which has expectation zero, it follows that

$E[Y(T)\mid X_t=x] = E[Y(t)\mid X_t=x] = u(x,t).$

The desired result is obtained by observing that

$E[Y(T)\mid X_t=x] = E \left [e^{-\int_t^T V(X_\tau,\tau)\, d\tau} u(X_T,T) + \int_t^T e^{- \int_t^r V(X_\tau,\tau)\, d\tau}f(X_r,r)\,dr \,\Bigg|\, X_t=x \right ]$

and finally

$u(x,t) = E \left [e^{- \int_t^T V(X_\tau,\tau)\, d\tau} \psi(X_T) + \int_t^T e^{-\int_t^s V(X_\tau,\tau)\,d\tau} f(X_s,s)\,ds \,\Bigg|\, X_t=x \right ]$

## Remarks

• The proof above is essentially that of [1] with modifications to account for $f(x,t)$.
• The expectation formula above is also valid for N-dimensional Itô diffusions. The corresponding PDE for $u:\mathbb{R}^N\times[0,T]\to\mathbb{R}$ becomes (see H. Pham book below):
$\frac{\partial u}{\partial t} + \sum_{i=1}^N \mu_i(x,t)\frac{\partial u}{\partial x_i} + \frac{1}{2} \sum_{i=1}^N\sum_{j=1}^N\gamma_{ij}(x,t) \frac{\partial^2 u}{\partial x_i x_j} -r(x,t) u = f(x,t),$
where,
$\gamma_{ij}(x,t) = \sum_{k=1}^N\sigma_{ik}(x,t)\sigma_{jk}(x,t),$
i.e. γ = σσ′, where σ′ denotes the transpose matrix of σ).
• When originally published by Kac in 1949,[2] the Feynman–Kac formula was presented as a formula for determining the distribution of certain Wiener functionals. Suppose we wish to find the expected value of the function
$e^{-\int_0^t V(x(\tau))\, d\tau}$
in the case where x(τ) is some realization of a diffusion process starting at x(0) = 0. The Feynman–Kac formula says that this expectation is equivalent to the integral of a solution to a diffusion equation. Specifically, under the conditions that $u V(x) \geq 0$,
$E\left[ e^{- u \int_0^t V(x(\tau))\, d\tau} \right] = \int_{-\infty}^{\infty} w(x,t)\, dx$
where w(x, 0) = δ(x) and
$\frac{\partial w}{\partial t} = \frac{1}{2} \frac{\partial^2 w}{\partial x^2} - u V(x) w.$
The Feynman–Kac formula can also be interpreted as a method for evaluating functional integrals of a certain form. If
$I = \int f(x(0)) e^{-u\int_0^t V(x(t))\, dt} g(x(t))\, Dx$
where the integral is taken over all random walks, then
$I = \int w(x,t) g(x)\, dx$
where w(x, t) is a solution to the parabolic partial differential equation
$\frac{\partial w}{\partial t} = \frac{1}{2} \frac{\partial^2 w}{\partial x^2} - u V(x) w$
with initial condition w(x, 0) = f(x).