0

I tried to use Scipy and EXCEL to calculate Bessel function, but they give different results. Do you know why? Thanks in advance.

Python code:

import scipy.special as ss


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

EXCEL (I use the OneDrive Excel web app of today's version)

=BESSELK(0,2155481626213; 1)

The result from Python is 4.405746469429914
The result from Excel is 4,405746474969860.

aura
  • 383
  • 7
  • 24

2 Answers2

1

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.

0

As @HubertusKaiser says; 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. Now imagine doing a lot of those "wrong" floating-points calculations, you end up with the error difference you see

CutePoison
  • 4,679
  • 5
  • 28
  • 63