简体   繁体   English

为什么 Scipy 和 EXCEL 中的 Bessel function 给出不同的结果?

[英]Why does Bessel function in Scipy and EXCEL give different results?

I tried to use Scipy and EXCEL to calculate Bessel function, but they give different results.我尝试使用 Scipy 和 EXCEL 来计算贝塞尔 function,但它们给出了不同的结果。 Do you know why?你知道为什么吗? Thanks in advance.提前致谢。

Python code: Python代码:

import scipy.special as ss


result = ss.k1(0.2155481626213)
print(result)

EXCEL (I use the OneDrive Excel web app of today's version) EXCEL(我使用的是今天版本的 OneDrive Excel web 应用程序)

=BESSELK(0,2155481626213; 1)

The result from Python is 4.405746469429914 Python 的结果是4.405746469429914
The result from Excel is 4,405746474969860 . Excel 的结果是4,405746474969860

Since the error of the result is quite small, the complexity of the numerical calculations and the error propagation can cause the difference.由于结果的误差很小,数值计算的复杂性和误差传播会导致差异。

Side note: even Wolfram Alpha got a different value:4.405746469430.旁注:即使是 Wolfram Alpha 也有不同的值:4.405746469430。

As @HubertusKaiser says;正如@HubertusKaiser 所说; the error is so small that we can assign it to rounding-errors/floating-points.误差非常小,我们可以将其分配给舍入误差/浮点数。

There's an excelent explanation why 0.1+0.2.= 0.3 for most computers here .对于大多数计算机,这里有一个很好的解释为什么0.1+0.2.= 0.3 Now imagine doing a lot of those "wrong" floating-points calculations, you end up with the error difference you see现在想象做很多那些“错误”的浮点计算,你最终会看到你看到的误差差异

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

相关问题 为什么在Python中的t检验(scipy,statsmodels)给出的结果与R,Stata或Excel不同? - Why does t-test in Python (scipy, statsmodels) give results different from R, Stata, or Excel? 为什么scipy bessel root发现不返回零根? - Why does scipy bessel root finding not return roots at zero? 为什么 scipy.optimize.basinhopping 给出不同的结果 - why scipy.optimize.basinhopping give different results Matlab和numpy / scipy中的FFT给出不同的结果 - FFT in Matlab and numpy / scipy give different results 为什么和何时在dataframe.apply中给出的结果不同于在单个元素上使用函数的结果? - Why and when does dataframe.apply give different results than using the function on an individual element? 为什么 self 没有定义并给我不同的结果? - Why does self is not defined and give me different results? 为什么用php编写的河豚代码在Python中给出不同的结果? - Why does blowfish code written in php give different results in Python? 为什么myHDL手册中的示例为我提供了不同的结果? - Why does this example from the myHDL manual give me different results? 不同的scipy版本为curve_fit提供不同的结果 - Different scipy versions give different results for curve_fit 为什么scipy.stats.nanmean与numpy.nansum给出不同的结果? - Why does scipy.stats.nanmean give different result from numpy.nansum?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM