Confirmed on

R Under development (unstable) (2025-12-22 r89219)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.3 LTS

https://github.com/r-devel/r-svn/commits/50fa23f7748e9da48a15d045b6cb23a622192725/src/nmath/bessel_j.c

It's not surprising that this fails when nu is close to .Machine$double.eps (approx 1e-16, the smallest value for which 1+x != 1, i.e. precision limit of 64-bit floats), but it looks like one would have to dig through the J_bessel C code <https://github.com/r-devel/r-svn/blob/50fa23f7748e9da48a15d045b6cb23a622192725/src/nmath/bessel_j.c#L36> to see exactly where the catastrophic loss of precision happens, and what to do about it ...

  if desired I could post this on the R bug tracker (seems appropriate).

   cheers
   Ben Bolker

On 12/28/25 11:28, Leo Mada via R-help 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]]

______________________________________________
[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.

--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Associate chair (graduate), Mathematics & Statistics
Director, School of Computational Science and Engineering
* E-mail is sent at my convenience; I don't expect replies outside of working hours.

______________________________________________
[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