Implicit Scheme and Crank-Nicolson for the BS PDE

Medium  finite-difference-methods · Module 2 · ~30 min
Cell 1 — Shared utilities: BS analytic, Thomas algorithm, θ-scheme solver
Foundation cell: Black-Scholes closed form for benchmarking, the Thomas algorithm tridiagonal solver (O(M) per call), and the general θ-scheme PDE solver on the log-price grid. The same solver handles explicit (θ=0), fully implicit (θ=1), and Crank-Nicolson (θ=0.5) by switching the theta parameter.
Run cell to see output.
Not run
Cell 2 — Pricing accuracy: implicit vs CN vs BS analytic over a spot ladder
Price a European call across a spot ladder S ∈ {80, 90, 100, 110, 120} using both the implicit and CN schemes, and compare to the BS closed form. Confirms that both schemes produce sub-0.001 errors for M=100, N=100 — well inside acceptable production tolerance.
Run cell to see output.
Not run
Cell 3 — Convergence order: log-log error vs Δτ (implicit ≈ 1, CN ≈ 2)
Fix the spatial grid (M=200) and vary N = {10, 20, 40, 80, 160, 320}. Plot |price − BS_analytic| vs Δτ = T/N on a log-log scale. The implicit scheme should show slope ≈ 1 (O(Δτ)); Crank-Nicolson should show slope ≈ 2 (O(Δτ²)).
Expected result: When you halve Δτ, the implicit error halves; the CN error quarters. The log-log slopes will be approximately −1 and −2 respectively.
Run cell to see output.
Not run
Cell 4 — CN oscillations: digital call with and without Rannacher smoothing
Price a digital call (pays $1 if ST > K) using pure CN and CN with 2 Rannacher smoothing steps. Print the option value at nodes near K and compute the maximum absolute oscillation in delta across nodes near the kink. Demonstrates that Rannacher smoothing suppresses the oscillations.
Expected result: Without Rannacher, delta near the strike oscillates wildly (alternating positive and large-negative values). With 2 Rannacher steps, the oscillations are suppressed and delta is monotonically decreasing from near-zero to zero as S moves away from K.
Run cell to see output.
Not run
Cell 5 — Tridiagonal residual check: verify Thomas solve accuracy
Directly verify the Thomas algorithm by constructing a known tridiagonal system, solving it, and computing the residual $\|A\mathbf{x} - \mathbf{b}\|_\infty$. This confirms that the Thomas implementation is correct and the residual is at machine epsilon.
Run cell to see output.
Not run
Cell 6 — Validation summary
Aggregate all checks from this notebook into a final pass/fail report. Run all cells first.
Run cell to see output.
Not run