scijit.integrate.tplquad

scijit.integrate.tplquad(func, a, b, gfun, hfun, qfun, rfun, args=(), epsabs=1.49e-08, epsrel=1.49e-08, limit=50)

Triple integral of func(z, y, x) over a curved region.

int_a^b dx int_{gfun(x)}^{hfun(x)} dy int_{qfun(x,y)}^{rfun(x,y)} func(z, y, x) dz, an nquad of depth three.

Parameters:
func@njit function func(z, y, x, *args) -> float

Integrand, innermost variable first.

a, bfloat

Outer (x) limits. Either may be infinite.

gfun, hfunfloat, or @njit function g(x) -> float

Lower and upper y limits.

qfun, rfunfloat, or @njit function q(x, y) -> float

Lower and upper z limits. As callbacks they take (x, y), outermost variable first, the opposite order from the integrand. As with gfun/hfun, a form taking the args entries after the coordinates is accepted as well.

argstuple, optional

Extra parameters, passed to func. Each entry is a real number or an array of real numbers.

epsabs, epsrelfloat, optional

Accuracy request, applied at all three levels.

limitint, optional

Subdivision cap, applied at all three levels. Default 50.

Returns:
valuefloat

Approximation to the triple integral.

abserrfloat

The LARGEST error estimate over the three levels.

Raises:
TypeError

func or a limit callback is not a plain @njit function, a limit callback’s arity is neither its coordinate count nor that plus len(args), or func returns a complex value. TypingError inside @njit for the first two, which are compile-time questions.

ValueError

An args entry is not a real number or an array of them, or QUADPACK refuses the settings of some level, which is quad()’s own set of conditions.

See also

scipy.integrate.tplquad

The scipy routine this mirrors.

Notes

limit has no scipy counterpart, and a limit callback taking the args entries after its coordinates is additive. No scipy-shaped call reaches either.

Examples

>>> import numpy as np
>>> from numba import njit
>>> import scijit.integrate as si
>>> @njit
... def f(z, y, x):                   # innermost variable FIRST
...     return x * y * y * z * z * z
>>> @njit
... def run():                        # box 0<x<1, 0<y<2, 0<z<3
...     return si.tplquad(f, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0)[0]
>>> run()
26.999999999999996