# NAG FL Interfaces17alf (bessel_​zeros)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

s17alf determines the leading ${\mathbf{n}}$ zeros of one of the Bessel functions ${J}_{\alpha }\left(x\right)$, ${Y}_{\alpha }\left(x\right)$, ${J}_{\alpha }^{\prime }\left(x\right)$ or ${Y}_{\alpha }^{\prime }\left(x\right)$ for real $x$ and non-negative $\alpha$.

## 2Specification

Fortran Interface
 Subroutine s17alf ( a, n, mode, rel, x,
 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)
#include <nag.h>
 void s17alf_ (const double *a, const Integer *n, const Integer *mode, const double *rel, double x[], Integer *ifail)
The routine may be called by the names s17alf or nagf_specfun_bessel_zeros.

## 3Description

s17alf attempts to find the leading $N$ zeros of one of the Bessel functions ${J}_{\alpha }\left(x\right)$, ${Y}_{\alpha }\left(x\right)$, ${J}_{\alpha }^{\prime }\left(x\right)$ or ${Y}_{\alpha }^{\prime }\left(x\right)$, where $x$ is real. When $\alpha$ 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 $\alpha \ge 0$, the $\mathit{n}$th positive zero is denoted by ${j}_{\alpha ,\mathit{n}},{j}_{\alpha ,\mathit{n}}^{\prime },{y}_{\alpha ,\mathit{n}}$ and ${y}_{\alpha ,\mathit{n}}^{\prime }$, respectively, for $\mathit{n}=1,2,\dots ,N$, except that $x=0$ is counted as the first zero of ${J}_{\alpha }^{\prime }\left(x\right)$ when $\alpha =0$. Since ${J}_{0}^{\prime }\left(x\right)=-{J}_{1}\left(x\right)$, it, therefore, follows that ${j}_{0,1}^{\prime }=0$ and ${j}_{0,n}^{\prime }=-{j}_{1,n-1}$ for $n=2,3,\dots ,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

## 5Arguments

1: $\mathbf{a}$Real (Kind=nag_wp) Input
On entry: the order $\alpha$ of the function.
Constraint: $0.0\le {\mathbf{a}}\le 100000.0$.
2: $\mathbf{n}$Integer Input
On entry: the number $N$ of zeros required.
Constraint: ${\mathbf{n}}\ge 1$.
3: $\mathbf{mode}$Integer Input
On entry: specifies the form of the function whose zeros are required.
${\mathbf{mode}}=1$
The zeros of ${J}_{\alpha }\left(x\right)$ are required.
${\mathbf{mode}}=2$
The zeros of ${Y}_{\alpha }\left(x\right)$ are required;
${\mathbf{mode}}=3$
The zeros of ${J}_{\alpha }^{\prime }\left(x\right)$ are required;
${\mathbf{mode}}=4$
The zeros of ${Y}_{\alpha }^{\prime }\left(x\right)$ are required.
Constraint: $1\le {\mathbf{mode}}\le 4$.
4: $\mathbf{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: ${\mathbf{rel}}>0.0$.
5: $\mathbf{x}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
On exit: the $N$ required zeros of the function specified by mode.
6: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{a}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{a}}\le 100000.0$.
On entry, ${\mathbf{a}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{a}}\ge 0.0$.
On entry, ${\mathbf{mode}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mode}}\le 4$.
On entry, ${\mathbf{mode}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mode}}\ge 1$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 1$.
On entry, ${\mathbf{rel}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{rel}}>0.0$.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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

## 8Parallelism and Performance

s17alf is not threaded in any implementation.

None.

## 10Example

This example determines the leading five positive zeros of the Bessel function ${J}_{0}\left(x\right)$.

### 10.1Program Text

Program Text (s17alfe.f90)

### 10.2Program Data

Program Data (s17alfe.d)

### 10.3Program Results

Program Results (s17alfe.r)