scipy.integrate.fixed_quad

scipy.integrate.fixed_quad(func, a, b, args=(), n=5)[源代码]

用定阶高斯求积计算定积分。

集成 func 从… ab 利用阶高斯求积 n

参数
func可调用

要集成的Python函数或方法(必须接受向量输入)。如果积分向量值函数,则返回的数组必须具有形状 (..., len(x))

a浮动

积分下限。

b浮动

积分上限。

args元组,可选

要传递给函数的额外参数(如果有)。

n整型,可选

正交积分的阶数。默认值为5。

退货
val浮动

积分的高斯求积逼近

none

静态返回值None

参见

quad

使用故障诊断仪的自适应正交

dblquad

重积分

tplquad

三重积分

romberg

自适应Romberg求积

quadrature

自适应高斯求积

romb

采样数据的积分器

simpson

采样数据的积分器

cumulative_trapezoid

采样数据的累积积分

ode

ODE积分器

odeint

ODE积分器

示例

>>> from scipy import integrate
>>> f = lambda x: x**8
>>> integrate.fixed_quad(f, 0.0, 1.0, n=4)
(0.1110884353741496, None)
>>> integrate.fixed_quad(f, 0.0, 1.0, n=5)
(0.11111111111111102, None)
>>> print(1/9.0)  # analytical result
0.1111111111111111
>>> integrate.fixed_quad(np.cos, 0.0, np.pi/2, n=4)
(0.9999999771971152, None)
>>> integrate.fixed_quad(np.cos, 0.0, np.pi/2, n=5)
(1.000000000039565, None)
>>> np.sin(np.pi/2)-np.sin(0)  # analytical result
1.0