Dear R-Users,

I suspected it is a catastrophic loss of precision. Unfortunately, it popped up 
in an unexpected way. I was plotting some curves using the Bessel function , 
something like this:

curve(besselJ(x, pi/2-x), 0, 2*pi, ylim = c(-2,2), n = 101)
abline(v = pi/2, col = "red", lty = 2)
# n = 101 is the default;

Note that the error is generated for a large set of values of x:
median (besselJ(seq(0, 1, length.out = 1025), 1E-15))
# 9.38233e+14

Sincerely,

Leonard

________________________________
From: Leo Mada <[email protected]>
Sent: Sunday, December 28, 2025 6:28 PM
To: Leo Mada via R-help <[email protected]>
Subject: Error in besselJ(pi/2, 1E-15)?

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]]

______________________________________________
[email protected] 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.

Reply via email to