Doxygen Source Code Documentation
cdf_48.c File Reference
#include "cdflib.h"Go to the source code of this file.
Defines | |
| #define | hln2pi 0.91893853320467274178e0 |
| #define | ncoef 10 |
Functions | |
| double | dstrem (double *z) |
Define Documentation
|
|
|
|
|
|
Function Documentation
|
|
Definition at line 2 of file cdf_48.c. References devlpl(), dlngam(), dstrem(), and ftnstop(). Referenced by dbetrm(), and dstrem().
00003 {
00004 /*
00005 **********************************************************************
00006 double dstrem(double *z)
00007 Double precision Sterling Remainder
00008 Function
00009 Returns Log(Gamma(Z)) - Sterling(Z) where Sterling(Z) is
00010 Sterling's Approximation to Log(Gamma(Z))
00011 Sterling(Z) = LOG( SQRT( 2*PI ) ) + ( Z-0.5 ) * LOG( Z ) - Z
00012 Arguments
00013 Z --> Value at which Sterling remainder calculated
00014 Must be positive.
00015 DOUBLE PRECISION Z
00016 Method
00017 If Z >= 6 uses 9 terms of series in Bernoulli numbers
00018 (Values calculated using Maple)
00019 Otherwise computes difference explicitly
00020 **********************************************************************
00021 */
00022 #define hln2pi 0.91893853320467274178e0
00023 #define ncoef 10
00024 static double coef[ncoef] = {
00025 0.0e0,0.0833333333333333333333333333333e0,
00026 -0.00277777777777777777777777777778e0,0.000793650793650793650793650793651e0,
00027 -0.000595238095238095238095238095238e0,
00028 0.000841750841750841750841750841751e0,-0.00191752691752691752691752691753e0,
00029 0.00641025641025641025641025641026e0,-0.0295506535947712418300653594771e0,
00030 0.179644372368830573164938490016e0
00031 };
00032 static int K1 = 10;
00033 static double dstrem,sterl,T2;
00034 /*
00035 ..
00036 .. Executable Statements ..
00037 */
00038 /*
00039 For information, here are the next 11 coefficients of the
00040 remainder term in Sterling's formula
00041 -1.39243221690590111642743221691
00042 13.4028640441683919944789510007
00043 -156.848284626002017306365132452
00044 2193.10333333333333333333333333
00045 -36108.7712537249893571732652192
00046 691472.268851313067108395250776
00047 -0.152382215394074161922833649589D8
00048 0.382900751391414141414141414141D9
00049 -0.108822660357843910890151491655D11
00050 0.347320283765002252252252252252D12
00051 -0.123696021422692744542517103493D14
00052 */
00053 if(*z <= 0.0e0) ftnstop("Zero or negative argument in DSTREM");
00054 if(!(*z > 6.0e0)) goto S10;
00055 T2 = 1.0e0/pow(*z,2.0);
00056 dstrem = devlpl(coef,&K1,&T2)**z;
00057 goto S20;
00058 S10:
00059 sterl = hln2pi+(*z-0.5e0)*log(*z)-*z;
00060 dstrem = dlngam(z)-sterl;
00061 S20:
00062 return dstrem;
00063 #undef hln2pi
00064 #undef ncoef
00065 } /* END */
|