📜  numpy.trapz()函数| Python

📅  最后修改于: 2022-05-13 01:55:22.946000             🧑  作者: Mango

numpy.trapz()函数| Python

numpy.trapz()函数使用复合梯形规则沿给定轴积分。

代码#1:

# Python program explaining
# numpy.trapz() function
  
# importing numpy as geek  
import numpy as geek
  
y = [1, 2, 3, 4]
  
gfg = geek.trapz( y )
  
print (gfg)

输出 :

7.5


代码#2:

# Python program explaining
# numpy.trapz() function
  
# importing numpy as geek  
import numpy as geek
  
y = [1, 2, 3, 4]
x = [5, 6, 7, 8]
  
gfg = geek.trapz(y, x)
  
print (gfg)

输出 :

7.5


代码#3:

# Python program explaining
# numpy.trapz() function
  
# importing numpy as geek  
import numpy as geek
  
y = [1, 2, 3, 4]
  
  
gfg = geek.trapz(y, dx = 2)
  
print (gfg)

输出 :

15.0