• https://me.yahoo.com
COST (GBP)
0.84
0.00
0

# log Gamma simple

A Stirling series approximation of the gamma function.
Controller: CodeCogs

C++
Excel

## LogGamma Simple

 doublelogGamma_simple( double x )[inline]
Returns a simple approximation to the log-gamma functions. If your only interested in low levels of accuracy (10 significant figures), then this solution is evaluated quickly and is relatively stable.

This approximation is achieved using the Stirling series (in its normal form) that provides a solution, given by the simple analytic expression
$ln&space;\Gamma(z)&space;=&space;\frac{1}{2}&space;\ln(2&space;\pi)&space;+&space;(z&space;-&space;\frac{1}{2})&space;\ln&space;z&space;-&space;z&space;+&space;\frac{1}{12z}&space;-&space;\frac{1}{360&space;z^3}&space;+&space;\frac{1}{1260&space;z^5}&space;-&space;...$

### Example 1

#include <codecogs/maths/special/gamma/loggamma_simple.h>
#include <codecogs/maths/special/gamma/log_gamma_stirling.h>
#include <stdio.h>

int main()
{
for(double x=3; x<5; x+=0.3)
printf("\n x=%lf logGamma_simple=%lf  log_gamma_stirling=%lf",x,
Maths::Special::Gamma::logGamma_simple(x),
Maths::Special::Gamma::log_gamma_stirling(x));
return 0;
}
Output:
x=3.000000 logGamma_simple=0.693147  log_gamma_stirling=0.693147
x=3.300000 logGamma_simple=0.987099  log_gamma_stirling=0.987099
x=3.600000 logGamma_simple=1.312923  log_gamma_stirling=1.312923
x=3.900000 logGamma_simple=1.667580  log_gamma_stirling=1.667580
x=4.200000 logGamma_simple=2.048556  log_gamma_stirling=2.048556
x=4.500000 logGamma_simple=2.453737  log_gamma_stirling=2.453737
x=4.800000 logGamma_simple=2.881323  log_gamma_stirling=2.881323

### Parameters

 x argument

### Authors

Tony Ottosson and Pl Frenger
Documention by Will Bateman
##### Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.