API Reference

High-Level API

These functions provide the easiest interface for integration with automatic adaptation.

FastTanhSinhQuadrature.quadFunction
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 low and up are absent, integrates over [-1, 1] (1D).
  • Uses SIMD-accelerated (_avx) implementation for Float32/Float64.
  • Uses higher-precision implementation for other types (e.g., BigFloat).
  • Automatically converts AbstractVector to SVector for multi-dimensional integration.
source
quad(f; rtol, atol, max_levels)

Adaptive 1D integration of f over the default interval [-1, 1].

source
FastTanhSinhQuadrature.quad_splitFunction
quad_split(f, c, [low, up]; rtol, atol, max_levels)

Split the integration domain at point c (singularity) and integrate sub-domains separately.

source
quad_split(f, c; rtol, atol, max_levels)

Split the default interval [-1, 1] at singularity c and integrate both sides adaptively.

source
FastTanhSinhQuadrature.quad_cmplFunction
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.

source

1D Integration

Functions for integrating over 1D domains using pre-computed nodes and weights.

FastTanhSinhQuadrature.integrate1DFunction
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.

source
integrate1D(f, x, w, h)

Calculate the integral of f over [-1, 1] using pre-computed nodes x, weights w, and step size h.

source
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.

source
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 π.

source
FastTanhSinhQuadrature.integrate1D_avxFunction
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.

source
integrate1D_avx(f, low, up, x, w, h)

SIMD-accelerated 1D integration over [low, up] Using LoopVectorization.

source
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 π.

source
FastTanhSinhQuadrature.adaptive_integrate_1DFunction
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.

source
FastTanhSinhQuadrature.adaptive_integrate_1D_cmplFunction
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).

source

2D Integration

Functions for integrating over 2D rectangular domains.

FastTanhSinhQuadrature.integrate2DFunction
integrate2D(f, x, w, h)

Calculate the 2D integral of f over [-1, 1]^2 using pre-computed nodes/weights.

source
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.

source
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 π.

source
integrate2D(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)

Convenience overload for bounds given as vectors of length 2.

source
FastTanhSinhQuadrature.integrate2D_avxFunction
integrate2D_avx(f, low, up, x, w, h)

SIMD-accelerated 2D integration over [low, up] Using LoopVectorization.

source
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.

source
integrate2D_avx(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)

Convenience SIMD overload for bounds given as vectors of length 2.

source
FastTanhSinhQuadrature.adaptive_integrate_2DFunction
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.

source

3D Integration

Functions for integrating over 3D box domains.

FastTanhSinhQuadrature.integrate3DFunction
integrate3D(f, x, w, h)

Calculate the 3D integral of f over [-1, 1]^3 using pre-computed nodes/weights.

source
integrate3D(f, low, up, x, w, h)

Calculate the 3D integral of f over [low, up] (with low, up::SVector{3}).

source
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 π.

source
integrate3D(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)

Convenience overload for bounds given as vectors of length 3.

source
FastTanhSinhQuadrature.integrate3D_avxFunction
integrate3D_avx(f, x, w, h)

SIMD-accelerated 3D integral over [-1, 1]^3.

source
integrate3D_avx(f, low, up, x, w, h)

SIMD-accelerated 3D integral over [low, up].

source
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.

source
integrate3D_avx(f, low::AbstractVector{<:Real}, up::AbstractVector{<:Real}, x, w, h)

Convenience SIMD overload for bounds given as vectors of length 3.

source
FastTanhSinhQuadrature.adaptive_integrate_3DFunction
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.

source

Node Generation

FastTanhSinhQuadrature.tanhsinhFunction
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

source
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.

source
tanhsinh(N::Int)

Generate Tanh-Sinh quadrature nodes x, weights w, and step size h for Float64 precision and N points.

source

Bounds and Containers

  • quad / quad_split / quad_cmpl accept scalar bounds as any Real type and convert internally to floating-point.
  • For 2D/3D high-level calls, bounds can be SVector or regular vectors of reals (length == 2 or 3).
  • Pre-computed multidimensional APIs (integrate2D, integrate3D, and _avx variants) support:
    • typed static bounds (SVector{N,T}),
    • mixed real static bounds (SVector{N,<:Real}),
    • vector bounds (AbstractVector{<:Real} with matching length).

All Exported Symbols

FastTanhSinhQuadrature.adaptive_integrate_1DMethod
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.

source
FastTanhSinhQuadrature.adaptive_integrate_1D_cmplMethod
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).

source
FastTanhSinhQuadrature.adaptive_integrate_2DMethod
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.

source
FastTanhSinhQuadrature.adaptive_integrate_3DMethod
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.

source
FastTanhSinhQuadrature.integrate1DMethod
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 π.

source
FastTanhSinhQuadrature.integrate1D_avxMethod
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.

source
FastTanhSinhQuadrature.integrate1D_avxMethod
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 π.

source
FastTanhSinhQuadrature.integrate1D_cmplMethod
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).

source
FastTanhSinhQuadrature.integrate2DMethod
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 π.

source
FastTanhSinhQuadrature.integrate3DMethod
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 π.

source
FastTanhSinhQuadrature.quadMethod
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 low and up are absent, integrates over [-1, 1] (1D).
  • Uses SIMD-accelerated (_avx) implementation for Float32/Float64.
  • Uses higher-precision implementation for other types (e.g., BigFloat).
  • Automatically converts AbstractVector to SVector for multi-dimensional integration.
source
FastTanhSinhQuadrature.quad_cmplMethod
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.

source
FastTanhSinhQuadrature.t_w_maxMethod
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).

source
FastTanhSinhQuadrature.t_x_maxMethod
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).

source
FastTanhSinhQuadrature.tanhsinhMethod
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

source
FastTanhSinhQuadrature.tanhsinhMethod
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.

source
FastTanhSinhQuadrature.tmaxMethod
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).

source