# NAG FL Interfaces17dhf (airy_​bi_​complex)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

s17dhf returns the value of the Airy function $\mathrm{Bi}\left(z\right)$ or its derivative ${\mathrm{Bi}}^{\prime }\left(z\right)$ for complex $z$, with an option for exponential scaling.

## 2Specification

Fortran Interface
 Subroutine s17dhf ( z, scal, bi,
 Integer, Intent (Inout) :: ifail Complex (Kind=nag_wp), Intent (In) :: z Complex (Kind=nag_wp), Intent (Out) :: bi Character (1), Intent (In) :: deriv, scal
#include <nag.h>
 void s17dhf_ (const char *deriv, const Complex *z, const char *scal, Complex *bi, Integer *ifail, const Charlen length_deriv, const Charlen length_scal)
The routine may be called by the names s17dhf or nagf_specfun_airy_bi_complex.

## 3Description

s17dhf returns a value for the Airy function $\mathrm{Bi}\left(z\right)$ or its derivative ${\mathrm{Bi}}^{\prime }\left(z\right)$, where $z$ is complex, $-\pi <\mathrm{arg}z\le \pi$. Optionally, the value is scaled by the factor ${e}^{|\mathrm{Re}\left(2z\sqrt{z}/3\right)|}$.
The routine is derived from the routine CBIRY in Amos (1986). It is based on the relations $\mathrm{Bi}\left(z\right)=\frac{\sqrt{z}}{\sqrt{3}}\left({I}_{-1/3}\left(w\right)+{I}_{1/3}\left(w\right)\right)$, and ${\mathrm{Bi}}^{\prime }\left(z\right)=\frac{z}{\sqrt{3}}\left({I}_{-2/3}\left(w\right)+{I}_{2/3}\left(w\right)\right)$, where ${I}_{\nu }$ is the modified Bessel function and $w=2z\sqrt{z}/3$.
For very large $|z|$, argument reduction will cause total loss of accuracy, and so no computation is performed. For slightly smaller $|z|$, the computation is performed but results are accurate to less than half of machine precision. If $\mathrm{Re}\left(z\right)$ is too large, and the unscaled function is required, there is a risk of overflow and so no computation is performed. In all the above cases, a warning is given by the routine.
NIST Digital Library of Mathematical Functions
Amos D E (1986) Algorithm 644: A portable package for Bessel functions of a complex argument and non-negative order ACM Trans. Math. Software 12 265–273

## 5Arguments

1: $\mathbf{deriv}$Character(1) Input
On entry: specifies whether the function or its derivative is required.
${\mathbf{deriv}}=\text{'F'}$
$\mathrm{Bi}\left(z\right)$ is returned.
${\mathbf{deriv}}=\text{'D'}$
${\mathrm{Bi}}^{\prime }\left(z\right)$ is returned.
Constraint: ${\mathbf{deriv}}=\text{'F'}$ or $\text{'D'}$.
2: $\mathbf{z}$Complex (Kind=nag_wp) Input
On entry: the argument $z$ of the function.
3: $\mathbf{scal}$Character(1) Input
On entry: the scaling option.
${\mathbf{scal}}=\text{'U'}$
The result is returned unscaled.
${\mathbf{scal}}=\text{'S'}$
The result is returned scaled by the factor ${e}^{|\mathrm{Re}\left(2z\sqrt{z}/3\right)|}$.
Constraint: ${\mathbf{scal}}=\text{'U'}$ or $\text{'S'}$.
4: $\mathbf{bi}$Complex (Kind=nag_wp) Output
On exit: the required function or derivative value.
5: $\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, deriv has an illegal value: ${\mathbf{deriv}}=⟨\mathit{\text{value}}⟩$.
On entry, scal has an illegal value: ${\mathbf{scal}}=⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=2$
No computation because $\mathrm{Re}\left({\mathbf{z}}\right)=⟨\mathit{\text{value}}⟩$ is too large when ${\mathbf{scal}}=\text{'U'}$.
${\mathbf{ifail}}=3$
Results lack precision because $|{\mathbf{z}}|=⟨\mathit{\text{value}}⟩>⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=4$
No computation because $|{\mathbf{z}}|=⟨\mathit{\text{value}}⟩>⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=5$
No computation – algorithm termination condition not met.
${\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

All constants in s17dhf are given to approximately $18$ digits of precision. Calling the number of digits of precision in the floating-point arithmetic being used $t$, 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 s17dhf, 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,|{\mathrm{log}}_{10}|z||\right)$ represents the number of digits lost due to the argument reduction. Thus the larger the value of $|z|$, the less the precision in the result.
Empirical tests with modest values of $z$, checking relations between Airy functions $\mathrm{Ai}\left(z\right)$, ${\mathrm{Ai}}^{\prime }\left(z\right)$, $\mathrm{Bi}\left(z\right)$ and ${\mathrm{Bi}}^{\prime }\left(z\right)$, have shown errors limited to the least significant $3$$4$ digits of precision.

## 8Parallelism and Performance

s17dhf is not threaded in any implementation.

Note that if the function is required to operate on a real argument only, then it may be much cheaper to call s17ahf or s17akf.

## 10Example

This example prints a caption and then proceeds to read sets of data from the input data stream. The first datum is a value for the argument deriv, the second is a complex value for the argument, z, and the third is a character value to set the argument scal. The program calls the routine and prints the results. The process is repeated until the end of the input data stream is encountered.

### 10.1Program Text

Program Text (s17dhfe.f90)

### 10.2Program Data

Program Data (s17dhfe.d)

### 10.3Program Results

Program Results (s17dhfe.r)