Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_specfun_1f1_real (s22ba)

## Purpose

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

## Syntax

[m, ifail] = s22ba(a, b, x)
[m, ifail] = nag_specfun_1f1_real(a, b, x)

## Description

nag_specfun_1f1_real (s22ba) returns a value for the confluent hypergeometric function 1F1 (a ; b ; x) ${}_{1}F_{1}\left(a;b;x\right)$ with real parameters a$a$, b$b$ and x$x$. This function is unbounded or not uniquely defined for b$b$ equal to zero or a negative integer.
The associated function nag_specfun_1f1_real_scaled (s22bb) performs the same operations, but returns M$M$ in the scaled form M = mf × 2ms$M={m}_{f}×{2}^{{m}_{s}}$ to allow calculations to be performed when M$M$ is not representable as a single working precision number. It also accepts the parameters a$a$ and b$b$ as summations of an integer and a decimal fraction, giving higher accuracy when a$a$ or b$b$ are close to an integer. In such cases, nag_specfun_1f1_real_scaled (s22bb) should be used when high accuracy is required.
The confluent hypergeometric function is defined by the confluent series
 ∞ 1F1(a ; b ; x) = M(a,b,x) = ∑ ( (a)s xs )/( (b)s s! ) = 1 + (a)/b x + ( a(a + 1) )/( b(b + 1) 2! )x2 + ⋯ s = 0
$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 (a)s = 1 (a) (a + 1) (a + 2) (a + s1) ${\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$a$. M(a,b,x) $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 . $x d2M dx2 + (b-x) dM dx - a M = 0 .$ (1)
Given the parameters (a,b,x) $\left(a,b,x\right)$, this function determines a set of safe parameters {(αi,βi,ζi)i2} $\left\{\left({\alpha }_{i},{\beta }_{i},{\zeta }_{i}\right)\mid i\le 2\right\}$ and selects an appropriate algorithm to accurately evaluate the functions Mi (αi,βi,ζi) ${M}_{i}\left({\alpha }_{i},{\beta }_{i},{\zeta }_{i}\right)$. The result is then used to construct the solution to the original problem M(a,b,x) $M\left(a,b,x\right)$ using, where necessary, recurrence relations and/or continuation.
Additionally, an artificial bound, arbnd$\mathit{arbnd}$ is placed on the magnitudes of a$a$, b$b$ and x$x$ to minimize the occurrence of overflow in internal calculations. arbnd = 0.0001 × Imax $\mathit{arbnd}=0.0001×{I}_{\mathrm{max}}$, where Imax = x02bb${I}_{\mathrm{max}}=\mathbf{x02bb}$. It should, however, not be assumed that this function will produce an accurate result for all values of a$a$, b$b$ and x$x$ satisfying this criterion.
Please consult the NIST Digital Library of Mathematical Functions or the companion (2010) for a detailed discussion of the confluent hypergeoemtric function including special cases, transformations, relations and asymptotic approximations.

## 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

## Parameters

### Compulsory Input Parameters

1:     a – double scalar
The parameter a$a$ of the function.
Constraint: |a|arbnd$|{\mathbf{a}}|\le \mathit{arbnd}$.
2:     b – double scalar
The parameter b$b$ of the function.
Constraint: |b|arbnd$|{\mathbf{b}}|\le \mathit{arbnd}$.
3:     x – double scalar
The argument x$x$ of the function.
Constraint: |x|arbnd$|{\mathbf{x}}|\le \mathit{arbnd}$.

None.

None.

### Output Parameters

1:     m – double scalar
The solution M(a,b,x)$M\left(a,b,x\right)$.
Note: if overflow occurs upon completion, as indicated by ${\mathbf{ifail}}={\mathbf{2}}$, |M(a,b,x)|$|M\left(a,b,x\right)|$ may be assumed to be too large to be representable. m will be returned as ± Rmax$±{R}_{\mathrm{max}}$, where Rmax${R}_{\mathrm{max}}$ is the largest representable real number (see nag_machine_real_largest (x02al)). The sign of m should match the sign of M(a,b,x)$M\left(a,b,x\right)$. If overflow occurs during a subcalculation, as indicated by ${\mathbf{ifail}}={\mathbf{5}}$, the sign may be incorrect, and the true value of M(a,b,x)$M\left(a,b,x\right)$ may or may not be greater than Rmax${R}_{\mathrm{max}}$. In either case it is advisable to subsequently use nag_specfun_1f1_real_scaled (s22bb).
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W ifail = 1${\mathbf{ifail}}=1$
Underflow occurred during the evaluation of M(a,b,x)$M\left(a,b,x\right)$.
The returned value may be inaccurate.
ifail = 2${\mathbf{ifail}}=2$
On completion, overflow occurred in the evaluation of M(a,b,x)$M\left(a,b,x\right)$.
ifail = 3${\mathbf{ifail}}=3$
All approximations have completed, and the final residual estimate indicates some precision may have been lost.
ifail = 4${\mathbf{ifail}}=4$
All approximations have completed, and the final residual estimate indicates no accuracy can be guaranteed.
ifail = 5${\mathbf{ifail}}=5$
Overflow occurred in a subcalculation of M(a,b,x)$M\left(a,b,x\right)$.
The answer may be completely incorrect.
ifail = 11${\mathbf{ifail}}=11$
Constraint: .
ifail = 31${\mathbf{ifail}}=31$
Constraint: .
ifail = 32${\mathbf{ifail}}=32$
On entry.
M(a,b,x)$M\left(a,b,x\right)$ is undefined when b$b$ is zero or a negative integer.
ifail = 51${\mathbf{ifail}}=51$
Constraint: .

## Accuracy

In general, if ${\mathbf{ifail}}={\mathbf{0}}$, the value of M$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 res$\mathit{res}$ is made internally using equation (1). If the magnitude of res$\mathit{res}$ is sufficiently large, a nonzero ifail will be returned. Specifically,
 ${\mathbf{ifail}}={\mathbf{0}}$ res ≤ 1000ε$\mathit{res}\le 1000\epsilon$ ${\mathbf{ifail}}={\mathbf{3}}$ 1000 ε < res ≤ 0.1$1000\epsilon <\mathit{res}\le 0.1$ ${\mathbf{ifail}}={\mathbf{4}}$ res > 0.1$\mathit{res}>0.1$
A further estimate of the residual can be constructed using equation (1), and the differential identity,
 ( d M(a,b,x) )/(dx) = a/b M (a + 1,b + 1,x) , ( d2 M(a,b,x) )/(dx2) = (a(a + 1))/(b(b + 1)) M (a + 2,b + 2,x) .
$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 (a + 1,b + 1,x) $M\left(a+1,b+1,x\right)$ and M (a + 2,b + 2,x) $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$a$ and b$b$. For example, if b = bi + br = 100 + 1.0e−6$b={b}_{i}+{b}_{r}=100+\text{1.0e−6}$, then on a machine with 16$16$ decimal digits of precision, the internal calculation of br${b}_{r}$ will only be accurate to 8$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 nag_specfun_1f1_real_scaled (s22bb), which requires you to supply the correct decimal fraction.

None.

## Example

```function nag_specfun_1f1_real_example
a = 13.6;
b = 14.2;
x = [-2.5; -0.9; -0.25; -0.01; 0.1; 0.5; 0.75];

m     = zeros(numel(x), 1);
ifail = zeros(numel(x), 1, 'int64');
for i = 1:numel(x)
[m(i), ifail(i)] = nag_specfun_1f1_real(a, b, x(i));
end
fprintf('\n       x       M(a,b,x)       ifail\n');
fprintf('%10.2f  %13.5e  %6d\n', vertcat(x', m', double(ifail')));
```
```

x       M(a,b,x)       ifail
-2.50    9.20723e-02       0
-0.90    4.22800e-01       0
-0.25    7.87137e-01       0
-0.01    9.90468e-01       0
0.10    1.10053e+00       0
0.50    1.61478e+00       0
0.75    2.05246e+00       0

```
```function s22ba_example
a = 13.6;
b = 14.2;
x = [-2.5; -0.9; -0.25; -0.01; 0.1; 0.5; 0.75];

m     = zeros(numel(x), 1);
ifail = zeros(numel(x), 1, 'int64');
for i = 1:numel(x)
[m(i), ifail(i)] = s22ba(a, b, x(i));
end
fprintf('\n       x       M(a,b,x)       ifail\n');
fprintf('%10.2f  %13.5e  %6d\n', vertcat(x', m', double(ifail')));
```
```

x       M(a,b,x)       ifail
-2.50    9.20723e-02       0
-0.90    4.22800e-01       0
-0.25    7.87137e-01       0
-0.01    9.90468e-01       0
0.10    1.10053e+00       0
0.50    1.61478e+00       0
0.75    2.05246e+00       0

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013