S Chapter Contents
S Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentS18GKF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

S18GKF returns a sequence of values for the Bessel functions ${J}_{\alpha +n-1}\left(z\right)$ or ${J}_{\alpha -n+1}\left(z\right)$ for complex $z$, non-negative $\alpha <1$ and $n=1,2,\dots ,\left|N\right|+1$.

## 2  Specification

 SUBROUTINE S18GKF ( Z, A, NL, B, IFAIL)
 INTEGER NL, IFAIL REAL (KIND=nag_wp) A COMPLEX (KIND=nag_wp) Z, B(abs(NL)+1)

## 3  Description

S18GKF evaluates a sequence of values for the Bessel function of the first kind ${J}_{\alpha }\left(z\right)$, where $z$ is complex and nonzero and $\alpha$ is the order with $0\le \alpha <1$. The $\left(\left|N\right|+1\right)$-member sequence is generated for orders $\alpha ,\alpha +1,\dots ,\alpha +\left|N\right|$ when $N\ge 0$. Note that $+$ is replaced by $-$ when $N<0$. For positive orders the routine may also be called with $z=0$, since ${J}_{q}\left(0\right)=0$ when $q>0$. For negative orders the formula
 $J-qz=cosπqJqz-sinπqYqz$
is used to generate the required sequence. The appropriate values of ${J}_{q}\left(z\right)$ and ${Y}_{q}\left(z\right)$ are obtained by calls to S17DCF and S17DEF.

## 4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

## 5  Parameters

1:     Z – COMPLEX (KIND=nag_wp)Input
On entry: the argument $z$ of the function.
Constraint: ${\mathbf{Z}}\ne \left(0.0,0.0\right)$ when ${\mathbf{NL}}<0$.
2:     A – REAL (KIND=nag_wp)Input
On entry: the order $\alpha$ of the first member in the required sequence of function values.
Constraint: $0.0\le {\mathbf{A}}<1.0$.
3:     NL – INTEGERInput
On entry: the value of $N$.
Constraint: $\mathrm{abs}\left({\mathbf{NL}}\right)\le 101$.
4:     B($\mathrm{abs}{\mathbf{NL}}+1$) – COMPLEX (KIND=nag_wp) arrayOutput
On exit: with ${\mathbf{IFAIL}}={\mathbf{0}}$ or ${\mathbf{3}}$, the required sequence of function values: ${\mathbf{B}}\left(\mathit{n}\right)$ contains ${J}_{\alpha +\mathit{n}-1}\left(z\right)$ if ${\mathbf{NL}}\ge 0$ and ${J}_{\alpha -\mathit{n}+1}\left(z\right)$ otherwise, for $\mathit{n}=1,2,\dots ,\mathrm{abs}\left({\mathbf{NL}}\right)+1$.
5:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ 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 parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ 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).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{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{Z}}=\left(0.0,0.0\right)$ when ${\mathbf{NL}}<0$, or ${\mathbf{A}}<0.0$, or ${\mathbf{A}}\ge 1.0$, or $\mathrm{abs}\left({\mathbf{NL}}\right)>101$.
${\mathbf{IFAIL}}=2$
The computation has been abandoned due to the likelihood of overflow.
${\mathbf{IFAIL}}=3$
The computation has been completed but some precision has been lost.
${\mathbf{IFAIL}}=4$
The computation has been abandoned due to total loss of precision.
${\mathbf{IFAIL}}=5$
The computation has been abandoned due to failure to satisfy the termination condition.

## 7  Accuracy

All constants in S17DCF and S17DEF are specified to approximately $18$ digits of precision. If $t$ denotes the number of digits of precision in the floating point arithmetic being used, then clearly the maximum number of correct digits in the results obtained is limited by $p=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(t,18\right)$. Because of errors in argument reduction when computing elementary functions inside S17DCF and S17DEF, the actual number of correct digits is limited, in general, by $p-s$, where $s\approx \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\left|{\mathrm{log}}_{10}\left|z\right|\right|,\left|{\mathrm{log}}_{10}\left|\alpha \right|\right|\right)$ represents the number of digits lost due to the argument reduction. Thus the larger the values of $\left|z\right|$ and $\left|\alpha \right|$, the less the precision in the result.

None.

## 9  Example

This example evaluates ${J}_{0}\left(z\right),{J}_{1}\left(z\right),{J}_{2}\left(z\right)$ and ${J}_{3}\left(z\right)$ at $z=0.6-0.8i$, and prints the results.

### 9.1  Program Text

Program Text (s18gkfe.f90)

### 9.2  Program Data

Program Data (s18gkfe.d)

### 9.3  Program Results

Program Results (s18gkfe.r)