Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

integrate.dblquad

Numerically computes a definite double integral of func(y, x), with x integrated from a to b and y bounded by gfun(x) and hfun(x). It returns the integral estimate together with an error estimate.

How it works

dblquad numerically evaluates a double integral by integrating func(y, x) with respect to y between gfun(x) and hfun(x), then integrating those results with respect to x from a to b. The boundary functions may instead be constants, and epsabs and epsrel control the inner quadrature tolerance.

Syntax

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

Parameters

NameTypeDescription
funccallableIntegrand accepting y first and x second.
a, bfloatLower and upper limits for x, with a < b.
gfuncallable or floatLower y boundary as a function of x or a constant.
hfuncallable or floatUpper y boundary as a function of x or a constant.
argssequence, optionalAdditional positional arguments passed to func.
epsabsfloat, optionalAbsolute tolerance for the inner quadrature.
epsrelfloat, optionalRelative tolerance for the inner integrals.

Returns

A tuple containing y, the resultant integral, and abserr, an estimate of the error.

Key points

  • Use dblquad for numerical integration over a two-dimensional region.
  • The integrand is called with y as its first argument and x as its second.
  • The x interval is fixed by a and b, while y bounds can depend on x.
  • gfun may define a lower y boundary as a function of x.
  • hfun defines the upper y boundary and follows the same callable-or-constant pattern.
  • epsabs controls the absolute tolerance of the inner one-dimensional quadrature.

Common mistakes

  • The x limits are documented with the requirement a < b.
  • When epsabs is nonpositive, epsrel must satisfy the documented lower bounds.

Example: Integrate over a rectangular region

from scipy.integrate import dblquad

value, error = dblquad(
    lambda y, x: x * y**2,
    0, 2,
    lambda x: 0,
    lambda x: 1,
)
print(value)  # 0.6666666666666666

Integrates x·y² over 0 ≤ x ≤ 2 and 0 ≤ y ≤ 1, returning the estimated value and error.

When to use it

Rectangular-domain integration

Evaluate a surface integral over a region with fixed rectangular bounds.

Curved-domain integration

Integrate where the lower or upper y boundary changes with x.

Tolerance-aware numerical integration

Estimate numerical integration error alongside the computed value.

Interview questions

QWhat argument order and integration region does dblquad use?

The integrand receives y first and x second: func(y, x). The outer variable x runs from a to b, while y runs from gfun(x) to hfun(x).

Follow-up: How can constant y bounds be supplied? Pass numeric values instead of callables, such as 0 and 1.

QHow are variable and constant boundaries represented?

gfun and hfun can each be a callable of x that returns a y boundary, or a float representing a constant boundary. This allows regions whose vertical limits vary with x.

Follow-up: What is the role of args? It supplies extra positional values to func in addition to y and x.

QWhat does dblquad return, and how is accuracy controlled?

The function returns a pair: y, the resultant integral, and abserr, an estimate of the error. epsabs and epsrel set absolute and relative tolerances for the inner one-dimensional integrations.

Follow-up: What accuracy target is documented? dblquad seeks abs(i-result) <= max(epsabs, epsrel*abs(i)) for the inner integral i.

  • scipy.integrate.quad
  • scipy.integrate.tplquad
  • scipy.integrate.nquad

Source: dblquad — SciPy v1.18.0 Manual. Checked 2026-10-15.