bundles / scipy 1.17.1 / scipy / integrate / _quadpack_py / tplquad
function
scipy.integrate._quadpack_py:tplquad
Signature
def tplquad ( func , a , b , gfun , hfun , qfun , rfun , args = () , epsabs = 1.49e-08 , epsrel = 1.49e-08 ) Summary
Compute a triple (definite) integral.
Extended Summary
Return the triple integral of func(z, y, x) from x = a..b, y = gfun(x)..hfun(x), and z = qfun(x,y)..rfun(x,y).
Parameters
func: functionA Python function or method of at least three variables in the order (z, y, x).
a, b: floatThe limits of integration in x:
a<bgfun: function or floatThe 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: function or floatThe upper boundary curve in y (same requirements as
gfun).qfun: function or floatThe lower boundary surface in z. It must be a function that takes two floats in the order (x, y) and returns a float or a float indicating a constant boundary surface.
rfun: function or floatThe upper boundary surface in z. (Same requirements as
qfun.)args: tuple, optionalExtra arguments to pass to
func.epsabs: float, optionalAbsolute tolerance passed directly to the innermost 1-D quadrature integration. Default is 1.49e-8.
epsrel: float, optionalRelative tolerance of the innermost 1-D integrals. Default is 1.49e-8.
Returns
y: floatThe resultant integral.
abserr: floatAn estimate of the error.
Notes
For valid results, the integral must converge; behavior for divergent integrals is not guaranteed.
Details of QUADPACK level routines
quad calls routines from the FORTRAN library QUADPACK. This section provides details on the conditions for each routine to be called and a short description of each routine. For each level of integration, qagse is used for finite limits or qagie is used, if either limit (or both!) are infinite. The following provides a short description from [1] for each routine.
qagse
is an integrator based on globally adaptive interval subdivision in connection with extrapolation, which will eliminate the effects of integrand singularities of several types. The integration is is performed using a 21-point Gauss-Kronrod quadrature within each subinterval.
qagie
handles integration over infinite intervals. The infinite range is mapped onto a finite interval and subsequently the same strategy as in
QAGSis applied.
Array API Standard Support
tplquad has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ⛔ ⛔ JAX ⛔ ⛔ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
Compute the triple integral of ``x * y * z``, over ``x`` ranging from 1 to 2, ``y`` ranging from 2 to 3, ``z`` ranging from 0 to 1. That is, :math:`\int^{x=2}_{x=1} \int^{y=3}_{y=2} \int^{z=1}_{z=0} x y z \,dz \,dy \,dx`.import numpy as np from scipy import integrate f = lambda z, y, x: x*y*z✓
integrate.tplquad(f, 1, 2, 2, 3, 0, 1)
✗f = lambda z, y, x: x*y*z
✓integrate.tplquad(f, 0, 1, 0, lambda x: 1-2*x, 0, lambda x, y: 1-x-2*y)
✗f = lambda z, y, x, a: a*x*y*z
✓integrate.tplquad(f, 0, 1, 0, 1, 0, 1, args=(1,)) integrate.tplquad(f, 0, 1, 0, 1, 0, 1, args=(3,))✗
f = lambda x, y, z: np.exp(-(x ** 2 + y ** 2 + z ** 2))
✓integrate.tplquad(f, -np.inf, np.inf, -np.inf, np.inf, -np.inf, np.inf)
✗See also
- dblquad
Double integrals
- fixed_quad
Fixed-order Gaussian quadrature
- nquad
N-dimensional integrals
- quad
Adaptive quadrature using QUADPACK
- romb
Integrators for sampled data
- scipy.special
For coefficients and roots of orthogonal polynomials
- simpson
Integrators for sampled data
Aliases
-
scipy.integrate.tplquad