S Chapter Contents
S Chapter Introduction
NAG Library Manual

NAG Library Routine DocumentS22BBF

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

S22BBF returns a value for the confluent hypergeometric function ${}_{1}F_{1}\left(a;b;x\right)$ with real parameters $a$, $b$ and $x$ in the scaled form ${}_{1}F_{1}\left(a;b;x\right)={m}_{f}×{2}^{{m}_{s}}$. This function is sometimes also known as Kummer's function $M\left(a,b,x\right)$.

2  Specification

 SUBROUTINE S22BBF ( ANI, ADR, BNI, BDR, X, FRM, SCM, IFAIL)
 INTEGER SCM, IFAIL REAL (KIND=nag_wp) ANI, ADR, BNI, BDR, X, FRM

3  Description

S22BBF returns a value for the confluent hypergeometric function ${}_{1}F_{1}\left(a;b;x\right)$ with real parameters $a$, $b$ and $x$ in the scaled form ${}_{1}F_{1}\left(a;b;x\right)={m}_{f}×{2}^{{m}_{s}}$, where ${m}_{f}$ is the real scaled component and ${m}_{s}$ is the integer power of two scaling. This function is unbounded or not uniquely defined for $b$ equal to zero or a negative integer.
The confluent hypergeometric function is defined by the confluent series
 $F1 1 a;b;x = Ma,b,x = ∑ s=0 ∞ as xs bs s! = 1 + a b x + aa+1 bb+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 $\left(a,b,x\right)$, this routine determines a set of safe parameters $\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.
For improved precision in the final result, this routine accepts $a$ and $b$ split into an integral and a decimal fractional component. Specifically $a={a}_{i}+{a}_{r}$, where $\left|{a}_{r}\right|\le 0.5$ and ${a}_{i}=a-{a}_{r}$ is integral. $b$ is similarly deconstructed.
Additionally, an artificial bound, $\mathit{arbnd}$ is placed on the magnitudes of ${a}_{i}$, ${b}_{i}$ and $x$ to minimize the occurrence of overflow in internal calculations. $\mathit{arbnd}=0.0001×{I}_{\mathrm{max}}$, where ${I}_{\mathrm{max}}={\mathbf{X02BBF}}$. It should, however, not be assumed that this routine will produce an accurate result for all values of ${a}_{i}$, ${b}_{i}$ and $x$ satisfying this criterion.
Please consult the NIST Digital Library of Mathematical Functions or the companion (2010) for a detailed discussion of the confluent hypergeometric function including special cases, transformations, relations and asymptotic approximations.

4  References

NIST Handbook of Mathematical Functions (2010) (eds F W J Olver, D W Lozier, R F Boisvert, C W Clark) Cambridge University Press
Pearson J (2009) Computation of hypergeometric functions MSc Dissertation, Mathematical Institute, University of Oxford

5  Parameters

1:     ANI – REAL (KIND=nag_wp)Input
On entry: ${a}_{i}$, the nearest integer to $a$, satisfying ${a}_{i}=a-{a}_{r}$.
Constraints:
• ${\mathbf{ANI}}=⌊{\mathbf{ANI}}⌋$;
• $\left|{\mathbf{ANI}}\right|\le \mathit{arbnd}$.
On entry: ${a}_{r}$, the signed decimal remainder satisfying ${a}_{r}=a-{a}_{i}$ and $\left|{a}_{r}\right|\le 0.5$.
Constraint: $\left|{\mathbf{ADR}}\right|\le 0.5$.
Note: if $\left|{\mathbf{ADR}}\right|<100.0\epsilon$, ${a}_{r}=0.0$ will be used, where $\epsilon$ is the machine precision as returned by X02AJF.
3:     BNI – REAL (KIND=nag_wp)Input
On entry: ${b}_{i}$, the nearest integer to $b$, satisfying ${b}_{i}=b-{b}_{r}$.
Constraints:
• ${\mathbf{BNI}}=⌊{\mathbf{BNI}}⌋$;
• $\left|{\mathbf{BNI}}\right|\le \mathit{arbnd}$;
• if ${\mathbf{BDR}}=0.0$, ${\mathbf{BNI}}>0$.
4:     BDR – REAL (KIND=nag_wp)Input
On entry: ${b}_{r}$, the signed decimal remainder satisfying ${b}_{r}=b-{b}_{i}$ and $\left|{b}_{r}\right|\le 0.5$.
Constraint: $\left|{\mathbf{BDR}}\right|\le 0.5$.
Note: if $\left|{\mathbf{BDR}}-{\mathbf{ADR}}\right|<100.0\epsilon$, ${a}_{r}={b}_{r}$ will be used, where $\epsilon$ is the machine precision as returned by X02AJF.
5:     X – REAL (KIND=nag_wp)Input
On entry: the argument $x$ of the function.
Constraint: $\left|{\mathbf{X}}\right|\le \mathit{arbnd}$.
6:     FRM – REAL (KIND=nag_wp)Output
On exit: ${m}_{f}$, the scaled real component of the solution satisfying ${m}_{f}=M\left(a,b,x\right)×{2}^{-{m}_{s}}$.
Note: if overflow occurs upon completion, as indicated by ${\mathbf{IFAIL}}={\mathbf{2}}$, the value of ${m}_{f}$ returned may still be correct. If overflow occurs in a subcalculation, as indicated by ${\mathbf{IFAIL}}={\mathbf{5}}$, this should not be assumed.
7:     SCM – INTEGEROutput
On exit: ${m}_{s}$, the scaling power of two, satisfying ${m}_{s}={\mathrm{log}}_{2}\left(\frac{M\left(a,b,x\right)}{{m}_{f}}\right)$.
Note: if overflow occurs upon completion, as indicated by ${\mathbf{IFAIL}}={\mathbf{2}}$, then ${m}_{s}\ge {I}_{\mathrm{max}}$, where ${I}_{\mathrm{max}}$ is the largest representable integer (see X02BBF). If overflow occurs during a subcalculation, as indicated by ${\mathbf{IFAIL}}={\mathbf{5}}$, ${m}_{s}$ may or may not be greater than ${I}_{\mathrm{max}}$. In either case, ${\mathbf{SCM}}={\mathbf{X02BBF}}$ will have been returned.
8:     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$
Underflow occurred during the evaluation of $M\left(a,b,x\right)$.
The returned value may be inaccurate.
${\mathbf{IFAIL}}=2$
On completion, overflow occurred in the evaluation of $M\left(a,b,x\right)$.
${\mathbf{IFAIL}}=3$
All approximations have completed, and the final residual estimate indicates some precision may have been lost.
Relative residual $\text{}=⟨\mathit{\text{value}}⟩$.
${\mathbf{IFAIL}}=4$
All approximations have completed, and the final residual estimate indicates no accuracy can be guaranteed.
Relative residual $\text{}=⟨\mathit{\text{value}}⟩$.
${\mathbf{IFAIL}}=5$
Overflow occurred in a subcalculation of $M\left(a,b,x\right)$.
The answer may be completely incorrect.
${\mathbf{IFAIL}}=11$
On entry, ${\mathbf{ANI}}=⟨\mathit{\text{value}}⟩$.
Constraint: $\left|{\mathbf{ANI}}\right|\le \mathit{arbnd}=⟨\mathit{\text{value}}⟩$.
${\mathbf{IFAIL}}=13$
ANI is non-integral.
On entry, ${\mathbf{ANI}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ANI}}=⌊{\mathbf{ANI}}⌋$.
${\mathbf{IFAIL}}=21$
On entry, ${\mathbf{ADR}}=⟨\mathit{\text{value}}⟩$.
Constraint: $\left|{\mathbf{ADR}}\right|\le 0.5$.
${\mathbf{IFAIL}}=31$
On entry, ${\mathbf{BNI}}=⟨\mathit{\text{value}}⟩$.
Constraint: $\left|{\mathbf{BNI}}\right|\le \mathit{arbnd}=⟨\mathit{\text{value}}⟩$.
${\mathbf{IFAIL}}=32$
On entry, $b={\mathbf{BNI}}+{\mathbf{BDR}}=⟨\mathit{\text{value}}⟩$.
$M\left(a,b,x\right)$ is undefined when $b$ is zero or a negative integer.
${\mathbf{IFAIL}}=33$
BNI is non-integral.
On entry, ${\mathbf{BNI}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{BNI}}=⌊{\mathbf{BNI}}⌋$.
${\mathbf{IFAIL}}=41$
On entry, ${\mathbf{BDR}}=⟨\mathit{\text{value}}⟩$.
Constraint: $\left|{\mathbf{BDR}}\right|\le 0.5$.
${\mathbf{IFAIL}}=51$
On entry, ${\mathbf{X}}=⟨\mathit{\text{value}}⟩$.
Constraint: $\left|{\mathbf{X}}\right|\le \mathit{arbnd}=⟨\mathit{\text{value}}⟩$.

7  Accuracy

In general, if ${\mathbf{IFAIL}}={\mathbf{0}}$, 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 nonzero IFAIL will be returned. Specifically,
 ${\mathbf{IFAIL}}={\mathbf{0}}$ $\mathit{res}\le 1000\epsilon$ ${\mathbf{IFAIL}}={\mathbf{3}}$ $1000\epsilon <\mathit{res}\le 0.1$ ${\mathbf{IFAIL}}={\mathbf{4}}$ $\mathit{res}>0.1$
A further estimate of the residual can be constructed using equation (1), and the differential identity,
 $d Ma,b,x dx = ab M a+1,b+1,x , d2 Ma,b,x dx2 = aa+1 bb+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)$.

The values returned in FRM (${m}_{f}$) and SCM (${m}_{s}$) may be used to explicitly evaluate $M\left(a,b,x\right)$, and may also be used to evaluate products and ratios of multiple values of $M$ as follows,
 $Ma,b,x = mf × 2ms M a1,b1,x1 × M a2,b2,x2 = mf1 × mf2 × 2 ms1 + ms2 M a1,b1,x1 M a2,b2,x2 = mf1 mf2 × 2 ms1 - ms2 ln M a,b,x = lnmf + ms × ln2 .$

9  Example

This example evaluates the confluent hypergeometric function at two points in scaled form using S22BBF, and subsequently calculates their product and ratio without having to explicitly construct $M$.

9.1  Program Text

Program Text (s22bbfe.f90)

None.

9.3  Program Results

Program Results (s22bbfe.r)