FastTanhSinhQuadrature.jl
FastTanhSinhQuadrature.jl is a high-performance Julia library for numerical integration using the Tanh-Sinh (Double Exponential) quadrature method.
It handles singularities at endpoints robustly, supports arbitrary precision arithmetic (e.g., BigFloat, Double64), and leverages SIMD for speed.
The implementation follows the method introduced by Takahasi & Mori (1973).
Quick Start
using FastTanhSinhQuadrature
# High-level adaptive integration
val = quad(exp, 0.0, 1.0) # ≈ e - 1
# Match the quadrature type to your bounds
val32 = quad(exp, 0.0f0, 1.0f0) # Float32
# Handle singularities
f(x) = 1 / sqrt(abs(x))
val = quad_split(f, 0.0, -1.0, 1.0) # Split at singularity
# Pre-computed nodes
x, w, h = tanhsinh(Float64, 80)
val = integrate1D(x -> sin(x)^2, 0.0, π, x, w, h) # bounds can include π
# SIMD-accelerated (2-3x faster)
val = integrate1D_avx(sin, x, w, h)
# Use Val{N} for maximum performance with small N (< 128)
x_static, w_static, h_static = tanhsinh(Float64, Val(80))
val_static = integrate1D_avx(sin, x_static, w_static, h_static)Choosing an API
- Use
quadwhen you want adaptive refinement without manually choosingN. - Use
integrate1D/integrate2D/integrate3Dwith pre-computed(x, w, h)when reusing the same nodes across many integrals. - Use
_avxvariants forFloat32/Float64if your integrand works withLoopVectorization. - Use
quad_splitfor interior singularities andquad_cmplfor endpoint-sensitive formulations.
Pre-computed and high-level interfaces accept mixed real bounds (Int, Float64, π, etc.) and convert them to the numerical type used by the quadrature nodes. For concrete floating-point inputs such as Float32, the quadrature stays in that same type and returns that same type.
Key Features
- Arbitrary Precision:
Float32,Float64,BigFloat,Double64 - High Performance: SIMD-accelerated
_avxvariants - Multidimensional: 1D, 2D, and 3D integration
- Adaptive Integration:
quadandquad_splitfunctions - Singularity Handling: Robust at endpoints and interior points
- Double Exponential Convergence: Machine precision with few points
- Type Stability: Rigorously tested with
JET.jlfor zero runtime dispatch
Contents
- Theory: Understand the mathematics behind the method.
- Convergence: Convergence analysis and test functions.
- Basic Examples: Learn how to integrate simple 1D functions.
- Advanced Examples: Multidimensional integration and performance tips.
- Benchmarks: Performance comparison against other libraries.
- API Reference: Detailed function documentation.