The Feynman–Kac theorem connects the solution of a parabolic PDE with an expectation over a diffusion process, under suitable regularity and integrability conditions. In option pricing, it links a pricing PDE to a discounted expected payoff. Below, we compare finite differences and Monte Carlo under the same Black–Scholes model.

There are two ways to price a European option, and they look nothing alike.

One is a **partial differential equation**: write down the Black-Scholes PDE, impose the payoff as a terminal condition, and integrate backwards through time on a grid. No randomness enters anywhere. It is deterministic numerical analysis.

The other is an **expectation**: simulate the stock under the risk-neutral measure, average the discounted payoff. No derivatives, no grid. It is probability.

Feynman-Kac is the theorem that says these are the same calculation.

The statement

Suppose u(t,x) solves the PDE

    \[\frac{\partial u}{\partial t} + \mu(x)\frac{\partial u}{\partial x} + \frac{1}{2}\sigma^2(x)\frac{\partial^2 u}{\partial x^2} - r\,u = 0\]

with terminal condition u(T,x) = g(x). Then

    \[u(t,x) = \mathbb{E}\left[e^{-r(T-t)}\,g(X_T)\;\middle|\;X_t = x\right]\]

where X follows dX_s = \mu(X_s)\,ds + \sigma(X_s)\,dW_s.

For a classical representation, take a well-posed diffusion, a sufficiently regular solution u\in C^{1,2} before maturity, and a payoff and discount rate for which the expectation is finite. The local martingale obtained by applying Itô’s formula to the discounted u must be a true martingale, or the localisation limit must be justified by suitable integrability. Uniqueness is within a stated growth class. A call payoff is not differentiable at the strike at maturity; this does not prevent interior regularity for the Black–Scholes problem. The abstract theorem applies under the measure driving the diffusion; choosing Q is a separate pricing-model step.

Read the correspondence term by term, because it is exact and it is the whole point:

In the PDE In the process
coefficient of \partial u/\partial x the drift \mu
coefficient of \frac{1}{2}\partial^2 u/\partial x^2 the variance \sigma^2
the -ru term discounting at rate r
terminal condition g the payoff

Every piece of the equation has a probabilistic counterpart. The second-order term becomes volatility, the first-order term becomes drift, and the zeroth-order term becomes a discount factor.

Watching it happen

Price a one-year at-the-money call two ways, with no shared code between them.

**The PDE route.** Crank-Nicolson on a 400-point grid in spot and 400 steps in time, marching backwards from the payoff. At no point does a random number appear.

**The expectation route.** Four million simulated paths, discounted payoffs averaged. At no point does a derivative appear.

Method Value
PDE, finite differences backwards in time 10.4481
\mathbb{E}^{\mathbb{Q}}, Monte Carlo 10.4393 ± 0.0144
Black-Scholes closed form 10.4506

The PDE lands within 0.0025 of the closed form; the Monte Carlo within 0.0113, comfortably inside its own two-standard-error band of 0.0144. Two distinct numerical implementations agree within their respective discretisation and sampling errors; they still share the same pricing model.

Why this is more than a curiosity

It is the bridge that makes derivatives pricing coherent, and three consequences follow directly.

**It explains why risk-neutral pricing works at all.** Black and Scholes derived a PDE from a hedging argument — build a delta-hedged portfolio, note it must earn the risk-free rate, and a PDE falls out. There is no probability in that derivation; it is pure replication. Feynman-Kac then tells you the solution to that PDE happens to be an expectation under a particular measure. **The expectation is a consequence of the hedging argument, not an assumption about anyone’s beliefs.** That is the answer to the perennial question of why we price under a measure nobody thinks is real.

**It helps compare numerical methods.** Monte Carlo avoids a full tensor grid, although path generation, payoff complexity and variance still determine its cost. A standard grid PDE becomes expensive as dimension grows. Early exercise requires an optimal-stopping or obstacle formulation; it is not covered by the terminal-payoff formula alone.

**And it works in reverse.** Given a process, you can write down the PDE its expectations satisfy — the backward Kolmogorov equation. That is how you get a PDE for a model defined by an SDE, and it is how affine models produce their Riccati ODEs.

Where the conditions bite

A strict local martingale can lead to non-uniqueness of the associated pricing PDE. The stochastic representation may select the minimal nonnegative solution, while another PDE solution satisfies the same terminal payoff. The expectation is not automatically “wrong”: the admissible growth class, boundary behaviour and financial interpretation must be specified. Failure of a sufficient condition alone does not prove that the representation fails.

The practical implication: if your PDE and your Monte Carlo disagree by more than simulation error, do not assume one of them has a bug. Check whether your model satisfies the conditions first.

Code

import numpy as np
from scipy.linalg import solve_banded

S0, K, r, sig, T = 100., 100., 0.05, 0.20, 1.0
Smax, J, N = 400., 400, 400
dt = T/N
Sg = np.linspace(0, Smax, J+1)
V  = np.maximum(Sg - K, 0.)              # terminal condition = the payoff
j  = np.arange(1, J)

A = 0.25*dt*(sig**2*j**2 - r*j)
B = -0.5*dt*(sig**2*j**2 + r)
C = 0.25*dt*(sig**2*j**2 + r*j)
ab = np.zeros((3, J-1))
ab[0, 1:] = -C[:-1]; ab[1, :] = 1 - B; ab[2, :-1] = -A[1:]

for n in range(N):                        # march backwards in time
    rhs = A*V[0:J-1] + (1+B)*V[1:J] + C*V[2:J+1]
    lo, hi = 0.0, Smax - K*np.exp(-r*(n+1)*dt)
    rhs[0] += A[0]*lo; rhs[-1] += C[-1]*hi
    V[1:J] = solve_banded((1, 1), ab, rhs)
    V[0], V[J] = lo, hi

print(f"PDE : {np.interp(S0, Sg, V):.4f}")

rng = np.random.default_rng(3); M = 4_000_000
ST = S0*np.exp((r - 0.5*sig**2)*T + sig*np.sqrt(T)*rng.standard_normal(M))
pay = np.exp(-r*T)*np.maximum(ST - K, 0)
print(f"MC  : {pay.mean():.4f} +/- {1.96*pay.std(ddof=1)/np.sqrt(M):.4f}")

These are different numerical implementations of the same model, payoff and boundary-value problem. Their agreement is a useful cross-check, but shared modelling or parameter errors can affect both. Validate each method against the Black–Scholes benchmark, refine the PDE grid and report Monte Carlo standard errors.

The takeaway

Feynman-Kac says a parabolic PDE and a discounted expectation are two descriptions of one object. The drift, the variance and the discount rate each appear in both, in exactly corresponding places.

It is what turns a hedging argument into a probability, what makes the choice between finite differences and Monte Carlo a question of efficiency rather than correctness, and why regularity, integrability and the admissible solution class must be checked before identifying the two representations.


The measure under which that expectation is taken is built by Girsanov’s theorem, and the second-order term in the PDE comes from Itô’s lemma.


Build the connection from Itô’s formula to Feynman–Kac and Black–Scholes in Stochastic Calculus. Explore the syllabus, executable notebooks and numerical validation exercises.


Get the Quant Reference Card — four pages covering stochastic calculus, measure change, the models you’ll meet, discretisation, rates, credit and XVA. Free.