scijit.integrate.dblquad

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

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

int_a^b dx int_{gfun(x)}^{hfun(x)} func(y, x) dy, an nquad of depth two.

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

Integrand, with the inner variable first.

a, bfloat

Outer (x) limits. Either may be infinite.

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

Lower and upper inner (y) limits. Either may be a constant or a callback, in any combination. A callback receives the outer coordinate alone; a form taking the args entries after it 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 both levels.

limitint, optional

Subdivision cap, applied at both levels. Default 50.

Returns:
valuefloat

Approximation to the double integral.

abserrfloat

The LARGEST error estimate over both levels.

Raises:
TypeError

func or a limit callback is not a plain @njit function, a limit callback’s arity is neither 1 nor 1 + 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 either level, which is quad()’s own set of conditions.

See also

scipy.integrate.dblquad

The scipy routine this mirrors.

Notes

limit has no scipy counterpart, and a limit callback taking the args entries after its coordinate 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(y, x):                      # inner variable FIRST
...     return x * y * y
>>> @njit
... def hfun(x):
...     return 1.0 - x
>>> @njit
... def run():
...     return si.dblquad(f, 0.0, 1.0, 0.0, hfun)[0]
>>> run()
0.016666666666666666