Integral Solver Algorithms

The following algorithms are available:

  • QuadGKJL: Uses QuadGK.jl, which supports one-dimensional integration of scalar and array-valued integrands with in-place or batched forms. Integrands that are both in-place and batched are implemented in the wrapper but are not supported under the hood.
  • HCubatureJL: Uses HCubature.jl, which supports scalar and array-valued integrands and works best in low dimensions, e.g. ≤ 8. In-place integrands are implemented in the wrapper but are not supported under the hood. Batching is not supported.
  • VEGAS: Uses MonteCarloIntegration.jl, which requires scalar, Float64-valued integrands and works in any number of dimensions.
  • VEGASMC: Uses MCIntegration.jl. Requires using MCIntegration. Doesn't support batching.
  • CubatureJLh: h-Cubature from Cubature.jl. Requires using Cubature.
  • CubatureJLp: p-Cubature from Cubature.jl. Requires using Cubature.
  • CubaVegas: Vegas from Cuba.jl. Requires using Cuba.
  • CubaSUAVE: SUAVE from Cuba.jl. Requires using Cuba.
  • CubaDivonne: Divonne from Cuba.jl. Requires using Cuba. Works only for >1-dimensional integrations.
  • CubaCuhre: Cuhre from Cuba.jl. Requires using Cuba. Works only for >1-dimensional integrations.
  • GaussLegendre: Performs fixed-order Gauss-Legendre quadrature. Requires using FastGaussQuadrature.
  • QuadratureRule: Accepts a user-defined function that returns nodes and weights.
  • ArblibJL: real- and complex-valued univariate integration of holomorphic and meromorphic functions from Arblib.jl. Requires using Arblib.
Integrals.QuadGKJLType
QuadGKJL(; order = 7, norm = norm, buffer = nothing)

One-dimensional adaptive Gauss-Kronrod integration from QuadGK.jl.

Keyword Arguments

  • order: Order of the embedded Gauss-Kronrod rule. Higher values reduce the number of subintervals for smooth integrands and increase work per subinterval.
  • norm: Function used by QuadGK.jl to turn the integral estimate and error estimate into scalar convergence criteria. This is most useful for array-valued integrands.
  • buffer: If non-nothing, allocate and cache a QuadGK segment buffer during init. This avoids repeated buffer allocation when solve! is called on the same cache. Buffer construction may evaluate the integrand unless the problem supplies an integrand_prototype.

Fields

  • order::Int: Stored quadrature rule order.
  • norm: Stored convergence norm.
  • buffer: Stored buffer option.

Returns

Returns a QuadGKJL algorithm object for use with solve(prob::IntegralProblem, alg), init, and solve!.

Example

using Integrals

prob = IntegralProblem((x, p) -> x^2, (0.0, 1.0))
sol = solve(prob, QuadGKJL(order = 9); reltol = 1e-10)

References

@article{laurie1997calculation,
title={Calculation of Gauss-Kronrod quadrature rules},
author={Laurie, Dirk},
journal={Mathematics of Computation},
volume={66},
number={219},
pages={1133--1145},
year={1997}
}
source
Integrals.HCubatureJLType
HCubatureJL(; norm=norm, initdiv=1, buffer = nothing)

Multidimensional h-adaptive integration from HCubature.jl.

Keyword Arguments

  • initdiv: Initial number of segments used to divide each integration dimension.
  • norm: Function used by HCubature.jl to turn integral and error estimates into scalar convergence criteria. This is most useful for array-valued integrands.
  • buffer: If non-nothing, allocate and cache HCubature work buffers during init. The buffer is managed by Integrals.jl; callers should not pass an HCubature buffer directly.

Fields

  • initdiv::Int: Stored initial subdivision count.
  • norm: Stored convergence norm.
  • buffer: Stored buffer option.

Returns

Returns an HCubatureJL algorithm object for IntegralProblems over scalar or vector box domains.

Example

using Integrals

f(x, p) = x[1]^2 + x[2]^2
prob = IntegralProblem(f, ([0.0, 0.0], [1.0, 1.0]))
sol = solve(prob, HCubatureJL(initdiv = 2))

References

@article{genz1980remarks,
title={Remarks on algorithm 006: An adaptive algorithm for numerical integration over an N-dimensional rectangular region},
author={Genz, Alan C and Malik, Aftab Ahmad},
journal={Journal of Computational and Applied mathematics},
volume={6},
number={4},
pages={295--302},
year={1980},
publisher={Elsevier}
}
source
Integrals.CubatureJLpType
CubatureJLp(; error_norm = Cubature.INDIVIDUAL)

Multidimensional p-adaptive integration from Cubature.jl. This method is based on repeatedly doubling the degree of the cubature rules, until convergence is achieved. The used cubature rule is a tensor product of Clenshaw–Curtis quadrature rules. error_norm specifies the convergence criterion for vector valued integrands. Defaults to Cubature.INDIVIDUAL, other options are Cubature.PAIRED, Cubature.L1, Cubature.L2, or Cubature.LINF.

Keyword Arguments

  • error_norm: Cubature.jl error norm used for vector-valued integrands. The constructor default 0 corresponds to Cubature.INDIVIDUAL.

Fields

  • error_norm::Int32: Stored Cubature.jl error-norm code.

Returns

Returns a CubatureJLp algorithm object. Cubature.jl must be loaded before construction.

source
Integrals.CubatureJLhType
CubatureJLh(; error_norm = Cubature.INDIVIDUAL)

Multidimensional h-adaptive integration from Cubature.jl. error_norm specifies the convergence criterion for vector valued integrands. Defaults to Cubature.INDIVIDUAL, other options are Cubature.PAIRED, Cubature.L1, Cubature.L2, or Cubature.LINF.

Keyword Arguments

  • error_norm: Cubature.jl error norm used for vector-valued integrands. The constructor default 0 corresponds to Cubature.INDIVIDUAL.

Fields

  • error_norm::Int32: Stored Cubature.jl error-norm code.

Returns

Returns a CubatureJLh algorithm object. Cubature.jl must be loaded before construction.

References

@article{genz1980remarks,
title={Remarks on algorithm 006: An adaptive algorithm for numerical integration over an N-dimensional rectangular region},
author={Genz, Alan C and Malik, Aftab Ahmad},
journal={Journal of Computational and Applied mathematics},
volume={6},
number={4},
pages={295--302},
year={1980},
publisher={Elsevier}
}
source
Integrals.VEGASType
VEGAS(; nbins = 100, ncalls = 1000, debug=false, seed = nothing)

Multidimensional adaptive Monte Carlo integration from MonteCarloIntegration.jl. Importance sampling is used to reduce variance.

Keyword Arguments

  • nbins: Initial number of bins used for each integration dimension.
  • ncalls: Number of integrand calls requested per Monte Carlo iteration.
  • debug: Whether to request debug output from MonteCarloIntegration.jl.
  • seed: Optional random seed passed to the underlying algorithm.

Fields

  • nbins::Int: Stored bin count.
  • ncalls::Int: Stored calls-per-iteration target.
  • debug::Bool: Stored debug-output flag.
  • seed: Stored seed value.

Returns

Returns a VEGAS algorithm object for multidimensional scalar Monte Carlo integration.

Example

using Integrals

f(x, p) = exp(-sum(abs2, x))
prob = IntegralProblem(f, (zeros(3), ones(3)))
sol = solve(prob, VEGAS(ncalls = 2_000); reltol = 1e-2)

Limitations

This algorithm can only integrate scalar Float64-valued functions.

References

@article{lepage1978new,
title={A new algorithm for adaptive multidimensional integration},
author={Lepage, G Peter},
journal={Journal of Computational Physics},
volume={27},
number={2},
pages={192--203},
year={1978},
publisher={Elsevier}
}
source
Integrals.VEGASMCType
VEGASMC(; kws...)

Markov-chain based Vegas algorithm from MCIntegration.jl.

Refer to MCIntegration.integrate for documentation on the keywords, which are passed directly to the solver with a set of defaults that works for conforming integrands.

Keyword Arguments

  • kws...: Backend keyword arguments forwarded to MCIntegration.integrate.

Fields

  • kws::NamedTuple: Stored backend keyword arguments.

Returns

Returns a VEGASMC algorithm object. MCIntegration.jl must be loaded before construction.

source
Integrals.CubaVegasType
CubaVegas(; flags = 0, seed = 0, minevals = 0, nstart = 1000,
    nincrease = 500, gridno = 0)

Multidimensional adaptive Monte Carlo integration from Cuba.jl. Importance sampling is used to reduce variance.

Keyword Arguments

  • flags: Cuba flags bitmask.
  • seed: Random seed passed to Cuba.
  • minevals: Minimum number of integrand evaluations.
  • nstart: Number of evaluations in the first iteration.
  • nincrease: Increase in evaluations for later iterations.
  • gridno: Cuba grid slot used for state reuse.

Fields

The fields match the keyword arguments: flags, seed, minevals, nstart, nincrease, and gridno.

Returns

Returns a CubaVegas algorithm object. Cuba.jl must be loaded before construction.

Example

using Integrals, Cuba

prob = IntegralProblem((x, p) -> x[1] * x[2], (zeros(2), ones(2)))
sol = solve(prob, CubaVegas(nstart = 2_000))

References

@article{lepage1978new,
title={A new algorithm for adaptive multidimensional integration},
author={Lepage, G Peter},
journal={Journal of Computational Physics},
volume={27},
number={2},
pages={192--203},
year={1978},
publisher={Elsevier}
}
source
Integrals.CubaSUAVEType
CubaSUAVE(; flags = 0, seed = 0, minevals = 0, nnew = 1000,
    nmin = 2, flatness = 25.0)

Multidimensional adaptive Monte Carlo integration from Cuba.jl. Suave stands for subregion-adaptive VEGAS. Importance sampling and subdivision are thus used to reduce variance.

Keyword Arguments

  • flags: Cuba flags bitmask.
  • seed: Random seed passed to Cuba.
  • minevals: Minimum number of integrand evaluations.
  • nnew: Number of new samples per subdivision.
  • nmin: Minimum samples required before subdivision.
  • flatness: Flatness parameter used by SUAVE subdivision.

Fields

The fields match the keyword arguments: flags, seed, minevals, nnew, nmin, and flatness.

Returns

Returns a CubaSUAVE algorithm object. Cuba.jl must be loaded before construction.

References

@article{hahn2005cuba,
title={Cuba—a library for multidimensional numerical integration},
author={Hahn, Thomas},
journal={Computer Physics Communications},
volume={168},
number={2},
pages={78--95},
year={2005},
publisher={Elsevier}
}
source
Integrals.CubaDivonneType
CubaDivonne(; flags = 0, seed = 0, minevals = 0, key1 = 47, key2 = 1,
    key3 = 1, maxpass = 5, border = 0.0, maxchisq = 10.0,
    mindeviation = 0.25, xgiven = zeros(Cdouble, 0, 0), nextra = 0,
    peakfinder = C_NULL)

Multidimensional adaptive Monte Carlo integration from Cuba.jl. Stratified sampling is used to reduce variance.

Keyword Arguments

  • flags: Cuba flags bitmask.
  • seed: Random seed passed to Cuba.
  • minevals: Minimum number of integrand evaluations.
  • key1, key2, key3: Divonne rule-selection keys.
  • maxpass: Maximum number of partitioning passes.
  • border: Border width excluded from partitioning.
  • maxchisq: Maximum chi-square value used for consistency checks.
  • mindeviation: Minimum relative deviation used for subdivision.
  • xgiven: Matrix of user-supplied points.
  • nextra: Number of extra points supplied through peakfinder.
  • peakfinder: Cuba peak-finder callback pointer.

Fields

The fields match the keyword arguments.

Returns

Returns a CubaDivonne algorithm object. Cuba.jl must be loaded before construction.

References

@article{friedman1981nested,
title={A nested partitioning procedure for numerical multiple integration},
author={Friedman, Jerome H and Wright, Margaret H},
journal={ACM Transactions on Mathematical Software (TOMS)},
volume={7},
number={1},
pages={76--92},
year={1981},
publisher={ACM New York, NY, USA}
}
source
Integrals.CubaCuhreType
CubaCuhre(; flags = 0, minevals = 0, key = 0)

Multidimensional h-adaptive integration from Cuba.jl.

Keyword Arguments

  • flags: Cuba flags bitmask.
  • minevals: Minimum number of integrand evaluations.
  • key: Cuba Cuhre rule-selection key.

Fields

  • flags::Int: Stored flags bitmask.
  • minevals::Int: Stored minimum evaluation count.
  • key::Int: Stored rule-selection key.

Returns

Returns a CubaCuhre algorithm object. Cuba.jl must be loaded before construction.

References

@article{berntsen1991adaptive,
title={An adaptive algorithm for the approximate calculation of multiple integrals},
author={Berntsen, Jarle and Espelid, Terje O and Genz, Alan},
journal={ACM Transactions on Mathematical Software (TOMS)},
volume={17},
number={4},
pages={437--451},
year={1991},
publisher={ACM New York, NY, USA}
}
source
Integrals.GaussLegendreType
GaussLegendre(; n = 250, subintervals = 1, nodes = nothing, weights = nothing)
GaussLegendre(nodes, weights, subintervals = 1)

Fixed-order Gauss-Legendre quadrature, optionally applied on a composite partition of the integration interval.

Arguments

  • nodes: Quadrature nodes on the standard interval [-1, 1].
  • weights: Quadrature weights corresponding to nodes.
  • subintervals: Number of equally sized subintervals used for composite Gauss-Legendre quadrature.

Keyword Arguments

  • n: Number of quadrature nodes to construct when nodes or weights is nothing.
  • subintervals: Number of subintervals used for composite quadrature. Must be positive.
  • nodes: Optional precomputed nodes. If omitted, gausslegendre(n) is used.
  • weights: Optional precomputed weights. If omitted, gausslegendre(n) is used.

Fields

  • nodes: Stored quadrature nodes.
  • weights: Stored quadrature weights.
  • subintervals::Int64: Stored number of subintervals.

The type parameter C is true when subintervals > 1 and false otherwise. Composite mode splits [a, b] into subintervals pieces and applies the same rule to each piece.

Returns

Returns a GaussLegendre algorithm object. GaussLegendre(; n=...) requires FastGaussQuadrature.jl to be loaded so that the gausslegendre extension method is available.

Example

using Integrals, FastGaussQuadrature

prob = IntegralProblem((x, p) -> cos(x), (0.0, pi / 2))
sol = solve(prob, GaussLegendre(n = 64))
source
Integrals.QuadratureRuleType
QuadratureRule(q; n=250)

Evaluate a user-supplied fixed quadrature rule.

The rule function q must support nodes, weights = q(n) and return nodes and weights for the standard interval or hypercube [-1, 1]^d. Integrals.jl rescales the nodes to the problem domain before evaluating the integrand. Nodes may be scalars in one dimension or vectors in multiple dimensions; weights must be scalar.

Arguments

  • q: Function that returns (nodes, weights) for a requested node count.

Keyword Arguments

  • n: Number of quadrature nodes requested from q. Must be positive.

Fields

  • q: Stored quadrature rule constructor.
  • n::Int: Stored quadrature node count.

Returns

Returns a QuadratureRule algorithm object. The method computes the fixed quadrature sum and reports success; callers are responsible for checking convergence by changing n or otherwise validating the chosen rule.

Example

using Integrals, FastGaussQuadrature

prob = IntegralProblem((x, p) -> x^4, (-1.0, 1.0))
sol = solve(prob, QuadratureRule(gausslegendre; n = 8))
source
Integrals.ArblibJLType
ArblibJL(; check_analytic=false, take_prec=false, warn_on_no_convergence=false, opts=C_NULL)

One-dimensional adaptive Gauss-Legendre integration using rigorous error bounds and precision ball arithmetic. Generally this assumes the integrand is holomorphic or meromorphic, which is the user's responsibility to verify. The result of the integral is not guaranteed to satisfy the requested tolerances, however the result is guaranteed to be within the error estimate.

Arblib.jl only supports integration of univariate real- and complex-valued functions with both inplace and out-of-place forms. See their documentation for additional details the algorithm arguments and on implementing high-precision integrands. Additionally, the error estimate is included in the return value of the integral, representing a ball.

Keyword Arguments

  • check_analytic: Whether Arblib should check analyticity assumptions.
  • take_prec: Whether to pass precision information through to the integrand.
  • warn_on_no_convergence: Whether to warn when Arblib reports non-convergence.
  • opts: Arblib option pointer or object passed to the backend.

Fields

The fields match the keyword arguments: check_analytic, take_prec, warn_on_no_convergence, and opts.

Returns

Returns an ArblibJL algorithm object. Arblib.jl must be loaded before construction.

source
Integrals.HAdaptiveIntegrationJLType
HAdaptiveIntegrationJL(; kws...)

Adaptive integration over simplices and orthotopes from HAdaptiveIntegration.jl.

This algorithm supports integration over:

  • Orthotope domains specified as (lb, ub) tuples (converted to Rectangle, Cuboid, etc.)
  • Simplex domains specified directly as HAdaptiveIntegration.Triangle, HAdaptiveIntegration.Tetrahedron, etc.

Any keyword arguments are passed directly to HAdaptiveIntegration.integrate.

Keyword Arguments

  • kws...: Backend keyword arguments forwarded to HAdaptiveIntegration.integrate.

Fields

  • kws::NamedTuple: Stored backend keyword arguments.

Returns

Returns an HAdaptiveIntegrationJL algorithm object. HAdaptiveIntegration.jl must be loaded before construction.

Example

using Integrals, HAdaptiveIntegration

# Orthotope domain (standard lb, ub)
prob = IntegralProblem((x, p) -> x[1] + x[2], (zeros(2), ones(2)))
sol = solve(prob, HAdaptiveIntegrationJL())

# Simplex domain (triangle)
prob = IntegralProblem((x, p) -> x[1] + x[2], Triangle((0.0, 0.0), (1.0, 0.0), (0.0, 1.0)))
sol = solve(prob, HAdaptiveIntegrationJL())
source
Integrals.FastTanhSinhQuadratureJLType
FastTanhSinhQuadratureJL(; rtol = 1e-12, atol = 0.0, max_levels = 10)

One-dimensional adaptive Tanh-Sinh (double exponential) quadrature from FastTanhSinhQuadrature.jl. This method uses a double exponential transformation that provides excellent convergence properties, especially for integrands with endpoint singularities or infinite derivatives at endpoints.

Keyword Arguments

  • rtol: Relative tolerance for convergence (default: 1e-12)
  • atol: Absolute tolerance for convergence (default: 0.0)
  • max_levels: Maximum number of refinement levels in adaptive integration (default: 10)

Fields

  • rtol: Stored relative tolerance.
  • atol: Stored absolute tolerance.
  • max_levels::Int: Stored maximum number of refinement levels.

Returns

Returns a FastTanhSinhQuadratureJL algorithm object. FastTanhSinhQuadrature.jl must be loaded before construction.

Example

using Integrals, FastTanhSinhQuadrature

prob = IntegralProblem((x, p) -> sqrt(x), (0.0, 1.0))
sol = solve(prob, FastTanhSinhQuadratureJL(rtol = 1e-10))

Limitations

  • Only supports 1D, 2D, and 3D integration
  • Does not support batched evaluation
  • Does not support in-place integrands

References

@article{takahasi1974double,
title={Double exponential formulas for numerical integration},
author={Takahasi, Hidetosi and Mori, Masatake},
journal={Publications of the Research Institute for Mathematical Sciences},
volume={9},
number={3},
pages={721--741},
year={1974},
publisher={Research Institute for Mathematical Sciences}
}
source
Integrals.ChangeOfVariablesType
ChangeOfVariables(fu2gv, alg)

Apply a change of variables from ∫ f(u,p) du to an equivalent integral ∫ g(v,p) dv using a helper function fu2gv(f, u_domain) -> (g, v_domain). The transformed integrand g must obey the same IntegralFunction or BatchIntegralFunction calling convention as f.

This meta-algorithm allows users to apply custom or alternative transformations when integrating, particularly useful for handling infinite domains where different transformations may provide better accuracy for specific integrand types.

Arguments

  • fu2gv: A transformation function with signature (f, domain) -> (g, new_domain) that transforms the integrand and domain. Built-in options include:
  • alg: The underlying integration algorithm to use (e.g., QuadGKJL(), HCubatureJL())

Fields

  • fu2gv: Stored transformation function.
  • alg: Stored wrapped algorithm.

Returns

Returns a ChangeOfVariables meta-algorithm. When solved, the result is reported as a solution of the original integral problem.

Example

using Integrals

f(x, p) = exp(-x^2)
prob = IntegralProblem(f, (-Inf, Inf))

# Use alternative tan transformation instead of default
alg = ChangeOfVariables(transformation_tan_inf, QuadGKJL())
sol = solve(prob, alg)

See also: transformation_if_inf, transformation_tan_inf, transformation_cot_inf

source