root / lab4 / MNUM / bis.c @ 14
History | View | Annotate | Download (376 Bytes)
1 |
#include <stdio.h> |
---|---|
2 |
#include <math.h> |
3 |
|
4 |
int main()
|
5 |
{ |
6 |
double x,x1,err,a,b;
|
7 |
scanf("%lf %lf %lf",&a,&b,&err);
|
8 |
|
9 |
x=(a+b)/2;
|
10 |
while(1) |
11 |
{ |
12 |
if(((2*pow(a,3)-2*pow(a,2)-1)*(2*pow(x,3)-2*pow(x,2)-1))<0) |
13 |
b=x; |
14 |
else
|
15 |
a=x; |
16 |
x1=x; |
17 |
x=(a+b)/2;
|
18 |
if(x-x1<err && x-x1>-err)
|
19 |
break;
|
20 |
|
21 |
} |
22 |
printf("%lf",x);
|
23 |
|
24 |
} |