# NAG CL Interfaces22bac (hyperg_​confl_​real)

Settings help

CL Name Style:

## 1Purpose

s22bac returns a value for the confluent hypergeometric function ${}_{1}F_{1}\left(a;b;x\right)$ with real parameters $a$ and $b$, and real argument $x$. This function is sometimes also known as Kummer's function $M\left(a,b,x\right)$.

## 2Specification

 #include
 void s22bac (double a, double b, double x, double *m, NagError *fail)
The function may be called by the names: s22bac, nag_specfun_hyperg_confl_real or nag_specfun_1f1_real.

## 3Description

s22bac returns a value for the confluent hypergeometric function ${}_{1}F_{1}\left(a;b;x\right)$ with real parameters $a$ and $b$, and real argument $x$. This function is unbounded or not uniquely defined for $b$ equal to zero or a negative integer.
The associated function s22bbc performs the same operations, but returns $M$ in the scaled form $M={m}_{f}×{2}^{{m}_{s}}$ to allow calculations to be performed when $M$ is not representable as a single working precision number. It also accepts the parameters $a$ and $b$ as summations of an integer and a decimal fraction, giving higher accuracy when $a$ or $b$ are close to an integer. In such cases, s22bbc should be used when high accuracy is required.
The confluent hypergeometric function is defined by the confluent series
 $F1 1 (a;b;x) = M(a,b,x) = ∑ s=0 ∞ (a)s xs (b)s s! = 1 + a b x + a(a+1) b(b+1) 2! x2 + ⋯$
where ${\left(a\right)}_{s}=1\left(a\right)\left(a+1\right)\left(a+2\right)\dots \left(a+s-1\right)$ is the rising factorial of $a$. $M\left(a,b,x\right)$ is a solution to the second order ODE (Kummer's Equation):
 $x d2M dx2 + (b-x) dM dx - a M = 0 .$ (1)
Given the parameters and argument $\left(a,b,x\right)$, this function determines a set of safe values $\left\{\left({\alpha }_{i},{\beta }_{i},{\zeta }_{i}\right)\mid i\le 2\right\}$ and selects an appropriate algorithm to accurately evaluate the functions ${M}_{i}\left({\alpha }_{i},{\beta }_{i},{\zeta }_{i}\right)$. The result is then used to construct the solution to the original problem $M\left(a,b,x\right)$ using, where necessary, recurrence relations and/or continuation.
Additionally, an artificial bound, $\mathit{arbnd}$ is placed on the magnitudes of $a$, $b$ and $x$ to minimize the occurrence of overflow in internal calculations. $\mathit{arbnd}=0.0001×{I}_{\mathrm{max}}$, where ${I}_{\mathrm{max}}={\mathbf{X02BBC}}$. It should, however, not be assumed that this function will produce an accurate result for all values of $a$, $b$ and $x$ satisfying this criterion.
Please consult the NIST Digital Library of Mathematical Functions for a detailed discussion of the confluent hypergeometric function including special cases, transformations, relations and asymptotic approximations.
NIST Digital Library of Mathematical Functions
Pearson J (2009) Computation of hypergeometric functions MSc Dissertation, Mathematical Institute, University of Oxford

## 5Arguments

1: $\mathbf{a}$double Input
On entry: the parameter $a$ of the function.
Constraint: $|{\mathbf{a}}|\le \mathit{arbnd}$.
2: $\mathbf{b}$double Input
On entry: the parameter $b$ of the function.
Constraint: $|{\mathbf{b}}|\le \mathit{arbnd}$.
3: $\mathbf{x}$double Input
On entry: the argument $x$ of the function.
Constraint: $|{\mathbf{x}}|\le \mathit{arbnd}$.
4: $\mathbf{m}$double * Output
On exit: the solution $M\left(a,b,x\right)$.
Note: if overflow occurs upon completion, as indicated by ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NW_OVERFLOW_WARN, $|M\left(a,b,x\right)|$ may be assumed to be too large to be representable. m will be returned as $±{R}_{\mathrm{max}}$, where ${R}_{\mathrm{max}}$ is the largest representable real number (see X02ALC). The sign of m should match the sign of $M\left(a,b,x\right)$. If overflow occurs during a subcalculation, as indicated by ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_OVERFLOW, the sign may be incorrect, and the true value of $M\left(a,b,x\right)$ may or may not be greater than ${R}_{\mathrm{max}}$. In either case it is advisable to subsequently use s22bbc.
5: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_OVERFLOW
Overflow occurred in a subcalculation of $M\left(a,b,x\right)$.
The answer may be completely incorrect.
NE_REAL
On entry, ${\mathbf{b}}=⟨\mathit{\text{value}}⟩$.
$M\left(a,b,x\right)$ is undefined when $b$ is zero or a negative integer.
NE_REAL_RANGE_CONS
On entry, ${\mathbf{a}}=⟨\mathit{\text{value}}⟩$.
Constraint: $|{\mathbf{a}}|\le \mathit{arbnd}=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{b}}=⟨\mathit{\text{value}}⟩$.
Constraint: $|{\mathbf{b}}|\le \mathit{arbnd}=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{x}}=⟨\mathit{\text{value}}⟩$.
Constraint: $|{\mathbf{x}}|\le \mathit{arbnd}=⟨\mathit{\text{value}}⟩$.
NE_TOTAL_PRECISION_LOSS
All approximations have completed, and the final residual estimate indicates no accuracy can be guaranteed.
Relative residual $\text{}=⟨\mathit{\text{value}}⟩$.
NW_OVERFLOW_WARN
On completion, overflow occurred in the evaluation of $M\left(a,b,x\right)$.
NW_SOME_PRECISION_LOSS
All approximations have completed, and the final residual estimate indicates some precision may have been lost.
Relative residual $\text{}=⟨\mathit{\text{value}}⟩$.
NW_UNDERFLOW_WARN
Underflow occurred during the evaluation of $M\left(a,b,x\right)$.
The returned value may be inaccurate.

## 7Accuracy

In general, if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, the value of $M$ may be assumed accurate, with the possible loss of one or two decimal places. Assuming the result does not under or overflow, an error estimate $\mathit{res}$ is made internally using equation (1). If the magnitude of $\mathit{res}$ is sufficiently large, a different fail.code will be returned. Specifically,
 ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR $\mathit{res}\le 1000\epsilon$ ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NW_SOME_PRECISION_LOSS $1000\epsilon <\mathit{res}\le 0.1$ ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_TOTAL_PRECISION_LOSS $\mathit{res}>0.1$
where $\epsilon$ is the machine precision as returned by X02AJC.
A further estimate of the residual can be constructed using equation (1), and the differential identity,
 $d M(a,b,x) dx = ab M (a+1,b+1,x) , d2 M(a,b,x) dx2 = a(a+1) b(b+1) M (a+2,b+2,x) .$
This estimate is however, dependent upon the error involved in approximating $M\left(a+1,b+1,x\right)$ and $M\left(a+2,b+2,x\right)$.
Furthermore, the accuracy of the solution, and the error estimate, can be dependent upon the accuracy of the decimal fraction of the input parameters $a$ and $b$. For example, if $b={b}_{i}+{b}_{r}=100+\text{1.0e−6}$, then on a machine with $16$ decimal digits of precision, the internal calculation of ${b}_{r}$ will only be accurate to $8$ decimal places. This can subsequently pollute the final solution by several decimal places without affecting the residual estimate as greatly. Should you require higher accuracy in such regions, then you should use s22bbc, which requires you to supply the correct decimal fraction.

## 8Parallelism and Performance

s22bac is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
s22bac makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10Example

This example prints the results returned by s22bac called using parameters $a=13.6$ and $b=14.2$ with $11$ differing values of argument $x$.

### 10.1Program Text

Program Text (s22bace.c)

None.

### 10.3Program Results

Program Results (s22bace.r)