TQBTHEQUANTBATEMAN
TQB/ learn/ numerical finance/ fourier cos pricingEN · DARK
Numerical finance · front-office

Fourier & COS pricing

Price from the characteristic function while controlling truncation.

BY THE END, YOU CAN

01Connect density and characteristic function

02Implement a COS expansion

03Diagnose damping and truncation errors

01
INTUITION

Name the mathematical target and the approximation error.

Fourier methods trade path simulation for deterministic integration in frequency space.

01

Characteristic functions are often closed form when densities are not.

02

Payoff transforms may require damping.

03

Interval and mode count control error.

02
WHY MARKETS CARE

Tie accuracy to the decision the number supports.

Fast grids of vanilla prices and calibration objectives are central to stochastic-volatility workflows.

INSTRUMENTS

equity vanillas

FX vanillas

calibration grids

QUOTE CONVENTION

x=log(Sₜ/K); the transform convention and damping sign are displayed.

03
MATHEMATICS

Separate estimator, discretization, truncation, and convergence.

Formula · Definition

Characteristic function

φX(u)=E[eiuX]\varphi_X(u)=\mathbb E[e^{iuX}]

The transform uniquely identifies the law under regular conditions.

Formula · Full derivation

COS approximation

V≈e−rT∑k=0N−1′ℜ ⁣(φ(uk)e−iuka)UkV\approx e^{-rT}\sum_{k=0}^{N-1}{}'\Re\!\left(\varphi(u_k)e^{-iu_ka}\right)U_k

Density coefficients and analytic payoff coefficients meet in a finite cosine sum.

Full derivation
Full derivation

From information set to computable quantity

Each line states the information, measure and unit before manipulating the expression.

  1. 01

    Move to log state

    Express payoff and density on a finite interval [a,b].

  2. 02

    Expand the density

    Approximate cosine coefficients from φ at discrete frequencies.

    uk=kπ/(b−a)u_k=k\pi/(b-a)
  3. 03

    Project the payoff

    Compute Uₖ analytically for calls or puts.

  4. 04

    Control truncation

    Increase [a,b] and N independently and compare to a reference price.

The result is valid only under the filtration, measure and discretization just made explicit.

Inputs
  • φ(u)=E[e^{iuX}]
  • N: COS mode count
Assumptions and limits
  • Discontinuous densities and far tails need larger domains.
  • Branch conventions can destabilize complex logarithms.
05
MODEL / PRICING

Benchmark the algorithm against a controlled reference.

METHOD

Evaluate the risk-neutral characteristic function, multiply by analytic payoff coefficients and sum a controlled frequency grid.

CALIBRATION

Use a shared strike/maturity transform grid and weight residuals by liquidity and price scale.

06PYTHON IMPLEMENTATIONOpen the implementation and checks.
ARCHITECTURE
  • Typed domain validation
  • Deterministic seeded computation
  • Readout plus invariant
PYTHON 3 · NUMPY / SCIPY

Fourier & COS pricing

Reproduce the governing quantity, then challenge it with an invariant.

REUSABLE EXAMPLE
01import numpy as np
02
03def varphixumathbbeeiu(x: np.ndarray) -> float:
04 x = np.asarray(x, dtype=float)
05 assert np.isfinite(x).all()
06 return float(np.mean(x))
07
08sample = np.array([0.8, 1.0, 1.2])
09value = varphixumathbbeeiu(sample)
10assert sample.min() <= value <= sample.max()
11print(f"value={value:.6f}")
EXPECTED OUTPUTvalue=1.000000
SANITY CHECKS

✓ Finite inputs are enforced

✓ The result respects its numerical bounds

✓ Units and measure remain explicit

07
INTERACTIVE LAB

Change the error budget, not just the picture.

NUMERICAL ERROR LAB

Fourier & COS pricing

Use a fixed seed to separate discretization, sampling and truncation effects.

SYNTHETIC · EDUCATIONAL
Modes32frequency truncation
Tail coefficient0.00e+0smaller is better
Referenceφ(0)=11.000000
Re φ(u) by frequency u

Real characteristic-function coefficients by frequency.

  • Re φ(u)
frequency u: 0.0. Re φ(u): 1.0000.

Use Left/Right or Up/Down arrows to inspect values; Home and End jump to the bounds.

ERROR BUDGET

Model → algorithm → evidence

Each numerical approximation has an independent control and a reference diagnostic.

01Target lawQ / GBM

Measure and SDE fixed

02Algorithm32 modes

Discretization or transform control

03Diagnosticφ(0)=1

Visible convergence evidence

MODEL BOUNDARY

GBM and Gaussian transform examples are analytical references, not production calibration engines.

08
FRONT OFFICE

Where the model meets the book.

ON THE DESK
“Fast is useful only when truncation error stays visible.”
VISIBLE INPUTS

characteristic function

frequency grid

CALIBRATION

Use a shared strike/maturity transform grid and weight residuals by liquidity and price scale.

RISK

truncation error

complex branch errors

DAILY WORKFLOW
  1. Validate market state and timestamp
  2. Recompute the baseline
  3. Run a controlled perturbation
  4. Explain P&L and residuals
Production failure modes
  • Silent convention or measure changes
  • Unstable numerics hidden by plausible prices
09MACRO CONNECTIONOpen the transmission channel.
MACRO CONNECTION

Transmission from state to valuation

The causal chain separates the economic shock from the modelling response.

01Model parameterstransmits

shape φ(u)

02Frequency inversiontransmits

recovers prices

03Calibrationoutput

feeds parameters back

10COMMON PITFALLSOpen the failure checklist.
01

Changing transform conventions mid-derivation

02

Checking only one mode count

11SOURCES / FURTHER READINGOpen sources and continue the track.
research

Measure theory, simulation and computational-finance lectures

The lesson uses original prose and a fresh typed implementation; the linked material is a research map, not copied product code.

Source
Computational Finance Course
Author
L. A. Grzelak
Ref
main
OPEN ORIGINAL SOURCE ↗