# NAG Library Function Document

## 1Purpose

nag_bessel_k_nu (s18efc) returns the value of the modified Bessel function ${K}_{\nu /4}\left(x\right)$ for real $x>0$.

## 2Specification

 #include #include
 double nag_bessel_k_nu (double x, Integer nu, NagError *fail)

## 3Description

nag_bessel_k_nu (s18efc) evaluates an approximation to the modified Bessel function of the second kind ${K}_{\nu /4}\left(x\right)$, where the order $\nu =-3,-2,-1,1,2$ or $3$ and $x$ is real and positive. For negative orders the formula
 $K - ν / 4 x = K ν/4 x$
is used.

## 4References

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

## 5Arguments

1:    $\mathbf{x}$doubleInput
On entry: the argument $x$ of the function.
Constraint: ${\mathbf{x}}>0.0$.
2:    $\mathbf{nu}$IntegerInput
On entry: the argument $\nu$ of the function.
Constraint: $1\le \mathrm{abs}\left({\mathbf{nu}}\right)\le 3$.
3:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_INT
On entry, ${\mathbf{nu}}=〈\mathit{\text{value}}〉$.
Constraint: $1\le \mathrm{abs}\left({\mathbf{nu}}\right)\le 3$.
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. The result is returned as zero.
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. The result is returned as zero.
NE_TOTAL_PRECISION_LOSS
The evaluation has been abandoned due to total loss of precision. The result is returned as zero.
NW_SOME_PRECISION_LOSS
The evaluation has been completed but some precision has been lost.

## 7Accuracy

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.

## 8Parallelism and Performance

nag_bessel_k_nu (s18efc) is not threaded in any implementation.

None.

## 10Example

The example program reads values of the arguments $x$ and $\nu$ from a file, evaluates the function and prints the results.

### 10.1Program Text

Program Text (s18efce.c)

### 10.2Program Data

Program Data (s18efce.d)

### 10.3Program Results

Program Results (s18efce.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017