API Reference
FastTanhSinhQuadrature.adaptive_integrate_1DFastTanhSinhQuadrature.adaptive_integrate_1DFastTanhSinhQuadrature.adaptive_integrate_1D_cmplFastTanhSinhQuadrature.adaptive_integrate_1D_cmplFastTanhSinhQuadrature.adaptive_integrate_2DFastTanhSinhQuadrature.adaptive_integrate_2DFastTanhSinhQuadrature.adaptive_integrate_3DFastTanhSinhQuadrature.adaptive_integrate_3DFastTanhSinhQuadrature.integrate1DFastTanhSinhQuadrature.integrate1DFastTanhSinhQuadrature.integrate1DFastTanhSinhQuadrature.integrate1DFastTanhSinhQuadrature.integrate1DFastTanhSinhQuadrature.integrate1D_avxFastTanhSinhQuadrature.integrate1D_avxFastTanhSinhQuadrature.integrate1D_avxFastTanhSinhQuadrature.integrate1D_avxFastTanhSinhQuadrature.integrate1D_cmplFastTanhSinhQuadrature.integrate2DFastTanhSinhQuadrature.integrate2DFastTanhSinhQuadrature.integrate2DFastTanhSinhQuadrature.integrate2DFastTanhSinhQuadrature.integrate2DFastTanhSinhQuadrature.integrate2D_avxFastTanhSinhQuadrature.integrate2D_avxFastTanhSinhQuadrature.integrate2D_avxFastTanhSinhQuadrature.integrate2D_avxFastTanhSinhQuadrature.integrate3DFastTanhSinhQuadrature.integrate3DFastTanhSinhQuadrature.integrate3DFastTanhSinhQuadrature.integrate3DFastTanhSinhQuadrature.integrate3DFastTanhSinhQuadrature.integrate3D_avxFastTanhSinhQuadrature.integrate3D_avxFastTanhSinhQuadrature.integrate3D_avxFastTanhSinhQuadrature.integrate3D_avxFastTanhSinhQuadrature.integrate3D_avxFastTanhSinhQuadrature.ordinate_complementFastTanhSinhQuadrature.quadFastTanhSinhQuadrature.quadFastTanhSinhQuadrature.quadFastTanhSinhQuadrature.quad_cmplFastTanhSinhQuadrature.quad_cmplFastTanhSinhQuadrature.quad_splitFastTanhSinhQuadrature.quad_splitFastTanhSinhQuadrature.quad_splitFastTanhSinhQuadrature.t_w_maxFastTanhSinhQuadrature.t_x_maxFastTanhSinhQuadrature.tanhsinhFastTanhSinhQuadrature.tanhsinhFastTanhSinhQuadrature.tanhsinhFastTanhSinhQuadrature.tanhsinhFastTanhSinhQuadrature.tmax
High-Level API
These functions provide the easiest interface for integration with automatic adaptation.
FastTanhSinhQuadrature.quad — Function
quad(f, [low, up]; rtol, atol, max_levels)High-level interface for Tanh-Sinh quadrature. Automatically detects dimensions (1D, 2D, or 3D) and chooses the most efficient implementation.
- If
lowandupare absent, integrates over[-1, 1](1D). - Uses SIMD-accelerated (
_avx) implementation forFloat32/Float64. - Uses higher-precision implementation for other types (e.g.,
BigFloat). - Automatically converts
AbstractVectortoSVectorfor multi-dimensional integration.
quad(f; rtol, atol, max_levels)Adaptive 1D integration of f over the default interval [-1, 1].
FastTanhSinhQuadrature.quad_split — Function
quad_split(f, c, [low, up]; rtol, atol, max_levels)Split the integration domain at point c (singularity) and integrate sub-domains separately.
quad_split(f, c; rtol, atol, max_levels)Split the default interval [-1, 1] at singularity c and integrate both sides adaptively.
FastTanhSinhQuadrature.quad_cmpl — Function
quad_cmpl(f, [low, up]; rtol, atol, max_levels)High-level 1D interface for endpoint-distance-aware integrands. Call as quad_cmpl(f, a, b). At each quadrature node x in [a, b], the callback is evaluated as f(x, b_minus_x, x_minus_a), where b_minus_x = b - x and x_minus_a = x - a (for [-1, 1]: f(x, 1-x, 1+x)).
This is useful when expressions like log(b_minus_x) or 1/sqrt(b_minus_x*x_minus_a) are sensitive to cancellation near endpoints.
1D Integration
Functions for integrating over 1D domains using pre-computed nodes and weights.
FastTanhSinhQuadrature.integrate1D — Function
integrate1D(::Type{T}, f, N::Int) where {T<:Real}Calculate the integral of f over [-1, 1] using N Tanh-Sinh quadrature points in precision T.
integrate1D(f, x, w, h)Calculate the integral of f over [-1, 1] using pre-computed nodes x, weights w, and step size h.
integrate1D(f, low, up, x, w, h)Calculate the integral of f over [low, up] using pre-computed nodes x, weights w, and step size h.
integrate1D(f, low::Real, up::Real, x, w, h)Calculate the integral of f over [low, up] using pre-computed nodes x, weights w, and step size h. Bounds are converted to the node type T to support inputs such as π.
FastTanhSinhQuadrature.integrate1D_avx — Function
integrate1D_avx(f, x, w, h)SIMD-accelerated 1D integration over [-1, 1] Using LoopVectorization. Requires f to be compatible with @turbo. Only beneficial for Float32/Float64.
integrate1D_avx(f, low, up, x, w, h)SIMD-accelerated 1D integration over [low, up] Using LoopVectorization.
integrate1D_avx(f, low::Real, up::Real, x, w, h)SIMD-accelerated 1D integration over [low, up] using LoopVectorization. Bounds are converted to the node type T to support inputs such as π.
FastTanhSinhQuadrature.adaptive_integrate_1D — Function
adaptive_integrate_1D(::Type{T}, f, a, b; rtol, atol, max_levels::Int=16, warn::Bool=true)Adaptive 1D Tanh-Sinh integration over [a, b]. Starts with a coarse grid (h ≈ tmax/2) and halves the step size at each level. Reuses function evaluations from previous levels by only computing new (odd-indexed) nodes. Exploits symmetry around the center of the interval.
FastTanhSinhQuadrature.adaptive_integrate_1D_cmpl — Function
adaptive_integrate_1D_cmpl(::Type{T}, f, a, b; rtol, atol, max_levels::Int=16, warn::Bool=true)Adaptive 1D Tanh-Sinh integration for endpoint-distance-aware integrands. For interval [a, b], f should accept f(x, b_minus_x, x_minus_a), where b_minus_x = b - x and x_minus_a = x - a. For the default interval [-1, 1], this is f(x, 1-x, 1+x).
2D Integration
Functions for integrating over 2D rectangular domains.
FastTanhSinhQuadrature.integrate2D — Function
integrate2D(f, x, w, h)Calculate the 2D integral of f over [-1, 1]^2 using pre-computed nodes/weights.
integrate2D(f, low, up, x, w, h)Calculate the 2D integral of f over [low, up] (with low, up::SVector{2}) using pre-computed nodes/weights.
integrate2D(f, low::SVector{2,<:Real}, up::SVector{2,<:Real}, x, w, h)Calculate the 2D integral of f over [low, up] using pre-computed nodes/weights. Bounds are converted to the node type T to support mixed real types such as π.
integrate2D(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience overload for bounds given as vectors of length 2.
FastTanhSinhQuadrature.integrate2D_avx — Function
integrate2D_avx(f, low, up, x, w, h)SIMD-accelerated 2D integration over [low, up] Using LoopVectorization.
integrate2D_avx(f, low::SVector{2,<:Real}, up::SVector{2,<:Real}, x, w, h)SIMD-accelerated 2D integration where bounds are converted to node type T.
integrate2D_avx(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience SIMD overload for bounds given as vectors of length 2.
FastTanhSinhQuadrature.adaptive_integrate_2D — Function
adaptive_integrate_2D(::Type{T}, f, low::SVector{2,T}, up::SVector{2,T}; rtol, atol, max_levels::Int=8, warn::Bool=true)Adaptive 2D Tanh-Sinh integration over a rectangle. Reuses indices by only evaluating new points where at least one coordinate corresponds to an odd multiple of the halved step size h. Exploits 4-way quadrant symmetry and 2-way axis symmetry.
3D Integration
Functions for integrating over 3D box domains.
FastTanhSinhQuadrature.integrate3D — Function
integrate3D(f, x, w, h)Calculate the 3D integral of f over [-1, 1]^3 using pre-computed nodes/weights.
integrate3D(f, low, up, x, w, h)Calculate the 3D integral of f over [low, up] (with low, up::SVector{3}).
integrate3D(f, low::SVector{3,<:Real}, up::SVector{3,<:Real}, x, w, h)Calculate the 3D integral of f over [low, up] using pre-computed nodes/weights. Bounds are converted to the node type T to support mixed real types such as π.
integrate3D(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience overload for bounds given as vectors of length 3.
FastTanhSinhQuadrature.integrate3D_avx — Function
integrate3D_avx(f, x, w, h)SIMD-accelerated 3D integral over [-1, 1]^3.
integrate3D_avx(f, low, up, x, w, h)SIMD-accelerated 3D integral over [low, up].
integrate3D_avx(f, low::SVector{3,<:Real}, up::SVector{3,<:Real}, x, w, h)SIMD-accelerated 3D integration where bounds are converted to node type T.
integrate3D_avx(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience SIMD overload for bounds given as vectors of length 3.
FastTanhSinhQuadrature.adaptive_integrate_3D — Function
adaptive_integrate_3D(::Type{T}, f, low::SVector{3,T}, up::SVector{3,T}; rtol, atol, max_levels::Int=5, warn::Bool=true)Adaptive 3D Tanh-Sinh integration over a box. Reuses old points and exploits 8-way octant symmetry, 4-way plane symmetry, and 2-way axis symmetry to minimize function evaluations.
Node Generation
FastTanhSinhQuadrature.tanhsinh — Function
tanhsinh(::Type{T}, N::Val{N}) where {T<:AbstractFloat,N}Generate Tanh-Sinh quadrature nodes x, weights w, and step size h for a given floating point type T and number of points Val{N}. Use this for approximately N<128
tanhsinh(::Type{T}, N::Int; D::Int=1) where {T<:AbstractFloat}Generate Tanh-Sinh quadrature nodes x, weights w, and step size h for a given floating point type T and number of points N.
tanhsinh(N::Int)Generate Tanh-Sinh quadrature nodes x, weights w, and step size h for Float64 precision and N points.
Bounds and Containers
quad/quad_split/quad_cmplaccept scalar bounds as anyRealtype and convert internally to floating-point.- For 2D/3D high-level calls, bounds can be
SVectoror regular vectors of reals (length == 2or3). - Pre-computed multidimensional APIs (
integrate2D,integrate3D, and_avxvariants) support:- typed static bounds (
SVector{N,T}), - mixed real static bounds (
SVector{N,<:Real}), - vector bounds (
AbstractVector{<:Real}with matching length).
- typed static bounds (
All Exported Symbols
FastTanhSinhQuadrature.adaptive_integrate_1D — Method
adaptive_integrate_1D(::Type{T}, f, a, b; rtol, atol, max_levels::Int=16, warn::Bool=true)Adaptive 1D Tanh-Sinh integration over [a, b]. Starts with a coarse grid (h ≈ tmax/2) and halves the step size at each level. Reuses function evaluations from previous levels by only computing new (odd-indexed) nodes. Exploits symmetry around the center of the interval.
FastTanhSinhQuadrature.adaptive_integrate_1D_cmpl — Method
adaptive_integrate_1D_cmpl(::Type{T}, f, a, b; rtol, atol, max_levels::Int=16, warn::Bool=true)Adaptive 1D Tanh-Sinh integration for endpoint-distance-aware integrands. For interval [a, b], f should accept f(x, b_minus_x, x_minus_a), where b_minus_x = b - x and x_minus_a = x - a. For the default interval [-1, 1], this is f(x, 1-x, 1+x).
FastTanhSinhQuadrature.adaptive_integrate_2D — Method
adaptive_integrate_2D(::Type{T}, f, low::SVector{2,T}, up::SVector{2,T}; rtol, atol, max_levels::Int=8, warn::Bool=true)Adaptive 2D Tanh-Sinh integration over a rectangle. Reuses indices by only evaluating new points where at least one coordinate corresponds to an odd multiple of the halved step size h. Exploits 4-way quadrant symmetry and 2-way axis symmetry.
FastTanhSinhQuadrature.adaptive_integrate_3D — Method
adaptive_integrate_3D(::Type{T}, f, low::SVector{3,T}, up::SVector{3,T}; rtol, atol, max_levels::Int=5, warn::Bool=true)Adaptive 3D Tanh-Sinh integration over a box. Reuses old points and exploits 8-way octant symmetry, 4-way plane symmetry, and 2-way axis symmetry to minimize function evaluations.
FastTanhSinhQuadrature.integrate1D — Method
integrate1D(::Type{T}, f, N::Int) where {T<:Real}Calculate the integral of f over [-1, 1] using N Tanh-Sinh quadrature points in precision T.
FastTanhSinhQuadrature.integrate1D — Method
integrate1D(f, low::Real, up::Real, x, w, h)Calculate the integral of f over [low, up] using pre-computed nodes x, weights w, and step size h. Bounds are converted to the node type T to support inputs such as π.
FastTanhSinhQuadrature.integrate1D — Method
integrate1D(f, low, up, x, w, h)Calculate the integral of f over [low, up] using pre-computed nodes x, weights w, and step size h.
FastTanhSinhQuadrature.integrate1D — Method
integrate1D(f, x, w, h)Calculate the integral of f over [-1, 1] using pre-computed nodes x, weights w, and step size h.
FastTanhSinhQuadrature.integrate1D_avx — Method
integrate1D_avx(f, x, w, h)SIMD-accelerated 1D integration over [-1, 1] Using LoopVectorization. Requires f to be compatible with @turbo. Only beneficial for Float32/Float64.
FastTanhSinhQuadrature.integrate1D_avx — Method
integrate1D_avx(f, low::Real, up::Real, x, w, h)SIMD-accelerated 1D integration over [low, up] using LoopVectorization. Bounds are converted to the node type T to support inputs such as π.
FastTanhSinhQuadrature.integrate1D_avx — Method
integrate1D_avx(f, low, up, x, w, h)SIMD-accelerated 1D integration over [low, up] Using LoopVectorization.
FastTanhSinhQuadrature.integrate1D_cmpl — Method
integrate1D_cmpl(::Type{T}, f, N::Int) where {T<:Real}Calculate the integral of f(x, 1-x, 1+x) over [-1, 1] using N points. f should accept three arguments: f(x, 1-x, 1+x).
FastTanhSinhQuadrature.integrate2D — Method
integrate2D(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience overload for bounds given as vectors of length 2.
FastTanhSinhQuadrature.integrate2D — Method
integrate2D(f, low, up, x, w, h)Calculate the 2D integral of f over [low, up] (with low, up::SVector{2}) using pre-computed nodes/weights.
FastTanhSinhQuadrature.integrate2D — Method
integrate2D(f, x, w, h)Calculate the 2D integral of f over [-1, 1]^2 using pre-computed nodes/weights.
FastTanhSinhQuadrature.integrate2D — Method
integrate2D(f, low::SVector{2,<:Real}, up::SVector{2,<:Real}, x, w, h)Calculate the 2D integral of f over [low, up] using pre-computed nodes/weights. Bounds are converted to the node type T to support mixed real types such as π.
FastTanhSinhQuadrature.integrate2D_avx — Method
integrate2D_avx(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience SIMD overload for bounds given as vectors of length 2.
FastTanhSinhQuadrature.integrate2D_avx — Method
integrate2D_avx(f, low, up, x, w, h)SIMD-accelerated 2D integration over [low, up] Using LoopVectorization.
FastTanhSinhQuadrature.integrate2D_avx — Method
integrate2D_avx(f, low::SVector{2,<:Real}, up::SVector{2,<:Real}, x, w, h)SIMD-accelerated 2D integration where bounds are converted to node type T.
FastTanhSinhQuadrature.integrate3D — Method
integrate3D(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience overload for bounds given as vectors of length 3.
FastTanhSinhQuadrature.integrate3D — Method
integrate3D(f, low, up, x, w, h)Calculate the 3D integral of f over [low, up] (with low, up::SVector{3}).
FastTanhSinhQuadrature.integrate3D — Method
integrate3D(f, x, w, h)Calculate the 3D integral of f over [-1, 1]^3 using pre-computed nodes/weights.
FastTanhSinhQuadrature.integrate3D — Method
integrate3D(f, low::SVector{3,<:Real}, up::SVector{3,<:Real}, x, w, h)Calculate the 3D integral of f over [low, up] using pre-computed nodes/weights. Bounds are converted to the node type T to support mixed real types such as π.
FastTanhSinhQuadrature.integrate3D_avx — Method
integrate3D_avx(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)Convenience SIMD overload for bounds given as vectors of length 3.
FastTanhSinhQuadrature.integrate3D_avx — Method
integrate3D_avx(f, low, up, x, w, h)SIMD-accelerated 3D integral over [low, up].
FastTanhSinhQuadrature.integrate3D_avx — Method
integrate3D_avx(f, x, w, h)SIMD-accelerated 3D integral over [-1, 1]^3.
FastTanhSinhQuadrature.integrate3D_avx — Method
integrate3D_avx(f, low::SVector{3,<:Real}, up::SVector{3,<:Real}, x, w, h)SIMD-accelerated 3D integration where bounds are converted to node type T.
FastTanhSinhQuadrature.ordinate_complement — Method
ordinate_complement(t::T) where {T<:Real}Return 1 - |ordinate(t)| accurately. Useful for f(1-x).
FastTanhSinhQuadrature.quad — Method
quad(f; rtol, atol, max_levels)Adaptive 1D integration of f over the default interval [-1, 1].
FastTanhSinhQuadrature.quad — Method
quad(f, [low, up]; rtol, atol, max_levels)High-level interface for Tanh-Sinh quadrature. Automatically detects dimensions (1D, 2D, or 3D) and chooses the most efficient implementation.
- If
lowandupare absent, integrates over[-1, 1](1D). - Uses SIMD-accelerated (
_avx) implementation forFloat32/Float64. - Uses higher-precision implementation for other types (e.g.,
BigFloat). - Automatically converts
AbstractVectortoSVectorfor multi-dimensional integration.
FastTanhSinhQuadrature.quad_cmpl — Method
quad_cmpl(f, [low, up]; rtol, atol, max_levels)High-level 1D interface for endpoint-distance-aware integrands. Call as quad_cmpl(f, a, b). At each quadrature node x in [a, b], the callback is evaluated as f(x, b_minus_x, x_minus_a), where b_minus_x = b - x and x_minus_a = x - a (for [-1, 1]: f(x, 1-x, 1+x)).
This is useful when expressions like log(b_minus_x) or 1/sqrt(b_minus_x*x_minus_a) are sensitive to cancellation near endpoints.
FastTanhSinhQuadrature.quad_split — Method
quad_split(f, c; rtol, atol, max_levels)Split the default interval [-1, 1] at singularity c and integrate both sides adaptively.
FastTanhSinhQuadrature.quad_split — Method
quad_split(f, c, [low, up]; rtol, atol, max_levels)Split the integration domain at point c (singularity) and integrate sub-domains separately.
FastTanhSinhQuadrature.t_w_max — Method
t_w_max(::Type{T}, D::Int=1) where {T<:Real}Calculate the maximum t to avoid weight underflow (Eq. 15 in arXiv:2007.15057). Ensures (ψ'(t))^calD >= floatmin(T) where calD = max(1, D-1).
FastTanhSinhQuadrature.t_x_max — Method
t_x_max(::Type{T}) where {T<:Real}Calculate the maximum t to avoid abscissae underflow (Eq. 13 in arXiv:2007.15057). Ensures 1 - |t| >= floatmin(T).
FastTanhSinhQuadrature.tanhsinh — Method
tanhsinh(N::Int)Generate Tanh-Sinh quadrature nodes x, weights w, and step size h for Float64 precision and N points.
FastTanhSinhQuadrature.tanhsinh — Method
tanhsinh(::Type{T}, N::Val{N}) where {T<:AbstractFloat,N}Generate Tanh-Sinh quadrature nodes x, weights w, and step size h for a given floating point type T and number of points Val{N}. Use this for approximately N<128
FastTanhSinhQuadrature.tanhsinh — Method
tanhsinh(::Type{T}, N::Int; D::Int=1) where {T<:AbstractFloat}Generate Tanh-Sinh quadrature nodes x, weights w, and step size h for a given floating point type T and number of points N.
FastTanhSinhQuadrature.tmax — Method
tmax(::Type{T}, D::Int=1) where {T<:Real}Find the optimal window limit tmax considering abscissae and weight underflow (Eq. 14 in arXiv:2007.15057).