scipy.integrate.dblquad

scipy.integrate.dblquad(func, a, b, gfun, hfun, args=(), epsabs=1.49e-08, epsrel=1.49e-08)[source]

Compute a double integral.

Return the double (definite) integral of func(y, x) from x = a..b and y = gfun(x)..hfun(x).

Parameters
funccallable

A Python function or method of at least two variables: y must be the first argument and x the second argument.

a, bfloat

The limits of integration in x: a < b

gfuncallable or float

The lower boundary curve in y which is a function taking a single floating point argument (x) and returning a floating point result or a float indicating a constant boundary curve.

hfuncallable or float

The upper boundary curve in y (same requirements as gfun).

argssequence, optional

Extra arguments to pass to func.

epsabsfloat, optional

Absolute tolerance passed directly to the inner 1-D quadrature integration. Default is 1.49e-8. dblquad` tries to obtain an accuracy of abs(i-result) <= max(epsabs, epsrel*abs(i)) where i = inner integral of func(y, x) from gfun(x) to hfun(x), and result is the numerical approximation. See epsrel below.

epsrelfloat, optional

Relative tolerance of the inner 1-D integrals. Default is 1.49e-8. If epsabs <= 0, epsrel must be greater than both 5e-29 and 50 * (machine epsilon). See epsabs above.

Returns
yfloat

The resultant integral.

abserrfloat

An estimate of the error.

See also

quad

single integral

tplquad

triple integral

nquad

N-dimensional integrals

fixed_quad

fixed-order Gaussian quadrature

quadrature

adaptive Gaussian quadrature

odeint

ODE integrator

ode

ODE integrator

simpson

integrator for sampled data

romb

integrator for sampled data

scipy.special

for coefficients and roots of orthogonal polynomials

Examples

Compute the double integral of x * y**2 over the box x ranging from 0 to 2 and y ranging from 0 to 1.

>>> from scipy import integrate
>>> f = lambda y, x: x*y**2
>>> integrate.dblquad(f, 0, 2, lambda x: 0, lambda x: 1)
    (0.6666666666666667, 7.401486830834377e-15)