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
∂
u
∂
t
(
x
,
t
)
+
μ
(
x
,
t
)
∂
u
∂
x
(
x
,
t
)
+
1
2
σ
2
(
x
,
t
)
∂
2
u
∂
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
)
=
ψ
(
x
)
,
where μ, σ, ψ, V, f are known functions, T is a parameter and
u
:
R
×
[
0
,
T
]
→
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
[
∫
t
T
e
−
∫
t
r
V
(
X
τ
,
τ
)
d
τ
f
(
X
r
,
r
)
d
r
+
e
−
∫
t
T
V
(
X
τ
,
τ
)
d
τ
ψ
(
X
T
)
|
X
t
=
x
]
under the probability measure Q such that X is an Itō process driven by the equation
d
X
=
μ
(
X
,
t
)
d
t
+
σ
(
X
,
t
)
d
W
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.
Let u(x, t) be the solution to above PDE. Applying Itō's lemma to the process
Y
(
s
)
=
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
u
(
X
s
,
s
)
+
∫
t
s
e
−
∫
t
r
V
(
X
τ
,
τ
)
d
τ
f
(
X
r
,
r
)
d
r
one gets
d
Y
=
d
(
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
)
u
(
X
s
,
s
)
+
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
d
u
(
X
s
,
s
)
+
d
(
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
)
d
u
(
X
s
,
s
)
+
d
(
∫
t
s
e
−
∫
t
r
V
(
X
τ
,
τ
)
d
τ
f
(
X
r
,
r
)
d
r
)
Since
d
(
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
)
=
−
V
(
X
s
,
s
)
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
d
s
,
the third term is
O
(
d
t
d
u
)
and can be dropped. We also have that
d
(
∫
t
s
e
−
∫
t
r
V
(
X
τ
,
τ
)
d
τ
f
(
X
r
,
r
)
d
r
)
=
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
f
(
X
s
,
s
)
d
s
.
Applying Itō's lemma once again to
d
u
(
X
s
,
s
)
, it follows that
d
Y
=
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
(
−
V
(
X
s
,
s
)
u
(
X
s
,
s
)
+
f
(
X
s
,
s
)
+
μ
(
X
s
,
s
)
∂
u
∂
X
+
∂
u
∂
s
+
1
2
σ
2
(
X
s
,
s
)
∂
2
u
∂
X
2
)
d
s
+
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
σ
(
X
,
s
)
∂
u
∂
X
d
W
.
The first term contains, in parentheses, the above PDE and is therefore zero. What remains is
d
Y
=
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
σ
(
X
,
s
)
∂
u
∂
X
d
W
.
Integrating this equation from t to T, one concludes that
Y
(
T
)
−
Y
(
t
)
=
∫
t
T
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
σ
(
X
,
s
)
∂
u
∂
X
d
W
.
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
)
∣
X
t
=
x
]
=
E
[
Y
(
t
)
∣
X
t
=
x
]
=
u
(
x
,
t
)
.
The desired result is obtained by observing that
E
[
Y
(
T
)
∣
X
t
=
x
]
=
E
[
e
−
∫
t
T
V
(
X
τ
,
τ
)
d
τ
u
(
X
T
,
T
)
+
∫
t
T
e
−
∫
t
r
V
(
X
τ
,
τ
)
d
τ
f
(
X
r
,
r
)
d
r
|
X
t
=
x
]
and finally
u
(
x
,
t
)
=
E
[
e
−
∫
t
T
V
(
X
τ
,
τ
)
d
τ
ψ
(
X
T
)
+
∫
t
T
e
−
∫
t
s
V
(
X
τ
,
τ
)
d
τ
f
(
X
s
,
s
)
d
s
|
X
t
=
x
]
The proof above is essentially that of 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
:
R
N
×
[
0
,
T
]
→
R
becomes (see H. Pham book below):
where,
i.e. γ = σσ′, where σ′ denotes the transpose matrix of σ).
This expectation can then be approximated using Monte Carlo or quasi-Monte Carlo methods.
When originally published by Kac in 1949, 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
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
)
≥
0
,
where
w(
x, 0) = δ(
x) and
The Feynman–Kac formula can also be interpreted as a method for evaluating functional integrals of a certain form. If
where the integral is taken over all random walks, then
where
w(
x,
t) is a solution to the parabolic partial differential equation
with initial condition
w(
x, 0) =
f(
x).