Python:辛普森规则,曲线下正面积的否定答案?

问题描述 投票:0回答:1

我有

y1=[  9.49110000e-004   4.74145420e-004   1.41847155e-008   3.33228420e-028
       3.76352289e-081   4.48206815e-193   0.00000000e+000   0.00000000e+000
       0.00000000e+000   0.00000000e+000   0.00000000e+000] 

x=[ 112.  111.97667396  111.90666665  111.78989038  111.62619837  
     111.41538384  111.15717866  110.85125168  110.49720654  110.09457901
    109.64283388]

所有

y
值均为正值,因此曲线下面积应为正值。但是当我尝试使用辛普森规则进行积分时

  from scipy.integrate import simps
  b= simps(y1, x)

  print b

我得到

-2.45630795891e-05
作为答案。我究竟做错了什么?

python scipy numerical-integration simpsons-rule
1个回答
7
投票

x
正在减少,因此您正在从右向左积分。这会翻转结果的符号。

© www.soinside.com 2019 - 2024. All rights reserved.