-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFalse_Position.c
More file actions
28 lines (25 loc) · 762 Bytes
/
Copy pathFalse_Position.c
File metadata and controls
28 lines (25 loc) · 762 Bytes
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
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define EPS 10.0e-6
#define F(x) ((x)*(x)*(x) + 4*(x)*(x) -10)
int main(void){
int n = 100 ,i;
double a = 1.25 , b= 1.5 , c;
if(F(a)*F(b) >0) exit(0);
printf("--------------------------------------------------------------------------\n");
printf("iter a b c f(a) f(b) f(c)\n");
printf("--------------------------------------------------------------------------\n");
for(i=1; i<n ; i++){
c=((a*F(b)-b*F(a))/(F(b) - F(a)));
printf("%3d %10.6lf %10.6lf %10.6lf %10.6lf %10.6lf %10.6lf\n", i,a,b,c, F(a),F(b),F(c));
if(fabs(F(c)) < EPS){
printf("ROOT(FP) = %lf\n" , c);
exit(0);
}
if(F(a)*F(c) <0)
b =c;
else
a =c ;
}
}