Error in besselJ(pi/2, 1E-15)?
besselJ(pi/2, sqrt(0.1)^(24:40))
[1] 4.720012e-01 4.720012e-01 4.720012e-01 4.720012e-01 4.720012e-01
1e-12 1e-13
1e-14
[6] 4.720012e-01 4.720012e-01 1.492599e+15 1.000000e+00 1.000000e+00
1e-15 1e-16
[11] 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00
1 e-17 1e-18
1e-19
[16] 1.000000e+00 1.000000e+00
1e-20
besselJ(pi/1, 1E-15)
[1] -3.042422e+14 For what it's worth, the besselj function in Octave 8.4 doesn't do this. octave:4> besselj(0.1.^(12:20), pi/2) ans = 0.4720 0.4720 0.4720 0.4720 0.4720 0.4720 0.4720 0.4720 0.4720 Bessel functions are most commonly wanted at integer and half-integer orders, so it's not surprising that a problem like this could go unnoticed for a while.
On Mon, 29 Dec 2025 at 05:29, Leo Mada via R-help <r-help at r-project.org> wrote:
Dear R-Users,
besselJ(pi/2, 0)
# 0.4720012
besselJ(pi/2, 1E-14)
# 0.4720012
besselJ(pi/2, 1E-15)
# 4.720012e+14
There seems to be an error in besselJ(pi/2, eps), where eps is close to 0; although besselJ(pi/2, 0) is well behaved.
I am not an expert in the field - but it doesn't seem right.
Sincerely,
Leonard
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.