Quant Sandbox
DerivativesPortfolio & RiskFixed IncomeCorporate FinanceStochastic ModelsGuide
Guide
Derivatives pricing
01Forwards, calls and puts02Combining positions03Arbitrage and the forward price04Put–call parity05The one-step binomial model06Risk-neutral probabilities07Multi-step trees and backward induction08American options and early exercise09Delta and hedging10Geometric Brownian motion11The Black–Scholes formula12The Greeks: gamma, vega, theta and rho13Implied volatility and the volatility smile14Stochastic volatility and the Heston model15Static replication: Breeden–Litzenberger and Carr–Madan16Exotic options: barriers, Asians and digitals
Portfolio & risk
01Returns and volatility02Diversification and correlation03The efficient frontier and the capital market line04Risk aversion and the optimal complete portfolio05CAPM, beta and the security market line06Performance measures: Sharpe, Treynor, Jensen and information ratio07Factor models and systematic risk08Value at Risk and expected shortfall
Fixed income
01Bond prices and yields02Duration and convexity03Immunization and duration matching04Spot rates, forward rates and the yield curve05Bond futures and the cheapest-to-deliver06Interest rate swaps07Callable bonds and negative convexity08Credit risk: default probabilities and credit spreads
Corporate finance
01Interest, compounding and discounting02Annuities, perpetuities and loan amortization03Net present value and internal rate of return04The weighted average cost of capital05Capital structure and the Modigliani–Miller theorems06Discounted cash flow valuation07Relative valuation with multiples08Real options: the value of flexibility
Stochastic models
01Random walks and Brownian motion02Probability spaces, σ-algebras and random variables03Filtrations, adapted processes and stopping times04Conditional expectation and martingales05Properties of Brownian motion06The reflection principle and first passage times07The Brownian bridge08The Itô integral09Itô's lemma10Kolmogorov equations and the Feynman–Kac formula11Change of measure and Girsanov's theorem12Monte Carlo option pricing13Simulating SDEs: the Euler–Maruyama scheme14Mean reversion: Ornstein–Uhlenbeck and Vasicek15Jumps and the Merton jump-diffusion model
Knowledge graph

© 2026 Quant Sandbox · A study aid for quantitative finance

Privacy & dataNo cookies

This site does not use cookies and asks for no personal data. It keeps a few small settings in your browser's local storage — your chosen theme and language, the sidebar layout, and your progress and answers in the Guides — so it remembers them on your next visit. This data never leaves your device; clearing your browser storage removes it. Inputs you change can also be captured in the page URL, so you can share or bookmark a specific setup. The site uses Vercel Web Analytics, a privacy-friendly, cookieless service that records only anonymous, aggregated usage (such as page views) without identifying you or tracking you across other sites.

Guide/Stochastic models

Kolmogorov equations and the Feynman–Kac formula

Lesson 10 of 15 · 1 min read

A price can be written as a discounted expectation, as in "Change of measure and Girsanov's theorem", or as the solution of a partial differential equation. This lesson proves that the two descriptions agree. It uses Itô's formula from "Itô's lemma", the martingale property of the integral from "The Itô integral" and conditional expectations from "Conditional expectation and martingales".

Diffusions and their generator

Let XXX solve the stochastic differential equation

dXs=μ(Xs) ds+σ(Xs) dWs,dX_s = \mu(X_s)\,ds + \sigma(X_s)\,dW_s,dXs​=μ(Xs​)ds+σ(Xs​)dWs​,

where WWW is a Brownian motion and the coefficients μ,σ:R→R\mu, \sigma : \mathbb{R} \to \mathbb{R}μ,σ:R→R are Lipschitz continuous. Under this assumption the equation has a unique solution for every starting point, and XXX is a Markov process: given XtX_tXt​, the future of XXX does not depend on the earlier path. Write Et,x[ ⋅ ]=E[ ⋅∣Xt=x]\mathbb{E}_{t,x}[\,\cdot\,] = \mathbb{E}[\,\cdot \mid X_t = x]Et,x​[⋅]=E[⋅∣Xt​=x].

The generator of XXX is the operator that gives the expected rate of change of f(X)f(X)f(X) at a point. For twice continuously differentiable fff with compact support,

Lf(x)=lim⁡h↓0E0,x[f(Xh)]−f(x)h.\mathcal{L}f(x) = \lim_{h \downarrow 0} \frac{\mathbb{E}_{0,x}[f(X_h)] - f(x)}{h}.Lf(x)=h↓0lim​hE0,x​[f(Xh​)]−f(x)​.

Itô's lemma computes it. Integrating df(Xs)df(X_s)df(Xs​) over [0,h][0, h][0,h],

f(Xh)=f(x)+∫0h(μf′+12σ2f′′)(Xs) ds+∫0hσ(Xs)f′(Xs) dWs.f(X_h) = f(x) + \int_0^h \Big(\mu f' + \tfrac12 \sigma^2 f''\Big)(X_s)\,ds + \int_0^h \sigma(X_s) f'(X_s)\,dW_s.f(Xh​)=f(x)+∫0h​(μf′+21​σ2f′′)(Xs​)ds+∫0h​σ(Xs​)f′(Xs​)dWs​.

The integrand σf′\sigma f'σf′ is bounded on the support of fff, so the Itô integral has mean zero. Taking expectations, dividing by hhh and letting h→0h \to 0h→0 (the dsdsds-integrand is continuous) gives

Lf(x)=μ(x) f′(x)+12 σ2(x) f′′(x).\mathcal{L}f(x) = \mu(x)\,f'(x) + \tfrac12\,\sigma^2(x)\,f''(x).Lf(x)=μ(x)f′(x)+21​σ2(x)f′′(x).

The drift contributes a first-derivative term and the diffusion a second-derivative term; the 12σ2\tfrac12\sigma^221​σ2 is the Itô correction. Examples: Brownian motion with volatility σ\sigmaσ has L=12σ2 ∂xx\mathcal{L} = \tfrac12\sigma^2\,\partial_{xx}L=21​σ2∂xx​; geometric Brownian motion under Q\mathbb{Q}Q has Lf=rx f′+12σ2x2f′′\mathcal{L}f = rx\,f' + \tfrac12\sigma^2 x^2 f''Lf=rxf′+21​σ2x2f′′. The same computation without the limit gives Dynkin's formula, E0,x[f(Xt)]=f(x)+E0,x[∫0tLf(Xs) ds]\mathbb{E}_{0,x}[f(X_t)] = f(x) + \mathbb{E}_{0,x}\big[\int_0^t \mathcal{L}f(X_s)\,ds\big]E0,x​[f(Xt​)]=f(x)+E0,x​[∫0t​Lf(Xs​)ds].

The Kolmogorov backward equation

Fix a horizon TTT and a payoff function ggg, and define v(t,x)=Et,x[g(XT)]v(t, x) = \mathbb{E}_{t,x}[g(X_T)]v(t,x)=Et,x​[g(XT​)]. By the Markov property, v(s,Xs)=E[g(XT)∣Fs]v(s, X_s) = \mathbb{E}[g(X_T) \mid \mathcal{F}_s]v(s,Xs​)=E[g(XT​)∣Fs​] for t≤s≤Tt \le s \le Tt≤s≤T, so s↦v(s,Xs)s \mapsto v(s, X_s)s↦v(s,Xs​) is a martingale. If vvv is once differentiable in ttt and twice in xxx, Itô's lemma gives

dv(s,Xs)=(∂sv+Lv)(s,Xs) ds+σ(Xs) ∂xv(s,Xs) dWs.dv(s, X_s) = \big(\partial_s v + \mathcal{L}v\big)(s, X_s)\,ds + \sigma(X_s)\,\partial_x v(s, X_s)\,dW_s.dv(s,Xs​)=(∂s​v+Lv)(s,Xs​)ds+σ(Xs​)∂x​v(s,Xs​)dWs​.

A continuous martingale whose dsdsds-part is not identically zero cannot exist, since a process of finite variation that is also a continuous martingale is constant. So the dsdsds-term must vanish, which gives the Kolmogorov backward equation

∂tv+Lv=0on [0,T)×R,v(T,x)=g(x).\partial_t v + \mathcal{L}v = 0 \quad \text{on } [0, T) \times \mathbb{R}, \qquad v(T, x) = g(x).∂t​v+Lv=0on [0,T)×R,v(T,x)=g(x).

It runs backwards: the terminal condition is given at TTT and the equation is solved towards t=0t = 0t=0. If XXX has a transition density p(t,x;T,y)p(t, x; T, y)p(t,x;T,y), that density solves the backward equation in (t,x)(t, x)(t,x), and in the forward variables (T,y)(T, y)(T,y) it solves the Kolmogorov forward (Fokker–Planck) equation

∂Tp=−∂y(μ(y) p)+12 ∂yy(σ2(y) p).\partial_T p = -\partial_y\big(\mu(y)\,p\big) + \tfrac12\,\partial_{yy}\big(\sigma^2(y)\,p\big).∂T​p=−∂y​(μ(y)p)+21​∂yy​(σ2(y)p).

The backward equation describes how an expected payoff depends on the starting point; the forward equation describes how probability mass spreads out from a fixed starting point.

The Feynman–Kac theorem

Add a discount rate r(x)≥0r(x) \ge 0r(x)≥0, continuous. Theorem (Feynman–Kac). Let μ,σ\mu, \sigmaμ,σ be Lipschitz and let u(t,x)u(t, x)u(t,x), once continuously differentiable in ttt and twice in xxx, solve

∂tu+μ(x) ∂xu+12σ2(x) ∂xxu−r(x) u=0on [0,T)×R,u(T,x)=g(x).\partial_t u + \mu(x)\,\partial_x u + \tfrac12\sigma^2(x)\,\partial_{xx} u - r(x)\,u = 0 \quad \text{on } [0, T) \times \mathbb{R}, \qquad u(T, x) = g(x).∂t​u+μ(x)∂x​u+21​σ2(x)∂xx​u−r(x)u=0on [0,T)×R,u(T,x)=g(x).

Assume also that Et,x[∫tT(σ(Xs) ∂xu(s,Xs))2ds]<∞\mathbb{E}_{t,x}\big[\int_t^T \big(\sigma(X_s)\,\partial_x u(s, X_s)\big)^2 ds\big] < \inftyEt,x​[∫tT​(σ(Xs​)∂x​u(s,Xs​))2ds]<∞, which holds, for example, if σ ∂xu\sigma\,\partial_x uσ∂x​u is bounded. Then

u(t,x)=Et,x ⁣[e−∫tTr(Xs) ds g(XT)].u(t, x) = \mathbb{E}_{t,x}\!\left[ e^{-\int_t^T r(X_s)\,ds}\, g(X_T) \right].u(t,x)=Et,x​[e−∫tT​r(Xs​)dsg(XT​)].

Proof. Fix (t,x)(t, x)(t,x) and set Ds=e−∫tsr(Xv) dvD_s = e^{-\int_t^s r(X_v)\,dv}Ds​=e−∫ts​r(Xv​)dv and Ys=Ds u(s,Xs)Y_s = D_s\,u(s, X_s)Ys​=Ds​u(s,Xs​) for s∈[t,T]s \in [t, T]s∈[t,T]. The factor DDD has finite variation, dDs=−r(Xs) Ds dsdD_s = -r(X_s)\,D_s\,dsdDs​=−r(Xs​)Ds​ds, so the product rule has no cross term. With Itô's lemma for u(s,Xs)u(s, X_s)u(s,Xs​),

dYs=Ds(∂su+Lu−ru)(s,Xs) ds+Ds σ(Xs) ∂xu(s,Xs) dWs=Ds σ(Xs) ∂xu(s,Xs) dWs.dY_s = D_s\big(\partial_s u + \mathcal{L}u - r u\big)(s, X_s)\,ds + D_s\,\sigma(X_s)\,\partial_x u(s, X_s)\,dW_s = D_s\,\sigma(X_s)\,\partial_x u(s, X_s)\,dW_s.dYs​=Ds​(∂s​u+Lu−ru)(s,Xs​)ds+Ds​σ(Xs​)∂x​u(s,Xs​)dWs​=Ds​σ(Xs​)∂x​u(s,Xs​)dWs​.

The dsdsds-term is zero because uuu solves the equation. Since 0<Ds≤10 < D_s \le 10<Ds​≤1, the integrability assumption makes YYY an Itô integral of an L2\mathcal{L}^2L2 integrand, hence a martingale. Therefore u(t,x)=Yt=Et,x[YT]=Et,x[DT g(XT)]u(t, x) = Y_t = \mathbb{E}_{t,x}[Y_T] = \mathbb{E}_{t,x}\big[D_T\,g(X_T)\big]u(t,x)=Yt​=Et,x​[YT​]=Et,x​[DT​g(XT​)], using u(T,⋅)=gu(T, \cdot) = gu(T,⋅)=g. □\square□

The proof also shows uniqueness: two solutions in the integrability class equal the same expectation. The converse direction, that the expectation is smooth enough to solve the equation, needs more, for example smooth coefficients and σ\sigmaσ bounded away from zero; under such conditions the expectation is the solution. Think of u(s,Xs)u(s, X_s)u(s,Xs​) as a fair value carried along the path: discounted, it neither drifts up nor down, so its value today is the expected discounted value at maturity.

Feynman–Kac: the solution of ∂tu+Lu−ru=0\partial_t u + \mathcal{L}u - ru = 0∂t​u+Lu−ru=0, u(T,⋅)=gu(T, \cdot) = gu(T,⋅)=g, is u(t,x)=Et,x[e−∫tTr(Xs)dsg(XT)]u(t, x) = \mathbb{E}_{t,x}\big[e^{-\int_t^T r(X_s)ds} g(X_T)\big]u(t,x)=Et,x​[e−∫tT​r(Xs​)dsg(XT​)]. The proof is Itô's lemma plus the fact that a dWdWdW-integral is a martingale.

The heat equation

Take μ=0\mu = 0μ=0, constant σ\sigmaσ and r=0r = 0r=0. Then XT=x+σ(WT−Wt)X_T = x + \sigma(W_T - W_t)XT​=x+σ(WT​−Wt​), and with the time to maturity τ=T−t\tau = T - tτ=T−t the theorem reads

∂τu=12σ2 ∂xxu,u(0,x)=g(x)⟹u(τ,x)=E[g(x+σWτ)]=∫Rg(y) 12πσ2τ e−(y−x)22σ2τ dy.\partial_\tau u = \tfrac12\sigma^2\,\partial_{xx} u, \quad u(0, x) = g(x) \qquad \Longrightarrow \qquad u(\tau, x) = \mathbb{E}\big[g(x + \sigma W_\tau)\big] = \int_{\mathbb{R}} g(y)\,\frac{1}{\sqrt{2\pi\sigma^2\tau}}\,e^{-\frac{(y - x)^2}{2\sigma^2\tau}}\,dy.∂τ​u=21​σ2∂xx​u,u(0,x)=g(x)⟹u(τ,x)=E[g(x+σWτ​)]=∫R​g(y)2πσ2τ​1​e−2σ2τ(y−x)2​dy.

This is the heat equation, and the solution is the payoff smoothed by a Gaussian kernel of variance σ2τ\sigma^2\tauσ2τ. Differentiating the kernel confirms that it solves the equation. Three payoffs have closed forms, with s=στs = \sigma\sqrt{\tau}s=στ​ and d=(x−1)/sd = (x - 1)/sd=(x−1)/s:

  • Square, g(x)=x2g(x) = x^2g(x)=x2: u=x2+σ2τu = x^2 + \sigma^2\tauu=x2+σ2τ. Check: ∂τu=σ2\partial_\tau u = \sigma^2∂τ​u=σ2 and 12σ2 ∂xxu=12σ2⋅2=σ2\tfrac12\sigma^2\,\partial_{xx}u = \tfrac12\sigma^2 \cdot 2 = \sigma^221​σ2∂xx​u=21​σ2⋅2=σ2.
  • Digital, g(x)=1{x>1}g(x) = \mathbf{1}\{x > 1\}g(x)=1{x>1}: u=Φ(d)u = \Phi(d)u=Φ(d), the probability that x+σWτx + \sigma W_\taux+σWτ​ ends above 1.
  • Call, g(x)=(x−1)+g(x) = (x - 1)^+g(x)=(x−1)+: u=(x−1) Φ(d)+s φ(d)u = (x - 1)\,\Phi(d) + s\,\varphi(d)u=(x−1)Φ(d)+sφ(d), the Bachelier price with zero interest.

Worked numbers at x=1x = 1x=1 with τ=0.5\tau = 0.5τ=0.5 and σ=1\sigma = 1σ=1, so s=0.5≈0.7071s = \sqrt{0.5} \approx 0.7071s=0.5​≈0.7071 and d=0d = 0d=0: the call is worth s φ(0)=0.7071×0.3989≈0.2821s\,\varphi(0) = 0.7071 \times 0.3989 \approx 0.2821sφ(0)=0.7071×0.3989≈0.2821, the digital Φ(0)=0.5\Phi(0) = 0.5Φ(0)=0.5, the square 1+0.5=1.51 + 0.5 = 1.51+0.5=1.5. A Monte Carlo estimate from 2000 draws of WτW_\tauWτ​ has standard error equal to the payoff's standard deviation over 2000\sqrt{2000}2000​: about 0.4128/44.72≈0.00920.4128/44.72 \approx 0.00920.4128/44.72≈0.0092 for the call, 0.5/44.72≈0.01120.5/44.72 \approx 0.01120.5/44.72≈0.0112 for the digital and 2.5/44.72≈0.0354\sqrt{2.5}/44.72 \approx 0.03542.5​/44.72≈0.0354 for the square.

The figure solves this heat equation for the chosen payoff: call (x−1)+(x - 1)^+(x−1)+, digital 1{x>1}\mathbf{1}\{x > 1\}1{x>1} or square x2x^2x2. Against xxx from −2-2−2 to 444 it plots the payoff ggg (dashed), the exact solution u(τ,x)u(\tau, x)u(τ,x) from the Gaussian integral (line), and Monte Carlo estimates at 13 points xxx from 2000 draws each (dots). Increase τ\tauτ or σ\sigmaσ and note that the kink of the call and the jump of the digital are smoothed out more, while the square is shifted up by σ2τ\sigma^2\tauσ2τ. The dots stay on the line within sampling noise. The readouts at x=1x = 1x=1 give the exact uuu, the Monte Carlo estimate and its standard error.

PDE solution and Monte CarloOpen in Black–Scholes →
0.50
0.052
1.00
0.21.5
Payoff g(x)Exact u(τ, x)Monte Carlo (2000 draws)
Exact u at x = 1
0.2821
Monte Carlo at x = 1
0.3025
Standard error
0.0095

The Black–Scholes equation

By "Change of measure and Girsanov's theorem", under Q\mathbb{Q}Q the stock follows dSs=rSs ds+σSs dW~sdS_s = rS_s\,ds + \sigma S_s\,d\tilde W_sdSs​=rSs​ds+σSs​dW~s​ with constant rrr and σ\sigmaσ, and the price of a payoff g(ST)g(S_T)g(ST​) is V(t,S)=Et,SQ[e−r(T−t)g(ST)]V(t, S) = \mathbb{E}^{\mathbb{Q}}_{t,S}\big[e^{-r(T - t)} g(S_T)\big]V(t,S)=Et,SQ​[e−r(T−t)g(ST​)]. This is a Feynman–Kac expectation with μ(S)=rS\mu(S) = rSμ(S)=rS, σ(S)=σS\sigma(S) = \sigma Sσ(S)=σS and constant discount rate rrr, so VVV solves the Black–Scholes equation

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

For a call, g(S)=(S−K)+g(S) = (S - K)^+g(S)=(S−K)+, and the expectation is the formula of "The Black–Scholes formula". The real-world drift μ\muμ does not appear anywhere, because the generator is taken under Q\mathbb{Q}Q. The substitution x=ln⁡Sx = \ln Sx=lnS turns the generator into (r−12σ2) ∂x+12σ2 ∂xx(r - \tfrac12\sigma^2)\,\partial_x + \tfrac12\sigma^2\,\partial_{xx}(r−21​σ2)∂x​+21​σ2∂xx​, which has constant coefficients; after removing the drift and the discounting the equation becomes the heat equation, which is why the Black–Scholes formula is built from the normal CDF N(⋅)N(\cdot)N(⋅).

Numerical check with S=K=100S = K = 100S=K=100, r=5%r = 5\%r=5%, σ=20%\sigma = 20\%σ=20%, T=1T = 1T=1: the call price is C=10.4506C = 10.4506C=10.4506 with Δ=N(d1)=0.6368\Delta = N(d_1) = 0.6368Δ=N(d1​)=0.6368, Γ=0.018762\Gamma = 0.018762Γ=0.018762 and ∂C/∂t=−6.4140\partial C/\partial t = -6.4140∂C/∂t=−6.4140. The terms of the equation are −6.4140+3.1842+3.7524−0.5225=0.0001-6.4140 + 3.1842 + 3.7524 - 0.5225 = 0.0001−6.4140+3.1842+3.7524−0.5225=0.0001, zero up to rounding.

Two ways to compute one number

Feynman–Kac gives two routes to the same price. The Monte Carlo route simulates many paths of XXX under Q\mathbb{Q}Q, averages the discounted payoffs and reports a standard error that falls like 1/N1/\sqrt{N}1/N​ in the number of paths, whatever the dimension of XXX. The PDE route discretises xxx and ttt on a grid and steps the equation backwards from u(T,⋅)=gu(T, \cdot) = gu(T,⋅)=g with finite differences; one solve gives uuu at every grid point, and the Greeks come from differences of neighbouring values, but the grid grows exponentially with the dimension of XXX. In practice PDE methods dominate for one to three state variables and Monte Carlo for more. Any difference between the two answers is numerical error, sampling error on one side and grid error on the other, not a difference in the model.

Summary

  • A diffusion dX=μ(X) ds+σ(X) dWdX = \mu(X)\,ds + \sigma(X)\,dWdX=μ(X)ds+σ(X)dW has generator Lf=μf′+12σ2f′′\mathcal{L}f = \mu f' + \tfrac12\sigma^2 f''Lf=μf′+21​σ2f′′, computed from Itô's lemma.
  • v(t,x)=Et,x[g(XT)]v(t, x) = \mathbb{E}_{t,x}[g(X_T)]v(t,x)=Et,x​[g(XT​)] solves the Kolmogorov backward equation ∂tv+Lv=0\partial_t v + \mathcal{L}v = 0∂t​v+Lv=0, v(T,⋅)=gv(T, \cdot) = gv(T,⋅)=g; transition densities solve the forward equation in (T,y)(T, y)(T,y).
  • Feynman–Kac: the solution of ∂tu+Lu−ru=0\partial_t u + \mathcal{L}u - ru = 0∂t​u+Lu−ru=0, u(T,⋅)=gu(T, \cdot) = gu(T,⋅)=g, is the discounted expectation of g(XT)g(X_T)g(XT​). Proof: the discounted value e−∫ru(s,Xs)e^{-\int r}u(s, X_s)e−∫ru(s,Xs​) has no drift, so it is a martingale.
  • With μ=0\mu = 0μ=0, constant σ\sigmaσ and r=0r = 0r=0 it is the heat equation, solved by Gaussian smoothing of the payoff. Under Q\mathbb{Q}Q with GBM it is the Black–Scholes equation.
  • Monte Carlo and finite-difference pricing compute the same number from the two sides of the theorem.

The next lesson, "Monte Carlo option pricing", takes the expectation side: it simulates terminal prices under Q\mathbb{Q}Q and studies the standard error of the average.

Try itExplore how the solution of the Black–Scholes equation depends on S, σ and T in the Black–Scholes lab →
3 questions on this lesson at the end of the series →
← PreviousItô's lemmaNext →Change of measure and Girsanov's theorem
Connections
Kolmogorov equations and the Feynman–Kac…
Open the full graph →
Labs for this lesson
Black–ScholesMonte Carlo