scipy.integrate.
romb#
- scipy.integrate.romb(y, dx=1.0, axis=-1, show=False)[source]#
使用函數樣本的 Romberg 積分。
- 參數:
- yarray_like (類陣列)
函數的
2**k + 1
個等間隔樣本的向量。- dxfloat, optional (可選)
樣本間距。預設值為 1。
- axisint, optional (可選)
沿著積分的軸。預設值為 -1 (最後一個軸)。
- showbool, optional (可選)
當 y 是單個 1 維陣列時,如果此參數為 True,則印出表格顯示來自樣本的 Richardson 外插法。預設值為 False。
- 返回值:
- rombndarray
沿著 axis 的積分結果。
另請參閱
quad
使用 QUADPACK 的自適應積分
fixed_quad
固定階高斯積分
dblquad
二重積分
tplquad
三重積分
simpson
取樣資料的積分器
cumulative_trapezoid
取樣資料的累積積分
範例
>>> from scipy import integrate >>> import numpy as np >>> x = np.arange(10, 14.25, 0.25) >>> y = np.arange(3, 12)
>>> integrate.romb(y) 56.0
>>> y = np.sin(np.power(x, 2.5)) >>> integrate.romb(y) -0.742561336672229
>>> integrate.romb(y, show=True) Richardson Extrapolation Table for Romberg Integration ====================================================== -0.81576 4.63862 6.45674 -1.10581 -3.02062 -3.65245 -2.57379 -3.06311 -3.06595 -3.05664 -1.34093 -0.92997 -0.78776 -0.75160 -0.74256 ====================================================== -0.742561336672229 # may vary