llllol

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
typedef double T;
T f( T x )
{
return 1/(x*x);
}
T F( T x )
{
return -1/x;
}
T Integral0( T left, T right, long N, T (*pf)(T) )
{
T S = 0.0;
T x, dx;
dx = (right - left) / N;
for ( x = left; x <= right; x += dx ) {
S += dx * ( pf( x ) + pf( x+dx ) ) / 2.0;
}
return S;
}
int main()
{
T L = 0.000001;
T R = 1000;
T F0 = F(R)-F(L);
long n;
for ( n=10000; n<100000000; n*=1.2 ) {
printf( "%ld %g\n",n, (Integral0(L,R,n,f)-F0)/F0);
}
return 0;
}