當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy integrate.romb用法及代碼示例

本文簡要介紹 python 語言中 scipy.integrate.romb 的用法。

用法:

scipy.integrate.romb(y, dx=1.0, axis=-1, show=False)#

使用函數樣本的 Romberg 積分。

參數

y array_like

由函數的 2**k + 1 等距樣本組成的向量。

dx 浮點數,可選

樣本間距。默認值為 1。

axis 整數,可選

要沿其集成的軸。默認值為 -1(最後一個軸)。

show 布爾型,可選

當 y 是單個一維數組時,如果此參數為 True,則打印顯示 Richardson 從樣本外推的表格。默認為假。

返回

romb ndarray

軸的綜合結果。

例子

>>> 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

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.integrate.romb。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。