Technical

Feynman-Kac Formula: From Diffusions to Pricing PDEs

Learn the Feynman-Kac formula with its assumptions, discount and source-term signs, proof, Black-Scholes example and checked numerical price.

13 min read·

What the Feynman-Kac Formula Says

The Feynman-Kac formula represents the solution of a linear parabolic PDE as an expectation over diffusion paths. In derivatives pricing, it is the precise reason a risk-neutral Monte Carlo average and the corresponding pricing PDE describe the same claim.

The formula does not create the risk-neutral measure. That is the job of no-arbitrage arguments and, in Brownian models, Girsanov's theorem. Once a measure and Markov diffusion have been fixed, Feynman-Kac converts between their conditional expectation and a PDE.

Mark Kac's 1949 paper, On Distributions of Certain Wiener Functionals, credits Richard Feynman's path-integral work as an influence. The modern name joins two related ideas, but the rigorous probabilistic formula in this form is Kac's.


The Backward Formula

Let Xs∈RnX_s\in\mathbb R^n solve, from state Xt=xX_t=x,

dXs=μ(s,Xs) ds+σ(s,Xs) dWs,t≤s≤T,dX_s=\mu(s,X_s)\,ds+\sigma(s,X_s)\,dW_s, \qquad t\leq s\leq T,

where WW is mm-dimensional and a=σσTa=\sigma\sigma^{\mathsf T}. Its spatial generator is

Lsu=∑i=1nμi(s,x)∂u∂xi+12∑i,j=1naij(s,x)∂2u∂xi∂xj.\mathcal L_s u =\sum_{i=1}^n\mu_i(s,x)\frac{\partial u}{\partial x_i} +\frac12\sum_{i,j=1}^n a_{ij}(s,x) \frac{\partial^2u}{\partial x_i\partial x_j}.

Consider the terminal-value problem

∂u∂t+Ltu−c(t,x)u+f(t,x)=0,u(T,x)=g(x).\frac{\partial u}{\partial t} +\mathcal L_tu-c(t,x)u+f(t,x)=0, \qquad u(T,x)=g(x).

Under conditions ensuring a unique non-explosive diffusion, finite expectations and a sufficiently regular solution, Feynman-Kac gives

u(t,x)=Et,x ⁣[e−∫tTc(q,Xq)dqg(XT)+∫tTe−∫tsc(q,Xq)dqf(s,Xs) ds].\begin{aligned} u(t,x)=\mathbb E_{t,x}\!\Bigg[ &e^{-\int_t^T c(q,X_q)dq}g(X_T)\\ &+\int_t^T e^{-\int_t^s c(q,X_q)dq}f(s,X_s)\,ds \Bigg]. \end{aligned}

This version includes a source term ff. Setting f=0f=0 leaves the discounted terminal payoff used most often in finance. The signs are linked: a PDE term −cu-cu produces e−∫c dse^{-\int c\,ds}, while +f+f produces a positive running-payoff integral.

A practical classical set of assumptions is that μ\mu and σ\sigma are Lipschitz in the state with linear growth, cc is continuous and bounded below, the data have controlled growth, and u∈C1,2u\in C^{1,2}. Weaker viscosity-solution versions exist, so these are sufficient conditions rather than the only possible ones.


Proof by a Discounted Martingale

Fix t,xt,x and define

Ds=exp⁡ ⁣(−∫tsc(q,Xq) dq)D_s=\exp\!\left(-\int_t^s c(q,X_q)\,dq\right)

and

Ms=Dsu(s,Xs)+∫tsDqf(q,Xq) dq.M_s=D_su(s,X_s)+\int_t^sD_qf(q,X_q)\,dq.

Itô's formula gives

du(s,Xs)=(∂u∂s+Lsu)ds+∇uTσ dWs.du(s,X_s) =\left(\frac{\partial u}{\partial s}+\mathcal L_su\right)ds +\nabla u^{\mathsf T}\sigma\,dW_s.

Since dDs=−c(s,Xs)DsdsdD_s=-c(s,X_s)D_sds and DD has finite variation, there is no quadratic-covariation term with u(s,Xs)u(s,X_s). Therefore

dMs=Ds(∂u∂s+Lsu−cu+f)ds+Ds∇uTσ dWs.dM_s =D_s\left( \frac{\partial u}{\partial s} +\mathcal L_su-cu+f \right)ds +D_s\nabla u^{\mathsf T}\sigma\,dW_s.

The PDE makes the drift zero. Subject to the required integrability, MM is a true martingale. Taking conditional expectations between tt and TT, then using u(T,XT)=g(XT)u(T,X_T)=g(X_T), yields the representation.

The converse needs care. Defining uu by the expectation does not by itself prove u∈C1,2u\in C^{1,2}. Regularity theory or a viscosity-solution argument is needed before the classical PDE conclusion follows.


A Heat-Equation Sanity Check

Before adding finance, take dXs=dWsdX_s=dW_s, no discount, no source term and terminal function g(x)=x2g(x)=x^2. Starting from Xt=xX_t=x,

XT=x+(WT−Wt),X_T=x+(W_T-W_t),

so Feynman-Kac gives

u(t,x)=Et,x[XT2]=x2+(T−t).u(t,x)=\mathbb E_{t,x}[X_T^2]=x^2+(T-t).

The associated backward heat equation is

ut+12uxx=0,u(T,x)=x2.u_t+\frac12u_{xx}=0,\qquad u(T,x)=x^2.

Direct differentiation verifies the signs:

ut=−1,12uxx=1.u_t=-1,\qquad \frac12u_{xx}=1.

The terms cancel and the terminal value is correct. Reversing the sign on utu_t would fail even this elementary test.

This example also shows why the generator carries a factor of one half. Brownian variance accumulates at one unit per unit time, and Itô's second-order correction is 12uxxdt\tfrac12u_{xx}dt. If instead dXs=σdWsdX_s=\sigma dW_s, the variance contribution becomes σ2(T−t)\sigma^2(T-t) and the generator term becomes 12σ2uxx\tfrac12\sigma^2u_{xx}.


Backward and Forward Equations

Feynman-Kac here uses the backward Kolmogorov equation: (t,x)(t,x) are the current time and state, while the terminal payoff is fixed at TT. The generator acts on the current-state variable xx.

The forward Kolmogorov equation, also called the Fokker-Planck equation, evolves the transition density towards later time. It uses the adjoint generator L∗\mathcal L^*. One can sometimes solve a pricing problem by finding that density and integrating the payoff, but that is a different PDE orientation from the terminal-value equation above.

Confusing the two usually produces a sign error in time or places derivatives on the wrong coefficients. A quick diagnostic is the data: a known payoff at maturity calls for the backward equation; a known probability density at the initial time calls for the forward equation.


Black-Scholes as Feynman-Kac

Under the bank-account pricing measure, a stock paying continuous dividend yield qq follows

dSt=(r−q)St dt+σSt dWtQ.dS_t=(r-q)S_t\,dt+\sigma S_t\,dW_t^{\mathbb Q}.

For a European payoff g(ST)g(S_T), take c=rc=r, f=0f=0 and

Lu=(r−q)S∂u∂S+12σ2S2∂2u∂S2.\mathcal L u =(r-q)S\frac{\partial u}{\partial S} +\frac12\sigma^2S^2\frac{\partial^2u}{\partial S^2}.

The value

V(t,S)=EQ ⁣[e−r(T−t)g(ST)∣St=S]V(t,S) =\mathbb E^{\mathbb Q}\!\left[ e^{-r(T-t)}g(S_T)\mid S_t=S \right]

solves

∂V∂t+(r−q)S∂V∂S+12σ2S2∂2V∂S2−rV=0,V(T,S)=g(S).\frac{\partial V}{\partial t} +(r-q)S\frac{\partial V}{\partial S} +\frac12\sigma^2S^2\frac{\partial^2V}{\partial S^2} -rV=0, \qquad V(T,S)=g(S).

For a call, g(S)=(S−K)+g(S)=(S-K)^+. This is the Black-Scholes PDE. The terminal payoff is not differentiable at KK, so a fully classical solution need not be smooth all the way to maturity. For t<Tt<T, the lognormal transition density smooths the value.


Checked Call Example

Take S0=K=100S_0=K=100, r=5%r=5\%, q=0q=0, σ=20%\sigma=20\% and T=1T=1. Under Q\mathbb Q,

ST=100exp⁡ ⁣((0.05−0.5×0.202)+0.20Z),Z∼N(0,1).S_T=100\exp\!\left((0.05-0.5\times0.20^2)+0.20Z\right), \qquad Z\sim N(0,1).

Feynman-Kac says

C0=e−0.05EQ[(ST−100)+].C_0=e^{-0.05}\mathbb E^{\mathbb Q}[(S_T-100)^+].

Evaluating the lognormal integral gives

d1=log⁡(100/100)+(0.05+0.5×0.202)0.20=0.35,d2=0.15,d_1=\frac{\log(100/100)+(0.05+0.5\times0.20^2)}{0.20}=0.35, \qquad d_2=0.15, C0=100Φ(0.35)−100e−0.05Φ(0.15)=10.4506.C_0=100\Phi(0.35)-100e^{-0.05}\Phi(0.15) =10.4506.

The units also line up. r(T−t)r(T-t) and σT−t\sigma\sqrt{T-t} are dimensionless, while the expectation and C0C_0 are in currency.

from statistics import NormalDist from math import exp, log, sqrt def black_scholes_call(s, k, r, q, sigma, tau): normal = NormalDist() d1 = (log(s / k) + (r - q + 0.5 * sigma**2) * tau) / (sigma * sqrt(tau)) d2 = d1 - sigma * sqrt(tau) return s * exp(-q * tau) * normal.cdf(d1) - k * exp(-r * tau) * normal.cdf(d2) print(black_scholes_call(100, 100, 0.05, 0.0, 0.20, 1.0)) # 10.4505835722

A Monte Carlo implementation estimates the expectation; a finite-difference solver estimates the PDE solution. Their numerical errors differ, but their population target is the same.


Running Cashflows and Killing

The source term is financially useful. If a contract pays a continuous cashflow rate f(s,Xs)f(s,X_s) until maturity and a terminal amount g(XT)g(X_T), its value is the sum of discounted running and terminal payments. The PDE records this as +f+f.

The coefficient cc is often a short rate, but it can also represent killing. If a state-dependent default intensity λ(t,Xt)\lambda(t,X_t) kills the claim with zero recovery, then c=r+λc=r+\lambda under suitable reduced-form assumptions. Recovery payments belong in ff or in the terminal/boundary data, depending on the contract.

This interpretation is one reason signs matter. Writing +cu+cu in the PDE while retaining negative exponential discounting would describe a different equation.

When the short rate is stochastic, discounting remains inside the expectation:

V(t,x)=Et,xQ ⁣[e−∫tTrsdsg(XT)].V(t,x)=\mathbb E_{t,x}^{\mathbb Q}\!\left[ e^{-\int_t^T r_sds}g(X_T) \right].

Replacing this by e−E[r](T−t)E[g(XT)]e^{-\mathbb E[r](T-t)}\mathbb E[g(X_T)] is generally wrong because the discount factor and payoff can be correlated. A joint Markov state, for example stock and short rate together, supplies the generator and cross-derivative terms needed by the PDE.


Jumps, Boundaries and Path Dependence

For a jump-diffusion, the generator contains an integral. With a Lévy measure ν\nu and a standard small-jump truncation, a one-dimensional term has the form

∫R[u(x+y)−u(x)−y1{∣y∣<1}ux(x)]ν(dy).\int_{\mathbb R} \left[ u(x+y)-u(x)-y\mathbf 1_{\{|y|<1\}}u_x(x) \right]\nu(dy).

The corresponding equation is a partial integro-differential equation. Omitting the truncation without adjusting the drift can make the integral undefined.

Boundaries add another layer. A barrier, stopping time or domain exit requires boundary data and a stopped diffusion. For some path-dependent claims, augmenting the state with a finite-dimensional statistic works: an Asian option can track the running integral and a lookback can track the running maximum. An arbitrary path dependence may be genuinely infinite-dimensional, so "just add a state variable" is not a universal cure.

Semilinear PDEs can be represented by backward stochastic differential equations. Fully nonlinear equations generally require control, second-order BSDEs or other nonlinear expectation machinery. They are extensions of the idea, not the elementary linear Feynman-Kac theorem.


Where the Formula Is Misused

Feynman-Kac assumes a model and a measure; it does not establish that either is economically correct. A beautifully solved PDE can still price under a misspecified volatility process.

The basic formula is linear. American exercise leads to an obstacle problem and an optimal-stopping expectation, not the European terminal-value equation above. Longstaff-Schwartz approximates that stopping problem by regression.

Finally, equality of the mathematical targets does not imply equality of numerical estimates. A coarse PDE grid has truncation and boundary errors. Monte Carlo has sampling error and may have time-stepping bias. Both need independent convergence checks.


Frequently Asked Questions

Is Feynman-Kac a pricing theorem?

It is a probability-to-PDE representation theorem. It becomes a pricing result only after no-arbitrage theory has supplied an appropriate pricing measure and numeraire.

Why is the PDE backward in time?

The payoff is known at maturity TT, so it is a terminal condition. The conditional value is propagated from TT back to the current state (t,x)(t,x).

What determines the sign of the discount term?

The factor e−∫tTc dse^{-\int_t^T c\,ds} corresponds to −cu-cu in the backward PDE. Changing one sign requires changing the other.

Does the terminal payoff need to be smooth?

Not necessarily. Vanilla option payoffs have kinks. Classical smoothness can hold before maturity through diffusion smoothing, while viscosity or weak solutions handle less regular data.

Does Feynman-Kac apply to nonlinear PDEs?

The classical expectation formula applies to linear PDEs. Semilinear and fully nonlinear equations need nonlinear generalisations such as BSDE or stochastic-control representations.

When should a quant use PDE rather than Monte Carlo?

PDE methods are attractive for a few Markov state variables and a full value surface. Monte Carlo scales better in dimension and for many path-dependent claims. Feynman-Kac says what they target, not which algorithm is cheaper.

Skip the £25k programme - try the alternative

Master's programmes are slow and expensive. Quantt is a self-paced alternative. Start free with a real lesson and interview practice, then unlock 50+ courses and your personalised plan.

Free to start · No credit card required