PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_2f1_real_scaled (s22bf)
Purpose
nag_specfun_2f1_real_scaled (s22bf) returns a value for the Gauss hypergeometric function for real parameters and , and real argument . The result is returned in the scaled form .
Syntax
Description
nag_specfun_2f1_real_scaled (s22bf) returns a value for the Gauss hypergeometric function for real parameters , and , and for real argument .
The Gauss hypergeometric function is a solution to the hypergeometric differential equation,
For
, it may be defined by the Gauss series,
where
is the rising factorial of
.
is undefined for
or
a negative integer.
For , the series is absolutely convergent and is finite.
For
, linear transformations of the form,
exist, where
,
.
and
are real valued functions of the parameters and argument, typically involving products of gamma functions. When these are degenerate, finite limiting cases exist. Hence for
,
is defined by analytic continuation, and for
,
is real and finite.
For
, the following apply:
- If , , and hence is finite. Solutions also exist for the degenerate cases where or are negative integers or zero.
- If , is infinite, and the sign of is determinable as approaches from below.
In the complex plane, the principal branch of is taken along the real axis from increasing. is multivalued along this branch, and for real parameters and is typically not real valued. As such, this function will not compute a solution when .
The solution strategy used by this function is primarily dependent upon the value of the argument . Once trivial cases and the case are eliminated, this proceeds as follows.
For
, sets of safe parameters
are determined, such that the values of
required for an appropriate transformation of the type
(3) may be calculated either directly or using recurrence relations from the solutions of
. If
is positive, then only transformations with
will be used, implying only
will be required, with the transformed argument
. If
is negative, in some cases a transformation with
will be used, with the argument
. The function then cycles through these sets until acceptable solutions are generated. If no computation produces an accurate answer, the least inaccurate answer is selected to complete the computation. See
Accuracy.
For , an identical approach is first used with the argument . Should this fail, a linear transformation resulting in both transformed arguments satisfying is employed, and the above strategy for is utilized on both components. Further transformations in these sub-computations are however limited to single terms with no argument transformation.
For , a linear transformation mapping the argument to the interval is first employed. The strategy for is then used on each component, including possible further two term transforms. To avoid some degenerate cases, a transform mapping the argument to may also be used.
For improved precision in the final result, this function accepts and split into an integral and a decimal fractional component. Specifically, , where and is integral. The other parameters and are similarly deconstructed.
In addition to the above restrictions on
and
, an artificial bound,
arbnd, is placed on the magnitudes of
and
to minimize the occurrence of overflow in internal calculations, particularly those involving real to integer conversions.
, where
is the largest machine integer (see
nag_machine_integer_max (x02bb)). It should however not be assumed that this function will produce accurate answers for all values of
and
satisfying this criterion.
This function also tests for non-finite values of the parameters and argument on entry, and assigns non-finite values upon completion if appropriate. See
Further CommentsPlease consult the
NIST Digital Library of Mathematical Functions or the companion
(2010) for a detailed discussion of the Gauss 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:
– double scalar
-
, the nearest integer to , satisfying .
- 2:
– double scalar
-
, the signed decimal remainder satisfying and .
Constraint:
.
- 3:
– double scalar
-
, the nearest integer to , satisfying .
- 4:
– double scalar
-
, the signed decimal remainder satisfying and .
Constraint:
.
- 5:
– double scalar
-
, the nearest integer to , satisfying .
Constraints:
- ;
- ;
- if , .
- 6:
– double scalar
-
, the signed decimal remainder satisfying and .
Constraint:
.
- 7:
– double scalar
-
The argument .
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
-
, the scaled real component of the solution satisfying
, i.e.,
. See
Further Comments for the behaviour of
when a finite or non-finite answer is returned.
- 2:
– int64int32nag_int scalar
-
, the scaling power of two, satisfying
, i.e.,
. See
Further Comments for the behaviour of
when a non-finite answer is returned.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Underflow occurred during the evaluation of . The returned value may be inaccurate.
-
-
All approximations have completed, and the final residual estimate indicates some precision may have been lost.
-
-
All approximations have completed, and the final residual estimate indicates no accuracy can be guaranteed.
-
-
On entry, , , .
is infinite in the case .
-
-
On completion, overflow occurred in the evaluation of .
-
-
Overflow occurred in a subcalculation of . The answer may be completely incorrect.
-
-
An internal calculation has resulted in an undefined result.
-
-
On entry,
ani does not satisfy
.
-
-
Constraint: .
-
-
On entry,
adr does not satisfy
.
-
-
On entry,
bni does not satisfy
.
-
-
Constraint: .
-
-
On entry,
bdr does not satisfy
.
-
-
On entry,
cni does not satisfy
.
-
-
is undefined when is zero or a negative integer.
-
-
Constraint: .
-
-
On entry,
cdr does not satisfy
.
-
-
On entry,
x does not satisfy
.
-
-
is not real valued when .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
In general, if
, the value of
may be assumed accurate, with the possible loss of one or two decimal places. Assuming the result does not overflow, an error estimate
is made internally using equation
(1). If the magnitude of this residual
is sufficiently large, a
nonzero
ifail
will be returned. Specifically,
or |
|
|
|
|
|
where
is the
machine precision as returned by
nag_machine_precision (x02aj). Note that underflow may also have occurred if
or
.
A further estimate of the residual can be constructed using equation
(1), and the differential identity,
This estimate is however dependent upon the error involved in approximating and .
Further Comments
nag_specfun_2f1_real_scaled (s22bf) returns non-finite values when appropriate.
Should a non-finite value be returned, this will be indicated in the value of
ifail, as detailed in the following cases.
If
or
,
or
, a finite value will have been returned with approximate accuracy as detailed in
Accuracy.
The values of and are implementation dependent. In most cases, if , and will be returned, and if is finite, the fractional component will be bound by , with chosen accordingly.
The values returned in
frf (
) and
scf (
) may be used to explicitly evaluate
, and may also be used to evaluate products and ratios of multiple values of
as follows,
If
then
is infinite. A signed infinity will have been returned for
frf, and
. The sign of
frf should be correct when taking the limit as
approaches
from below.
If
then upon completion,
, where
is given by
nag_machine_integer_max (x02bb), and hence is too large to be representable even in the scaled form. The scaled real component returned in
frf may still be correct, whilst
will have been returned.
If then overflow occurred during a subcalculation of . The same result as for will have been returned, however there is no guarantee that this is representative of either the magnitude of the scaling power , or the scaled component of .
For all other error exits,
will be returned and
frf will be returned as a signalling NaN.
If an internal computation produced an undefined result. This may occur when two terms overflow with opposite signs, and the result is dependent upon their summation for example.
If
then
is too close to a negative integer or zero on entry, and
is undefined. Note, this will also be the case when
is a negative integer, and a (possibly trivial) linear transformation of the form
(3) would result in either:
(i) |
all not being negative integers, |
(ii) |
for any which remain as negative integers, one of the corresponding parameters or is a negative integer of magnitude less than . |
In the first case, the transformation coefficients
are typically either infinite or undefined, preventing a solution being constructed. In the second case, the series
(2) will terminate before the degenerate term, resulting in a polynomial of fixed degree, and hence potentially a finite solution.
If , , or then no computation will have been performed due to the risk of integer overflow. The actual solution may however be finite.
indicates , and hence the requested solution is on the boundary of the principal branch of . Hence it is multivalued, typically with a non-zero imaginary component. It is however strictly finite.
Example
This example evaluates the Gauss hypergeometric function at two points in scaled form using nag_specfun_2f1_real_scaled (s22bf), and subsequently calculates their product and ratio implicitly.
Open in the MATLAB editor:
s22bf_example
function s22bf_example
fprintf('s22bf example results\n\n');
delta = 10^-4;
ani = -10; adr = delta;
bni = 2; bdr = -delta;
cni = -5; cdr = delta;
x = 0.45;
fprintf('%10s%10s%10s%10s%14s%7s%14s\n',...
'a','b','c','x','frf','scf','2F1(a,b;c;x)');
for j = 1:2
[frf(j), scf(j), ifail] = s22bf( ...
ani, adr, bni, bdr, cni, cdr, x);
scale = frf(j)*2^double(scf(j));
fprintf('%10.4f%10.4f%10.4f%10.4f%14.5e%7d%14.5e\n',...
ani+adr, bni+bdr, cni+cdr, x, frf(j), scf(j), scale);
adr = -adr;
bdr = -bdr;
cdr = -cdr;
end
frfp = prod(frf);
scfp = sum(scf);
scale = frfp*2^double(scfp);
fprintf('\n%-40s%14.5e%7d%14.5e\n','Solution Product', frfp, scfp, scale);
frfr = frf(1)/frf(2);
scfr = scf(1) - scf(2);
scale = frfr*(2^double(scfr));
fprintf('%-40s%14.5e%7d%14.5e\n','Solution Ratio', frfr, scfr, scale);
s22bf example results
a b c x frf scf 2F1(a,b;c;x)
-9.9999 1.9999 -4.9999 0.4500 -5.44477e-01 16 -3.56828e+04
-10.0001 2.0001 -5.0001 0.4500 5.44547e-01 16 3.56875e+04
Solution Product -2.96494e-01 32 -1.27343e+09
Solution Ratio -9.99871e-01 0 -9.99871e-01
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015