NAG Library Routine Document

s17alf (bessel_zeros)


s17alf determines the leading n zeros of one of the Bessel functions Jαx, Yαx, Jαx or Yαx for real x and non-negative α.


Fortran Interface
Subroutine s17alf ( a, n, mode, rel, x, ifail)
Integer, Intent (In):: n, mode
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: a, rel
Real (Kind=nag_wp), Intent (Out):: x(n)
C Header Interface
#include <nagmk26.h>
void  s17alf_ (const double *a, const Integer *n, const Integer *mode, const double *rel, double x[], Integer *ifail)


s17alf attempts to find the leading N zeros of one of the Bessel functions Jαx, Yαx, Jαx or Yαx, where x is real. When α is real, these functions each have an infinite number of real zeros, all of which are simple with the possible exception of x=0. If α0, the nth positive zero is denoted by jα,n,jα,n,yα,n and yα,n, respectively, for n=1,2,,N, except that x=0 is counted as the first zero of Jαx when α=0. Since J0x=-J1x, it therefore follows that j0,1=0 and j0,n=-j1,n-1 for n=2,3,,N-1. Further details can be found in Section 9.5 of Abramowitz and Stegun (1972).
s17alf is based on Algol 60 procedures given by Temme (1979). Initial approximations to the zeros are computed from asymptotic expansions. These are then improved by higher-order Newton iteration making use of the differential equation for the Bessel functions.


Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Temme N M (1976) On the numerical evaluation of the ordinary Bessel function of the second kind J. Comput. Phys. 21 343–350
Temme N M (1979) An algorithm with Algol 60 program for the computation of the zeros of ordinary Bessel functions and those of their derivatives J. Comput. Phys. 32 270–279


1:     a – Real (Kind=nag_wp)Input
On entry: the order α of the function.
Constraint: 0.0a100000.0.
2:     n – IntegerInput
On entry: the number N of zeros required.
Constraint: n1.
3:     mode – IntegerInput
On entry: specifies the form of the function whose zeros are required.
The zeros of Jαx are required.
The zeros of Yαx are required;
The zeros of Jαx are required;
The zeros of Yαx are required.
Constraint: 1mode4.
4:     rel – Real (Kind=nag_wp)Input
On entry: the relative accuracy to which the zeros are required.
Suggested value: the square root of the machine precision.
Constraint: rel>0.0.
5:     xn – Real (Kind=nag_wp) arrayOutput
On exit: the N required zeros of the function specified by mode.
6:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, a=value.
Constraint: a100000.0.
On entry, a=value.
Constraint: a0.0.
On entry, mode=value.
Constraint: mode4.
On entry, mode=value.
Constraint: mode1.
On entry, n=value.
Constraint: n1.
On entry, rel=value.
Constraint: rel>0.0.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


If the value of rel is set to 10-d, then the required zeros should have approximately d correct significant digits.

Parallelism and Performance

s17alf is not threaded in any implementation.

Further Comments



This example determines the leading five positive zeros of the Bessel function J0x.

Program Text

Program Text (s17alfe.f90)

Program Data

Program Data (s17alfe.d)

Program Results

Program Results (s17alfe.r)