FUNCTION
Gamma_Simple
A Sterling series approximation of the gamma function.
You're viewing an older version of this page (#114). View the current version.
Interface
#include <codecogs/maths/special/gamma/gamma_simple.h>
using namespace Maths::Special::Gamma;
Returns a simple approximation to the 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 of the gamma function is achieved using the exponential of the Stirling series,
(1)
where
(2)
Example 1
#include <codecogs/maths/special/gamma/gamma_simple.h>
#include <stdio.h>
int main()
{
for(double x=3; x<7; x+=0.4)
printf("\n x=%lf gamma_simple=%lf",x, Maths::Special::Gamma::gamma_simple(x));
return 0;
}Output:
x=3.000000 gamma_simple=2.000000
x=3.400000 gamma_simple=2.981206
x=3.800000 gamma_simple=4.694174
x=4.200000 gamma_simple=7.756690
x=4.600000 gamma_simple=13.381286
x=5.000000 gamma_simple=24.000000
x=5.400000 gamma_simple=44.598848
x=5.800000 gamma_simple=85.621738
x=6.200000 gamma_simple=169.406099
x=6.600000 gamma_simple=344.701924Parameters
x
argument
Interactive Calculator
x
Result
Computing…
Set a range above first to export a graph.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.