Examples#
This gallery walks through every public feature of
financialkit.pde_methods: the explicit, implicit and Crank-Nicolson
schemes, their stability and accuracy, American options as linear
complementarity problems, and a two-asset ADI solver. Each script
illustrates one dated breakthrough from the
history page.
See also the narrative tutorial:
Each script in this gallery is self-contained and can be run directly with
python examples/pde_methods/<section>/<script>.py.
Sections#
schemes – Crank-Nicolson, Laasonen’s implicit scheme, the Thomas algorithm, the heat-equation transform, Schwartz’s explicit scheme, the explicit scheme as a trinomial tree, and barrier options.
stability – the Courant-Friedrichs-Lewy condition, von Neumann analysis and Rannacher smoothing.
accuracy – Richardson extrapolation and Tavella-Randall grids.
american – Cryer’s projected SOR, the Brennan-Schwartz algorithm and the penalty method.
multi_factor – the Peaceman-Rachford ADI scheme for two assets.
Accuracy#
Getting more digits from the same work: Richardson extrapolation across grids, and grids that concentrate their nodes where the payoff bends.
American options#
Early exercise turns each implicit step into a linear complementarity problem: projected SOR, the Brennan-Schwartz direct solve and the penalty method.
Multi-factor#
Two state variables without a two-dimensional linear solve: the alternating-direction implicit scheme.
Schemes#
The Black-Scholes equation on a grid: explicit, implicit and Crank-Nicolson time stepping, the tridiagonal solves they need, the transformation to the heat equation, the link to trinomial trees, and knock-out barriers.
Brennan-Schwartz: explicit schemes are trinomial trees
Stability#
When a scheme’s errors grow without bound: the CFL time-step limit of the explicit scheme, von Neumann’s Fourier analysis, and Rannacher’s cure for Crank-Nicolson’s undamped oscillations.