{ } Raw JSON

bundles / scipy 1.17.1 / scipy / integrate / _quadrature / fixed_quad

function

scipy.integrate._quadrature:fixed_quad

source: /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 : callable

A 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 : float

Lower limit of integration.

b : float

Upper limit of integration.

args : tuple, optional

Extra arguments to pass to function, if any.

n : int, optional

Order of quadrature integration. Default is 5.

Returns

val : float

Gaussian quadrature approximation to the integral

none : None

Statically returned value of None

Notes

Array API Standard Support

fixed_quad 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-arrayapi for more information.

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)
print(1/9.0)  # analytical result
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

See also

cumulative_trapezoid

cumulative integration for sampled data

dblquad

double integrals

quad

adaptive quadrature using QUADPACK

romb

integrators for sampled data

simpson

integrators for sampled data

tplquad

triple integrals

Aliases

  • scipy.integrate.fixed_quad

Referenced by

This package