The Feynman–Kac Formula¶
The Feynman–Kac formula is one of the most profound results connecting stochastic differential equations to partial differential equations. It provides a probabilistic representation of solutions to parabolic PDEs and serves as the mathematical foundation for option pricing, risk-neutral valuation, and countless applications in physics and engineering.
Motivation: Why Connect SDEs and PDEs?¶
Two fundamental perspectives exist for studying diffusion processes:
- Probabilistic (SDE): Sample paths, expectations, distributions
- Analytical (PDE): Deterministic equations for expected values
The Feynman–Kac formula bridges these perspectives:
Why this matters:
- Numerical methods: Monte Carlo (SDE) vs finite differences (PDE)
- Intuition: Probabilistic interpretation of PDE solutions
- Finance: Risk-neutral pricing as an expectation
- Physics: Path integral formulation of quantum mechanics
The Classical Feynman–Kac Formula¶
Setting¶
Consider the SDE:
on the interval \([t, T]\), where \(X_t = x\) is the initial condition at time \(t\).
Theorem (Feynman–Kac)¶
Let \(u(t, x)\) be a solution to the parabolic PDE:
with terminal condition:
Under suitable regularity conditions, \(u\) has the probabilistic representation:
Special Cases¶
Case 1: No discounting, no source (\(r = 0\), \(f = 0\))
Case 2: Constant discounting ($r = $ const, \(f = 0\))
Case 3: Killing/discounting only (\(f = 0\))
Proof Sketch¶
Step 1: Define the process
Step 2: Apply Itô's lemma to \(e^{-\int_t^s r\,d\tau} u(s, X_s)\):
where by Itô's lemma:
Step 3: Substitute the PDE (which says the bracketed term equals \(ru - f\)):
Step 4: Therefore \(Y_s\) is a martingale (the \(-f\) term cancels with the integral term).
Step 5: By the martingale property:
\(\square\)
The Converse: From Expectation to PDE¶
Theorem (Converse Feynman–Kac): Define
Under suitable regularity (e.g., \(g\) bounded continuous, coefficients Lipschitz), \(u\) is a viscosity solution (and under stronger conditions, a classical solution) to:
where \(\mathcal{L}\) is the generator of \(X_t\).
Connection to the Infinitesimal Generator¶
The PDE in Feynman–Kac can be written compactly as:
where the infinitesimal generator is:
Interpretation:
- \(\frac{\partial u}{\partial t}\): Time evolution
- \(\mathcal{L}u\): Spatial diffusion (drift + volatility)
- \(-ru\): Discounting/killing
- \(f\): Source/running payoff
Application 1: Black–Scholes Option Pricing¶
Setup¶
Under the risk-neutral measure \(\mathbb{Q}\), the stock price follows:
where \(r\) is the risk-free rate.
European Call Option¶
The call option with strike \(K\) and maturity \(T\) has payoff \(g(S) = (S - K)^+\).
By Feynman–Kac, the price \(V(t, S)\) satisfies:
with \(V(T, S) = (S - K)^+\).
Probabilistic representation:
Explicit solution (Black–Scholes formula):
where:
Application 2: Bond Pricing with Stochastic Interest Rates¶
Vasicek Model¶
The short rate follows:
Zero-Coupon Bond¶
The price of a zero-coupon bond paying \(1\) at maturity \(T\) is:
By Feynman–Kac, \(P\) satisfies:
with \(P(T, r) = 1\).
Explicit solution:
where \(A\) and \(B\) are deterministic functions (affine term structure).
Application 3: Expected Exit Time (Boundary Value Problem)¶
Problem¶
For Brownian motion \(X_t = W_t\) starting at \(x \in (a, b)\), find the expected exit time:
Feynman–Kac Formulation¶
The function \(u(x)\) satisfies:
where \(\mathcal{L} = \frac{1}{2}\frac{d^2}{dx^2}\) for Brownian motion.
PDE:
Solution:
Interpretation: Maximum expected exit time at the midpoint \((a+b)/2\).
Multidimensional Feynman–Kac¶
For an \(\mathbb{R}^d\)-valued diffusion:
The Feynman–Kac PDE becomes:
where \(a^{ij} = \sigma^{i\alpha}\sigma^{j\alpha}\) is the diffusion matrix.
Numerical Methods: Monte Carlo vs PDE¶
The Feynman–Kac formula enables two numerical approaches:
Monte Carlo (SDE-based)¶
- Simulate \(N\) paths of \(X_t\)
- Compute average of \(e^{-\int r\,ds} g(X_T)\)
- Estimate: \(\hat{u} = \frac{1}{N}\sum_{i=1}^N e^{-\int_t^T r(s, X_s^{(i)})\,ds} g(X_T^{(i)})\)
Advantages: High dimensions, complex payoffs, path-dependent options
Disadvantages: Slow convergence (\(O(1/\sqrt{N})\)), variance reduction needed
Finite Differences (PDE-based)¶
- Discretize the PDE on a grid
- Solve backward from terminal condition
- Interpolate to get \(u(t, x)\)
Advantages: Fast for low dimensions, all option values at once
Disadvantages: Curse of dimensionality, complex boundaries difficult
Regularity Conditions¶
The Feynman–Kac formula requires:
- Coefficients: \(\mu, \sigma, r\) are continuous, satisfy linear growth
- Terminal condition: \(g\) is continuous with polynomial growth
- Source term: \(f\) is continuous with polynomial growth
- Ellipticity: \(\sigma^2(t, x) > 0\) (uniform ellipticity for classical solutions)
Without ellipticity: The PDE may have only viscosity solutions, not classical solutions.
Historical Note¶
The formula is named after:
- Richard Feynman (1918–1988): Developed path integral formulation of quantum mechanics
- Mark Kac (1914–1984): Proved the rigorous mathematical connection
Feynman's insight: Quantum mechanical propagators can be represented as integrals over all possible paths. Kac made this rigorous using Brownian motion and showed the connection to parabolic PDEs.
Summary¶
| Component | PDE Term | Probabilistic Meaning |
|---|---|---|
| Generator \(\mathcal{L}\) | Drift + diffusion | Expected local change |
| \(-ru\) | Discounting | Killing/interest rate |
| \(f\) | Source term | Running payoff |
| \(g(x)\) | Terminal condition | Final payoff |
The Feynman–Kac formula is the fundamental bridge between stochastic analysis and partial differential equations.
QuantPie Derivation¶
Proof via Martingale Methods¶
Define the process:
where \(u\) solves the PDE:
Applying Itô's Lemma to the first term:
Computing \(dY\):
The bracketed term equals zero by the PDE, leaving only the martingale part:
Therefore \(Y(s)\) is a martingale:
Examples: Diffusion Equations¶
Example 1: Pure Diffusion (No Drift, No Discounting)
Stochastic process: \(dX = \sigma dB_t\)
Solution by Feynman-Kac:
Example 2: Diffusion with Drift
Stochastic process: \(dX = \mu dt + \sigma dB_t\)
Solution:
Key Insight¶
The Feynman-Kac formula shows that solving the PDE is equivalent to computing an expectation. This opens two computational paths:
- Analytical: Solve the PDE directly (finite differences, separation of variables)
- Probabilistic: Simulate the SDE and average payoffs (Monte Carlo)
Each approach has advantages depending on dimensionality and problem structure.
Exercises¶
Exercise 1. State the Feynman-Kac formula for the special case \(r = 0\), \(f = 0\). Write the PDE and its probabilistic representation. For the SDE \(dX_s = \sigma\,dW_s\) with \(g(x) = x^4\), compute \(u(t, x) = \mathbb{E}[X_T^4 | X_t = x]\) and verify your answer satisfies the PDE.
Solution to Exercise 1
With \(r = 0\) and \(f = 0\), the Feynman-Kac formula reduces to:
PDE: \(\frac{\partial u}{\partial t} + \frac{1}{2}\sigma^2(t,x)\frac{\partial^2 u}{\partial x^2} = 0\) (using \(\mu = 0\) for \(dX_s = \sigma\,dW_s\))
Probabilistic representation: \(u(t, x) = \mathbb{E}[g(X_T) \mid X_t = x]\)
For \(g(x) = x^4\) and \(dX_s = \sigma\,dW_s\), we have \(X_T = x + \sigma(W_T - W_t)\). Let \(Z = W_T - W_t \sim N(0, T-t)\).
Expanding via the binomial theorem and using \(\mathbb{E}[Z] = 0\), \(\mathbb{E}[Z^2] = T - t\), \(\mathbb{E}[Z^3] = 0\), and \(\mathbb{E}[Z^4] = 3(T-t)^2\):
Verification: \(u_t = -6x^2\sigma^2 - 6\sigma^4(T - t)\), \(u_{xx} = 12x^2 + 12\sigma^2(T - t)\). Then:
Exercise 2. In the proof of the Feynman-Kac formula, the process \(Y_s = e^{-\int_t^s r\,d\tau}u(s, X_s)\) is shown to be a martingale when \(f = 0\). Explain which step in the proof ensures the \(ds\) term vanishes, and why the Ito correction from the exponential and from \(u(s, X_s)\) must both be accounted for.
Solution to Exercise 2
In the proof, we define \(Y_s = e^{-\int_t^s r\,d\tau}u(s, X_s)\) and apply Ito's lemma to obtain:
The step that ensures the \(ds\) term vanishes is Step 3 / Step 4: we substitute the PDE \(\partial_t u + \mathcal{L}u - r\,u = 0\) into the bracketed expression. The Ito lemma on \(u(s, X_s)\) produces the terms \(\partial_s u + \mu\,u_x + \frac{1}{2}\sigma^2\,u_{xx}\), which equals \(\partial_s u + \mathcal{L}u\). The product rule with the exponential discount factor \(e^{-\int r\,d\tau}\) contributes the \(-r\,u\) term.
Both corrections must be accounted for:
- The Ito correction from \(u(s, X_s)\): the term \(\frac{1}{2}\sigma^2 u_{xx}\) arises from the quadratic variation of \(X_s\).
- The correction from the exponential: \(d(e^{-\int_t^s r\,d\tau}) = -r\,e^{-\int_t^s r\,d\tau}\,ds\) contributes the \(-r\,u\) factor.
Together, the drift of \(Y_s\) is \(e^{-\int r\,d\tau}(\partial_s u + \mathcal{L}u - r\,u) = 0\) by the PDE, leaving only the martingale part.
Exercise 3. For the expected exit time problem with \(\mathcal{L} = \frac{1}{2}\frac{d^2}{dx^2}\), \(a = 0\), \(b = 1\), verify that \(u(x) = x(1-x)\) satisfies \(\frac{1}{2}u''(x) = -1\) with \(u(0) = u(1) = 0\). What is the maximum expected exit time and where is it achieved?
Solution to Exercise 3
With \(a = 0\), \(b = 1\), we need \(u(x) = x(1-x)\) to satisfy \(\frac{1}{2}u''(x) = -1\) with \(u(0) = u(1) = 0\).
Boundary conditions: \(u(0) = 0 \cdot 1 = 0\) \(\checkmark\), \(u(1) = 1 \cdot 0 = 0\) \(\checkmark\).
PDE: \(u'(x) = 1 - 2x\), \(u''(x) = -2\). Therefore:
Maximum expected exit time: Since \(u(x) = x(1-x) = -(x - 1/2)^2 + 1/4\) is a downward-opening parabola, the maximum is at \(x = 1/2\) with value \(u(1/2) = 1/4\).
The maximum expected exit time is \(1/4\), achieved at the midpoint \(x = 1/2\) of the interval \([0, 1]\). This makes intuitive sense: starting at the center maximizes the distance to both boundaries, so the Brownian motion takes the longest (in expectation) to exit.
Exercise 4. Consider the converse Feynman-Kac theorem: define \(u(t,x) = \mathbb{E}[e^{-r(T-t)}g(X_T) | X_t = x]\) where \(dX_s = \mu X_s\,ds + \sigma X_s\,dW_s\) (geometric Brownian motion) and \(g(x) = (x - K)^+\). Write the PDE that \(u\) satisfies without solving it explicitly. This is the Black-Scholes PDE.
Solution to Exercise 4
For geometric Brownian motion \(dX_s = \mu X_s\,ds + \sigma X_s\,dW_s\), the infinitesimal generator is:
By the converse Feynman-Kac theorem, \(u(t, x) = \mathbb{E}[e^{-r(T-t)}(X_T - K)^+ \mid X_t = x]\) satisfies:
with terminal condition \(u(T, x) = (x - K)^+\).
Under risk-neutral pricing where \(\mu = r\) (the drift equals the risk-free rate), this becomes the Black-Scholes PDE:
Exercise 5. For the multidimensional Feynman-Kac formula with two assets \(X_t = (S_t^1, S_t^2)\), write the generator \(\mathcal{L}\) in terms of the drift vector \((\mu^1, \mu^2)\), the diffusion matrix \(a^{ij} = \sum_\alpha \sigma^{i\alpha}\sigma^{j\alpha}\), and partial derivatives. Identify the cross-derivative term \(a^{12}\partial^2 u / \partial x^1 \partial x^2\) and explain its financial significance.
Solution to Exercise 5
For two correlated assets, the diffusion matrix has entries \(a^{ij} = \sum_\alpha \sigma^{i\alpha}\sigma^{j\alpha}\). The generator is:
where the diagonal terms are \(a^{11} = \sum_\alpha (\sigma^{1\alpha})^2\) and \(a^{22} = \sum_\alpha (\sigma^{2\alpha})^2\), and the cross term is \(a^{12} = \sum_\alpha \sigma^{1\alpha}\sigma^{2\alpha}\).
In financial terms, if \(S^1\) and \(S^2\) are two stock prices with volatilities \(\sigma_1\), \(\sigma_2\) and correlation \(\rho\), then \(a^{11} = \sigma_1^2 (S^1)^2\), \(a^{22} = \sigma_2^2 (S^2)^2\), and \(a^{12} = \rho\sigma_1\sigma_2 S^1 S^2\).
Financial significance of the cross-derivative term: The term \(a^{12}\frac{\partial^2 u}{\partial x^1 \partial x^2} = \rho\sigma_1\sigma_2 S^1 S^2\frac{\partial^2 u}{\partial S^1 \partial S^2}\) captures the effect of correlation between the two assets on the derivative price. When \(\rho > 0\), the assets tend to move together, and this cross-sensitivity (sometimes called "cross-gamma") measures how the option value changes when both assets move simultaneously. For products like spread options, basket options, or quanto options, this correlation term is crucial and cannot be ignored.
Exercise 6. Compare Monte Carlo and finite difference methods for computing the Feynman-Kac solution. For a European call option in the Black-Scholes model (\(d = 1\)), explain why finite differences are efficient. For a basket option on \(d = 10\) stocks, explain why Monte Carlo is preferred. What is the "curse of dimensionality"?
Solution to Exercise 6
Monte Carlo: Justified by writing \(u(t,x) = \mathbb{E}[e^{-\int r\,ds}g(X_T) \mid X_t = x]\), we simulate \(N\) independent paths of the SDE, compute the discounted payoff for each, and average. The error is \(O(1/\sqrt{N})\) regardless of dimension.
Finite differences: Justified by the PDE \(\partial_t u + \mathcal{L}u - ru + f = 0\), we discretize on a grid and solve backward from the terminal condition. The cost grows as \(O(N_{\text{grid}}^d)\) where \(d\) is the spatial dimension.
European call (\(d = 1\)): Finite differences are efficient. A grid of \(N_S = 200\) stock prices and \(N_t = 100\) time steps gives \(20{,}000\) points, and the tridiagonal linear system is solved in \(O(N_S)\) per time step. The method provides the option value at every grid point simultaneously, which is useful for computing Greeks. Monte Carlo achieves comparable accuracy only with thousands of paths.
Basket option (\(d = 10\)): Monte Carlo is strongly preferred. A finite difference grid with \(N = 50\) points per dimension would require \(50^{10} \approx 10^{17}\) grid points, which is computationally impossible. Monte Carlo, however, remains feasible: simulating \(10^6\) paths of 10 correlated stocks is routine, with cost \(O(10^6 \times 10 \times N_t)\).
The curse of dimensionality refers to the exponential growth of grid-based methods with dimension \(d\). The number of grid points scales as \(N^d\), making PDE methods impractical for \(d \geq 4\). Monte Carlo avoids this curse because its convergence rate \(O(1/\sqrt{N})\) does not depend on \(d\).
Exercise 7. The Feynman-Kac formula requires regularity conditions including uniform ellipticity (\(\sigma^2(t,x) > 0\)). Explain what goes wrong at \(x = 0\) for the CEV model \(dX_t = \sigma X_t^{\beta}\,dW_t\) with \(\beta \in (0, 1)\), where \(\sigma^2(t,x) = \sigma^2 x^{2\beta}\) vanishes at the origin. What type of solution (classical or viscosity) can still be obtained?
Solution to Exercise 7
In the CEV model \(dX_t = \sigma X_t^{\beta}\,dW_t\) with \(\beta \in (0, 1)\), the diffusion coefficient is \(\sigma^2(t, x) = \sigma^2 x^{2\beta}\). At \(x = 0\), this vanishes: \(\sigma^2(t, 0) = 0\).
What goes wrong: The Feynman-Kac PDE is:
At \(x = 0\), the second-order term disappears entirely, and the PDE degenerates from parabolic to first-order (or trivial). This means:
- Loss of uniform ellipticity: The condition \(\sigma^2(t, x) \geq \epsilon > 0\) (required for classical regularity theory) fails at \(x = 0\).
- Ito's lemma may not apply classically: The proof of Feynman-Kac requires \(u \in C^{1,2}\), but the degenerate PDE may not admit \(C^{1,2}\) solutions. The second derivative \(u_{xx}\) may blow up near \(x = 0\) to compensate for the vanishing diffusion coefficient.
- Boundary behavior: For \(\beta \in (0, 1)\), the process \(X_t\) can reach zero, and the behavior at zero (absorption vs. reflection) must be specified, adding a boundary condition that the standard Feynman-Kac setup does not address.
Viscosity solutions: Even when classical (\(C^{1,2}\)) solutions do not exist, the function \(u(t, x) = \mathbb{E}[g(X_T) \mid X_t = x]\) is still well-defined as an expectation. It can be shown to be a viscosity solution of the degenerate PDE. Viscosity solutions require only continuity (not differentiability) and are defined through comparison with smooth test functions. Uniqueness of viscosity solutions can often be established even for degenerate equations, preserving the Feynman-Kac connection in a weaker but rigorous sense.