use*_*770 2 python arrays integration scipy quad
我正在尝试创建一个将在计算中进一步使用的整数值数组.问题是integrate.quad返回(回答,错误).我不能在其他计算中使用它,因为它不是浮点数; 它是一组两个数字.
War*_*ser 10
@BrendanWood的答案很好,而且你已经接受了,所以它显然对你有用,但还有另一个python成语来处理这个问题.Python支持"多重赋值",这意味着你可以说x, y = 100, 200分配x = 100和y = 200.(有关介绍性python教程中的示例,请参阅http://docs.python.org/2/tutorial/introduction.html#first-steps-towards-programming.)
要使用此想法quad,您可以执行以下操作(对Brendan示例的修改):
# Do the integration on f over the interval [0, 10]
value, error = integrate.quad(f, 0, 10)
# Print out the integral result, not the error
print('The result of the integration is %lf' % value)
Run Code Online (Sandbox Code Playgroud)
我发现这段代码更容易阅读.