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)
fromx = a..b
andy = gfun(x)..hfun(x)
.Parameters: - func : callable
A Python function or method of at least two variables: y must be the first argument and x the second argument.
- a, b : float
The limits of integration in x: a < b
- gfun : callable 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.
- hfun : callable or float
The upper boundary curve in y (same requirements as gfun).
- args : sequence, optional
Extra arguments to pass to func.
- epsabs : float, optional
Absolute tolerance passed directly to the inner 1-D quadrature integration. Default is 1.49e-8.
- epsrel : float, optional
Relative tolerance of the inner 1-D integrals. Default is 1.49e-8.
Returns: - y : float
The resultant integral.
- abserr : float
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
simps
- 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 boxx
ranging from 0 to 2 andy
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)