Gamma function: Difference between revisions
Content deleted Content added
m →{{header|J}}: fix links and tags |
→{{header|C}}: -improve spouge implementation , double # of terms calcd |
||
Line 352:
}
#define A 12
{
static double c_space[A];
▲double sp_gamma(double x, double **fm)
▲ const int a = 6;
static double *c = NULL;
int k;
double
if ( c == NULL ) {
double k1_factrl = 1.0; /* (k - 1)!*(-1)^k with 0!==1*/
c[0] = sqrt(2.0*M_PI);
for(k=1; k < a; k++) {
c[k] = exp(
k1_factrl *= -k;
}
}
for(k=1; k < a; k++) {
}
return
}
int main()
{
double x
printf("%15s%15s%15s\n", "Stirling", "Spouge", "GSL");
for(x=1.0; x <= 10.0; x+=1.0) {
printf("%15.8lf%15.8lf%15.8lf\n", st_gamma(x/3.0), sp_gamma(x/3.0
gsl_sf_gamma(x/3.0));
}
return 0;
}</lang>
Line 400 ⟶ 394:
<pre> Stirling Spouge GSL
2.15697602 2.
1.20285073 1.
0.92213701
0.83974270 0.
0.85919025 0.
0.95950218
1.14910642 1.
1.45849038 1.
1.94540320
2.70976382 2.
=={{header|Fortran}}==
|