Free boundaries & exotic pricing.
European options have closed forms. Add the right to exercise early and the pricing problem becomes a free-boundary PDE: you must solve simultaneously for the option value and for the region where holding it is still worth more than exercising. This page solves it live.
From SDE to PDE
Under Black-Scholes dynamics , Itô's lemma and delta-hedging give the pricing PDE
For a European payoff you integrate backwards from maturity and you're done. For an American option the holder may exercise at any time, so the value must additionally satisfy everywhere - a linear complementarity problem whose solution carves the plane into a continuation region and an exercise region, separated by the free boundary S*(t).
Numerics
The solver below discretises the PDE on a grid (implicit Euler in time, central differences in space, Thomas algorithm for the tridiagonal system) and enforces the early-exercise constraint by projection at each exercise date à la Brennan-Schwartz: solve the European step, then take . Projecting at every time step gives the American price; projecting at four dates gives a Bermudan; never projecting recovers Black-Scholes exactly - a built-in sanity check against the closed form.
What to look at
The heatmap is the option value; the red curve is the exercise boundary. Three things worth toggling: switch European → Bermudan → American and watch the boundary appear as isolated points, then a continuous curve, while the price at climbs - the early-exercise premium. Raise r and the boundary rises (deeper incentive to take the strike early); raise σ and it falls (optionality is worth waiting for).
The same machinery scaled up in the fixed-income project: Bermudan swaptions priced by deriving the PDE under a short-rate model via Itô, setting the exercise conditions at each date, and solving numerically - after building the zero-coupon curve and validating European swaption prices against Black's formula. The Monte Carlo side of the same toolbox - Euler vs Milstein convergence, Heston pricing, implied-vol smiles - has its own page.