public static double gamma ( double x ) { double tmp = ( x - 0.5 ) * log ( x + 4.5 ) - ( x + 4.5 ) ; double ser = 1.0 + 76.18009173 / ( x + 0 ) - 86.50532033 / ( x + 1 ) + 24.01409822 / ( x + 2 ) - 1.231739516 / ( x + 3 ) + 0.00120858003 / ( x + 4 ) - 0.00000536382 / ( x + 5 ) ; double gamma = exp ( tmp + log ( ser * sqrt ( 2 * PI ) ) ) ; return gamma ; }
The Gamma function .