简体   繁体   English

辛普森的方法集成 scipy.integrate.simps

[英]Simpson's method integration scipy.integrate.simps

I'm learning about using simpson's method for integration.我正在学习使用辛普森的集成方法。 I've been reading material to learn the basis of using it but I am still having trouble even getting it to work我一直在阅读材料以了解使用它的基础,但我仍然无法使用它

import numpy as np
import scipy.integrate as integrate

x = np.array[0.1,50] 
y = 0.04*(x**(0.2*x))
result = integrate.simps(y,x)
print result

My problems with the above code are:我上面代码的问题是:

1) The first issue has been solved and edited 1)第一个问题已经解决和编辑

2) I don't fully understand how the integrate command should work. 2)我不完全理解集成命令应该如何工作。 I know that in integrate.simps(y,x) y represents my function/polynomial to be integrated and x represents the points at which y is evaluated.我知道在integrate.simps(y,x) y 代表我要积分的函数/多项式,x 代表评估y 的点。

3) I do not understand how or where to adjust the number of intervals (N) for my integral 3)我不明白如何或在哪里调整积分的间隔数(N)

4) my x = np.array[] produces an error message 'builtin_function_or_method' object has no attribute ' getitem ' 4) 我的 x = np.array[] 产生一条错误消息 'builtin_function_or_method' 对象没有属性 ' getitem '

The function i'm trying to integrate is:我试图整合的功能是:

∫x*(0.4x^(.2x)) ∫x*(0.4x^(.2x))

upper limit : 50.0上限:50.0

lower limit : 0.1下限:0.1

对于您的第二个问题,请为 array() 使用括号

x = np.array( [0.1,50]  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM