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.

Richardson extrapolation

Richardson extrapolation

Tavella-Randall non-uniform grids

Tavella-Randall non-uniform grids

American options#

Early exercise turns each implicit step into a linear complementarity problem: projected SOR, the Brennan-Schwartz direct solve and the penalty method.

Cryer’s projected SOR

Cryer's projected SOR

Brennan-Schwartz American put

Brennan-Schwartz American put

Forsyth-Vetzal penalty method

Forsyth-Vetzal penalty method

Multi-factor#

Two state variables without a two-dimensional linear solve: the alternating-direction implicit scheme.

Peaceman-Rachford ADI

Peaceman-Rachford ADI

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.

Crank-Nicolson

Crank-Nicolson

Laasonen’s implicit scheme

Laasonen's implicit scheme

The Thomas algorithm

The Thomas algorithm

Black-Scholes as the heat equation

Black-Scholes as the heat equation

Schwartz: explicit finite differences

Schwartz: explicit finite differences

Brennan-Schwartz: explicit schemes are trinomial trees

Brennan-Schwartz: explicit schemes are trinomial trees

Zvan-Forsyth-Vetzal barrier options

Zvan-Forsyth-Vetzal barrier options

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.

Courant-Friedrichs-Lewy

Courant-Friedrichs-Lewy

Von Neumann stability analysis

Von Neumann stability analysis

Rannacher smoothing

Rannacher smoothing

Gallery generated by Sphinx-Gallery