PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_gamma_log_scaled_real (s14ah)
Purpose
nag_specfun_gamma_log_scaled_real (s14ah) returns the value of , the scaled logarithm of the gamma function , via the function name.
Syntax
Description
nag_specfun_gamma_log_scaled_real (s14ah) calculates an approximate value for
, where
. This is a variant of the
function (see also
nag_specfun_gamma_log_real (s14ab)), which avoids rounding problems for very large arguments by computing
with the Stirling approximation factored out.
For , ;
and for , , where is a suitable Remez approximation.
For , the value is undefined; nag_specfun_gamma_log_scaled_real (s14ah) returns zero and exits with .
References
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Parameters
Compulsory Input Parameters
- 1:
– double scalar
-
The argument of the function.
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
The result of the function.
- 2:
– 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:
-
-
On entry, . On soft failure, the function value returned is zero.
-
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
nag_specfun_gamma_log_scaled_real (s14ah) has been designed to produce full relative accuracy for all input arguments. Empirical results obtained by comparing with multiprecision software confirm this.
Further Comments
None.
Example
This example reads values of the argument from a file, evaluates the function at each value of and prints the results.
Open in the MATLAB editor:
s14ah_example
function s14ah_example
fprintf('s14ah example results\n\n');
x = [1, 1.25, 1.5, 1.75, 2, 5, 10, 20, 1000];
n = size(x,2);
result = x;
for j=1:n
[result(j), ifail] = s14ah(x(j));
end
disp(' x ln G(x)');
fprintf('%12.3e%12.3e\n',[x; result]);
s14ah example results
x ln G(x)
1.000e+00 1.000e+00
1.250e+00 1.096e+00
1.500e+00 1.176e+00
1.750e+00 1.246e+00
2.000e+00 1.307e+00
5.000e+00 1.740e+00
1.000e+01 2.079e+00
2.000e+01 2.421e+00
1.000e+03 4.373e+00
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015