//////////////////////////////////////////////////////////////////////////////// // File: testlngamma.c // // // // Test the functions Ln_Gamma_Function() and xLn_Gamma_Function() in the file// // ln_gamma_function.c // // // // A table of log Gamma function can be found in "Handbook of Mathematical // // Functions with Formulas, Graphs, and Mathematical Tables" by Abramowitz // // and Stegun on page 274 Table 6.4 (note the table is the log Gamma Function,// // where the log is the common log i.e. log10). // //////////////////////////////////////////////////////////////////////////////// #include #include #include extern long double xGamma_Function(long double x); extern double Gamma_Function(double x); extern double Gamma_Function_Max_Arg( void ); extern double Ln_Gamma_Function(double x); extern long double xLn_Gamma_Function(long double x); int main() { double est; long double x,g; long double estL; long double onethird = 1.0L / 3.0L; long double half = 0.5L; long double twothirds = 2.0L / 3.0L; long double ln10 = logl(10.0); int i; printf("Program: testlngamma.c\n\n"); printf("See Abramowitz and Stegan - Handbook of Mathematical Functions with Formulas,\n Graphs, and Mathematical Tables\n Page 274 Table 6.4\n\n"); printf("Table of Log10(Gamma(x)) (double)\n\n"); printf(" x Log10(Gamma(x)) Log10(Gamma(x+1/3)) Log10(Gamma(x+1/2)) Log10(Gamma(x+2/3)\n"); for (i = 1; i <= 101; i++) { x = (long double) i; printf("%4i",i); est = Ln_Gamma_Function((double) x) / ln10; printf("%+14.8f",est); est = Ln_Gamma_Function((double) (x + onethird)) / ln10; printf("%+17.8f",est); est = Ln_Gamma_Function((double) (x + half)) / ln10; printf("%+20.8f",est); est = Ln_Gamma_Function((double) (x + twothirds)) / ln10; printf("%+20.8f\n",est); } printf("\n\n"); printf("Table of Log10(Gamma(x)) (long double)\n\n"); printf(" x Log10(Gamma(x)) Log10(Gamma(x+1/3)) Log10(Gamma(x+1/2)) Log10(Gamma(x+2/3)\n"); for (i = 1; i <= 101; i++) { x = (long double) i; printf("%4i",i); estL = xLn_Gamma_Function(x) / ln10; printf("%+14.8Lf",estL); estL = xLn_Gamma_Function(x + onethird) / ln10; printf("%+17.8Lf",estL); estL = xLn_Gamma_Function(x + half) / ln10; printf("%+20.8Lf",estL); estL = xLn_Gamma_Function(x + twothirds) / ln10; printf("%+20.8Lf\n",estL); } printf("\n\n"); }