hide long namesshow long names
hide short namesshow short names
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_scaled (s22bb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_specfun_1f1_real_scaled (s22bb) returns a value for the confluent hypergeometric function F 1 1 a;b;x , with real parameters a and b and real argument x. The solution is returned in the scaled form F 1 1 a;b;x = mf × 2ms . This function is sometimes also known as Kummer's function Ma,b,x.

Syntax

[frm, scm, ifail] = s22bb(ani, adr, bni, bdr, x)
[frm, scm, ifail] = nag_specfun_1f1_real_scaled(ani, adr, bni, bdr, x)

Description

nag_specfun_1f1_real_scaled (s22bb) returns a value for the confluent hypergeometric function F1 1 a;b;x , with real parameters a and b and real argument x, in the scaled form F1 1 a;b;x = mf × 2 ms , where mf is the real scaled component and ms 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 as = 1 a a+1 a+2 a+s-1  is the rising factorial of a . Ma,b,x  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 a,b,x , this function determines a set of safe values αi,βi,ζi i2  and selects an appropriate algorithm to accurately evaluate the functions Mi αi,βi,ζi . The result is then used to construct the solution to the original problem Ma,b,x  using, where necessary, recurrence relations and/or continuation.
For improved precision in the final result, this function accepts a and b split into an integral and a decimal fractional component. Specifically a=ai+ar, where ar0.5 and ai=a-ar is integral. b is similarly deconstructed.
Additionally, an artificial bound, arbnd is placed on the magnitudes of ai, bi and x to minimize the occurrence of overflow in internal calculations. arbnd = 0.0001 × Imax , where Imax=x02bb. It should, however, not be assumed that this function will produce an accurate result for all values of ai, bi 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.

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:     ani – double scalar
ai, the nearest integer to a, satisfying ai = a-ar.
Constraints:
  • ani=ani;
  • aniarbnd.
2:     adr – double scalar
ar, the signed decimal remainder satisfying ar = a-ai  and ar 0.5.
Constraint: adr0.5.
Note: if adr<100.0ε, ar=0.0 will be used, where ε is the machine precision as returned by nag_machine_precision (x02aj).
3:     bni – double scalar
bi, the nearest integer to b, satisfying bi=b-br.
Constraints:
  • bni=bni;
  • bniarbnd;
  • if bdr=0.0, bni>0.
4:     bdr – double scalar
br, the signed decimal remainder satisfying br = b-bi and br 0.5.
Constraint: bdr0.5.
Note: if bdr-adr<100.0ε, ar=br will be used, where ε is the machine precision as returned by nag_machine_precision (x02aj).
5:     x – double scalar
The argument x of the function.
Constraint: xarbnd.

Optional Input Parameters

None.

Output Parameters

1:     frm – double scalar
mf, the scaled real component of the solution satisfying mf=Ma,b,x×2-ms.
Note: if overflow occurs upon completion, as indicated by ifail=2, the value of mf returned may still be correct. If overflow occurs in a subcalculation, as indicated by ifail=5, this should not be assumed.
2:     scm int64int32nag_int scalar
ms, the scaling power of two, satisfying ms= log2 Ma,b,x mf .
Note: if overflow occurs upon completion, as indicated by ifail=2, then msImax, where Imax is the largest representable integer (see nag_machine_integer_max (x02bb)). If overflow occurs during a subcalculation, as indicated by ifail=5, ms may or may not be greater than Imax. In either case, scm=x02bb will have been returned.
3:     ifail int64int32nag_int scalar
ifail=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
Underflow occurred during the evaluation of Ma,b,x.
The returned value may be inaccurate.
W  ifail=2
On completion, overflow occurred in the evaluation of Ma,b,x.
W  ifail=3
All approximations have completed, and the final residual estimate indicates some precision may have been lost.
   ifail=4
All approximations have completed, and the final residual estimate indicates no accuracy can be guaranteed.
   ifail=5
Overflow occurred in a subcalculation of Ma,b,x.
The answer may be completely incorrect.
   ifail=11
Constraint: aniarbnd=_.
   ifail=13
Constraint: ani=ani.
   ifail=21
Constraint: adr0.5.
   ifail=31
Constraint: bniarbnd=_.
   ifail=32
On entryb=bni+bdr=_.
Ma,b,x is undefined when b is zero or a negative integer.
   ifail=33
Constraint: bni=bni.
   ifail=41
Constraint: bdr0.5.
   ifail=51
Constraint: xarbnd=_.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

In general, if ifail=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 res is made internally using equation (1). If the magnitude of res is sufficiently large a nonzero ifail will be returned. Specifically,
ifail=0 res1000ε
ifail=3 1000ε<res0.1
ifail=4 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 a+1,b+1,x  and M a+2,b+2,x .

Further Comments

The values of mf and ms are implementation dependent. In most cases, if F 1 1 a;b;x = 0 , m f = 0 and m s = 0 will be returned, and if F 1 1 a;b;x = 0  is finite, the fractional component will be bound by 0.5 m f < 1, with m s  chosen accordingly.
The values returned in frm (mf) and scm (ms) may be used to explicitly evaluate Ma,b,x, 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 .  

Example

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


fprintf('s22bb example results\n\n');

% n values of a and b
n     = 2;

% delta is perturbation on integer values for a and b
delta = 1e-4;
amod  = [-10    -10]; arem  = [ delta -delta];
bmod  = [ 30     30]; brem  = [-delta  delta];
x     = 25;

fprintf('        a         b         x         frm   scm    M(a,b,x)\n');
for j = 1:n
  [frmv(j), scmv(j), ifail] = s22bb( ...
                                     amod(j), arem(j), bmod(j), brem(j), x);
  a = amod(j) + arem(j);
  b = bmod(j) + brem(j);
  fprintf('%9.3f %9.3f %9.3f %11.3e %5d ', a, b, x, frmv(j), scmv(j));
  print_scale(frmv(j), scmv(j));
end

% Calculate the product M1*M2
frm = prod(frmv);
scm = sum(scmv);

fprintf('\nSolution product %24.3e %5d ', frm, scm);
print_scale(frm, scm);

% Calculate the ratio M1/M2
if frmv(2) ~= 0
  frm = frmv(1)/frmv(2);
  scm = scmv(1) - scmv(2);
  fprintf('\nSolution ratio   %24.3e %5d ', frm, scm);
  print_scale(frm, scm);
end



function print_scale(frm, scm)
  if scm < x02bl
    scale = frm*2^double(scm);
    fprintf('%11.3e\n', scale);
  else
    fprintf(' Not representable\n');
  end
s22bb example results

        a         b         x         frm   scm    M(a,b,x)
  -10.000    30.000    25.000  -7.733e-01   -15  -2.360e-05
  -10.000    30.000    25.000  -7.732e-01   -15  -2.360e-05

Solution product                5.979e-01   -30   5.568e-10

Solution ratio                  1.000e+00     0   1.000e+00

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–2015