【问题标题】:Mismatch in values calculated by scipy.integratescipy.integrate 计算的值不匹配
【发布时间】:2022-01-18 06:18:19
【问题描述】:

在 scipy 模块中使用积分时,我注意到积分的值与预期值(我手动计算的)不匹配。

我有一个简单的函数如下:

import math
def integrand(x, L):
    return (math.cos(sc.pi * x / L))**2
     

L=10
I = quad(integrand, 0, 1, args=(L))

I = 0.9677446418943196 # from scipy

但理论上,结果应该是 0.5519233944327677。我很困惑为什么存在差异。

我试图找到的积分如下:

【问题讨论】:

  • 真实值为0.9677446

标签: python-3.x numpy math scipy integral


【解决方案1】:

scipy 是正确的。你的计算不正确:

请注意,给定的 Decimal 与 scipy 获得的一致。这个问题最适合stackexchange。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 1970-01-01
    • 2021-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多