Principle:Avhz RustQuant Numerical Integration
| Knowledge Sources | |
|---|---|
| Domains | Numerical_Methods, Mathematics |
| Last Updated | 2026-02-07 21:00 GMT |
Overview
Numerical quadrature for computing definite integrals using the Tanh-Sinh (double exponential) method, providing high accuracy for smooth and endpoint-singular integrands.
Description
Numerical Integration in RustQuant implements the Tanh-Sinh quadrature rule for evaluating definite integrals over arbitrary finite intervals .
The public API consists of a single function, integrate(f, a, b), which accepts any closure Fn(f64) -> f64 and returns the approximate value of the integral. Internally, the function performs a linear change of variables to map onto the canonical interval :
where and .
The core integration on uses the Tanh-Sinh (double exponential) transformation, which maps the integral to an infinite sum that converges very rapidly. The implementation uses 100 precomputed abscissae and weights (sourced from Keisan Casio high-precision tables) to evaluate:
The abscissae and weights are computed from:
The function handles non-finite integrand values by substituting zero, providing robustness for integrands with endpoint singularities.
Usage
Use this integration routine for computing definite integrals in option pricing (e.g., integrating probability densities), bond valuation (e.g., continuous cash flow discounting), or any numerical computation requiring accurate quadrature. The Tanh-Sinh method is particularly effective for smooth functions and for integrands with algebraic or logarithmic singularities at the endpoints.
Theoretical Basis
The Tanh-Sinh quadrature was introduced by Takahasi and Mori (1974). It exploits the double exponential decay of the transformed integrand to achieve extremely rapid convergence. The method is especially advantageous when the integrand has integrable singularities at the endpoints, as the transformation compresses the endpoint regions where such singularities occur.
For a smooth integrand, the error decreases as where is the number of evaluation points, making it one of the most efficient general-purpose quadrature methods available.