nag_scaled_log_gamma (s14ahc) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_scaled_log_gamma (s14ahc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_scaled_log_gamma (s14ahc) returns the value of lnGx, the scaled logarithm of the gamma function Γx.

2  Specification

#include <nag.h>
#include <nags.h>
double  nag_scaled_log_gamma (double x, NagError *fail)

3  Description

nag_scaled_log_gamma (s14ahc) calculates an approximate value for lnGx, where Gx=Γx+1/xex. This is a variant of the lnΓx function (see also nag_log_gamma (s14abc)), which avoids rounding problems for very large arguments by computing lnΓx with the Stirling approximation factored out.
For 0<x<15, lnGx=lnΓx+1-xlnx+x;
and for 15x, lnGx=12 lnx+ln2π+1xR1/x2, where R is a suitable Remez approximation.
For x0.0, the value lnGx is undefined; nag_scaled_log_gamma (s14ahc) returns zero and exits with fail.code= NE_REAL_ARG_LE.

4  References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

5  Arguments

1:     x doubleInput
On entry: the argument x of the function.
Constraint: x>0.0.
2:     fail NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_REAL_ARG_LE
On entry, x=value.
Constraint: x>0.0.

7  Accuracy

nag_scaled_log_gamma (s14ahc) has been designed to produce full relative accuracy for all input arguments. Empirical results obtained by comparing with multiprecision software confirm this.

8  Parallelism and Performance

nag_scaled_log_gamma (s14ahc) is not threaded in any implementation.

9  Further Comments

None.

10  Example

This example reads values of the argument x from a file, evaluates the function at each value of x and prints the results.

10.1  Program Text

Program Text (s14ahce.c)

10.2  Program Data

Program Data (s14ahce.d)

10.3  Program Results

Program Results (s14ahce.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 1 2 3 4 5 6 7 8 lnG(x) x Example Program Returns the Value of lnG(x), the Scaled Logarithm of the Gamma Function Γ(x) gnuplot_plot_1

nag_scaled_log_gamma (s14ahc) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016