Skip to content
Prev 398382 / 398500 Next

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
[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:
Message-ID: <CABcYAd+KrQWhhAzibpo+EHOQs9+tXNtC7yUDgHAPktGX-Wy9ZA@mail.gmail.com>
In-Reply-To: <DBAP192MB0956A03DB297C16C857A695084BEA@DBAP192MB0956.EURP192.PROD.OUTLOOK.COM>