s Chapter Contents
s Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_bessel_k_alpha_scaled (s18ehc)

## 1  Purpose

nag_bessel_k_alpha_scaled (s18ehc) returns a sequence of values for the scaled modified Bessel functions ${e}^{x}{K}_{\alpha +n}\left(x\right)$ for real $x>0$, selected values of $\alpha \ge 0$ and $n=0,1,\dots ,N$.

## 2  Specification

 #include #include
 void nag_bessel_k_alpha_scaled (double x, Integer ia, Integer ja, Integer nl, double b[], NagError *fail)

## 3  Description

nag_bessel_k_alpha_scaled (s18ehc) evaluates a sequence of values for the scaled modified Bessel function of the second kind ${e}^{x}{K}_{\alpha }\left(x\right)$, where $x$ is real and non-negative and $\alpha \in \left\{0,\frac{1}{2},\frac{1}{3},\frac{1}{4},\frac{2}{3},\frac{3}{4}\right\}$ is the order. The $\left(N+1\right)$-member sequence is generated for orders $\alpha ,\alpha +1,\dots ,\alpha +N$.

## 4  References

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

## 5  Arguments

1:     xdoubleInput
On entry: the argument $x$ of the function.
Constraint: ${\mathbf{x}}>0.0$.
2:     iaIntegerInput
3:     jaIntegerInput
On entry: the numerator $i$ and denominator $j$, respectively, of the order $\alpha =i/j$ of the first member in the required sequence of function values. Only the following combinations of pairs of values of $i$ and $j$ are allowed:
• $i=0$ and $j=1$ corresponds to $\alpha =0$;
• $i=1$ and $j=2$ corresponds to $\alpha =\frac{1}{2}$;
• $i=1$ and $j=3$ corresponds to $\alpha =\frac{1}{3}$;
• $i=1$ and $j=4$ corresponds to $\alpha =\frac{1}{4}$;
• $i=2$ and $j=3$ corresponds to $\alpha =\frac{2}{3}$;
• $i=3$ and $j=4$ corresponds to $\alpha =\frac{3}{4}$.
Constraint: ia and ja must constitute a valid pair $\left({\mathbf{ia}},{\mathbf{ja}}\right)=\left(0,1\right)$, $\left(1,2\right)$, $\left(1,3\right)$, $\left(1,4\right)$, $\left(2,3\right)$ or $\left(3,4\right)$.
4:     nlIntegerInput
On entry: the value of $N$. Note that the order of the last member in the required sequence of function values is given by $\alpha +N$.
Constraint: $0\le {\mathbf{nl}}\le 100$.
5:     b[${\mathbf{nl}}+1$]doubleOutput
On exit: with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=\mathrm{NE_NOERROR}$ or ${\mathbf{fail}}\mathbf{.}\mathbf{code}={\mathbf{NW_SOME_PRECISION_LOSS}}$, the required sequence of function values: b$\left(n\right)$ contains ${K}_{\alpha +n}\left(x\right)$, for $n=0,1,\dots ,N$.
6:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_INT
On entry, ${\mathbf{nl}}=〈\mathit{\text{value}}〉$.
Constraint: $0\le {\mathbf{nl}}\le 100$.
NE_INT_2
On entry, ${\mathbf{ia}}=〈\mathit{\text{value}}〉$, ${\mathbf{ja}}=〈\mathit{\text{value}}〉$.
Constraint: ia and ja must constitute a valid pair (ia,ja).
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_OVERFLOW_LIKELY
The evaluation has been abandoned due to the likelihood of overflow.
NE_REAL
On entry, ${\mathbf{x}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{x}}>0.0$.
NE_TERMINATION_FAILURE
The evaluation has been abandoned due to failure to satisfy the termination condition.
NE_TOTAL_PRECISION_LOSS
The evaluation has been abandoned due to total loss of precision.
NW_SOME_PRECISION_LOSS
The evaluation has been completed but some precision has been lost.

## 7  Accuracy

All constants in the underlying function 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 the underlying function, 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}x\right|\right)$ represents the number of digits lost due to the argument reduction. Thus the larger the value of $x$, the less the precision in the result.

None.

## 9  Example

The example program evaluates ${e}^{x}{K}_{0}\left(x\right),{e}^{x}{K}_{1}\left(x\right),{e}^{x}{K}_{2}\left(x\right)$ and ${e}^{x}{K}_{3}\left(x\right)$ at $x=0.5$, and prints the results.

### 9.1  Program Text

Program Text (s18ehce.c)

### 9.2  Program Data

Program Data (s18ehce.d)

### 9.3  Program Results

Program Results (s18ehce.r)