nag_scaled_log_gamma (s14ahc) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG C 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:     xdoubleInput
On entry: the argument x of the function.
Constraint: x>0.0.
2:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

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.
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  Further Comments


9  Example

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

9.1  Program Text

Program Text (s14ahce.c)

9.2  Program Data

Program Data (s14ahce.d)

9.3  Program Results

Program Results (s14ahce.r)

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

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