(转载)
#include<stdio.h>
int main()
{
long k; /* dummy summation variable */
long n; /* number of terms to sum */
double kd; /* double version of k */
double x; /* the variable */
double sum; /* used for computation summations */
double px, p1; /* psi(x) and psi(1) */
double dpx; /* value of the first accelerated series at x */
double dp2; /* value of the first accelerated series at 2 */
double ddpx; /* value of the second accelerates series at x */
long i; /* counter for elements of table */
p1 = 1.0;
dp2 = 0.25;
n = 5000;
/* loop for the 2001 table entries */
for (i=0; i<2001; i++ )
{
x = i * 0.001;
/* sum second accelerated series */
sum = 0.0;
for( k=1; k<n; k++ )
{
kd = k;
sum += 1.0/(kd*(kd+1)*(kd+2)*(kd+x));
}
ddpx = (2.0-x)*sum;
/* get the value of the first accelerated series */
dpx = (1.0-x)*(dp2+ddpx);
/* get value of original series */
px = p1+dpx;
printf("%5.3f %16.12f/n", x, px);
}
return 1;
}
=================================================
很遗憾,WA ,不过测试数据都对得上 , 不知道哪里出问题了