python中eps是什么意思_如何在中使用参数epsabsscipy.integrate.quad在Python中?

根据scipy手册,quad function要指定limit参数An upper bound on the number of subintervals used in the adaptive algorithm.

默认情况下,limit的值是50。

你的代码返回警告信息quadpack.py:364: IntegrationWarning: The maximum number of

subdivisions (50) has been achieved. If increasing the limit yields

no improvement it is advised to analyze the integrand in order to

determine the difficulties. If the position of a local difficulty

can be determined (singularity, discontinuity) one will probably

gain from splitting up the interval and calling the integrator on

the subranges. Perhaps a special-purpose integrator should be used.

warnings.warn(msg, IntegrationWarning)

您必须更改limit参数,即:from scipy.integrate import quad

import numpy

integrand = lambda x: numpy.sin(x) / x ** 2

print(quad(integrand, 1e-16, 1.0, epsabs = 1e-4, limit=100))

输出:(36.7600787611414, 3.635057215414274e-05)

输出中没有警告消息。细分数小于100且quad达到了要求的精度。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值