|
@ -28,4 +28,19 @@ double exponential(double x){ |
|
|
|
|
|
|
|
|
double euler(){ |
|
|
double euler(){ |
|
|
return exponential(1); |
|
|
return exponential(1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
double pi(double eps){ |
|
|
|
|
|
double a = 1, b = 1/powerD(0.5, 2), t = 0.25, p = 1; |
|
|
|
|
|
double aNew, piold, pi = 1; |
|
|
|
|
|
do{ |
|
|
|
|
|
aNew = .5 * (a + b); |
|
|
|
|
|
b = powerD(0.5 , a * b); |
|
|
|
|
|
t -= p * (a - aNew) * (a - aNew); |
|
|
|
|
|
a = aNew; |
|
|
|
|
|
p *= 2; |
|
|
|
|
|
piold = pi; |
|
|
|
|
|
pi = (a + b) * (a + b) / (4 * t); |
|
|
|
|
|
} while (absD(pi - piold) > eps); |
|
|
|
|
|
return pi; |
|
|
} |
|
|
} |