bundles / scipy latest / scipy / integrate / _quadrature / fixed_quad
function
scipy.integrate._quadrature:fixed_quad
source: build-install/usr/lib/python3.14/site-packages/scipy/integrate/_quadrature.py:181
Signature
def fixed_quad(func, a, b, args = (), n = 5)Summary
Compute a definite integral using fixed-order Gaussian quadrature.
Extended Summary
Integrate func from a to b using Gaussian quadrature of order n.
Parameters
func: callableA Python function or method to integrate (must accept vector inputs). If integrating a vector-valued function, the returned array must have shape
(..., len(x)).a: floatLower limit of integration.
b: floatUpper limit of integration.
args: tuple, optionalExtra arguments to pass to function, if any.
n: int, optionalOrder of quadrature integration. Default is 5.
Returns
val: floatGaussian quadrature approximation to the integral
none: NoneStatically returned value of None
Examples
from scipy import integrate import numpy as np f = lambda x: x**8✓
integrate.fixed_quad(f, 0.0, 1.0, n=4) integrate.fixed_quad(f, 0.0, 1.0, n=5)✗
(np.float64(0.11111111111111102), None)
print(1/9.0) # analytical result
✓0.1111111111111111
integrate.fixed_quad(np.cos, 0.0, np.pi/2, n=4) integrate.fixed_quad(np.cos, 0.0, np.pi/2, n=5) np.sin(np.pi/2)-np.sin(0) # analytical result✗
np.float64(1.0)
See also
Aliases
scipy.integrate.fixed_quad