PROGRAM REGULA;
uses crt;
VAR
FA,FB,c,a,b,d,FC : REAL;
M_KIRI,M_KANAN : INTEGER;
PROCEDURE REGULA_FALSI (a,b : REAL);
CONST
EPS1 = 0.00001;
EPS2 = 0.000001;
VAR
FA,FB,c,d,FC : REAL;
M_KIRI,M_KANAN : INTEGER;
BEGIN
M_KIRI := 1;
M_KANAN:= 1;
REPEAT
FA := (a*a*a)+(2*(a*a))+10*a-20;
FB := (b*b*b)+(2*(b*b))+10*b-20;
c := a-(FA*(b-a)/(FB-FA));
FC := (c*c*c)+(2*(c*c))+10*c-20;
IF abs (FC) < EPS2 THEN
BEGIN
a:= c;
b:= c;
END
ELSE
IF ( FA*FC < 0 ) THEN
BEGIN
b := c;
FB := FC;
M_KIRI := M_KIRI + 1;
M_KANAN := 0;
IF (M_KIRI >= 1) THEN
FA := FA/2;
END
ELSE
BEGIN
a := c;
FA := FC;
M_KANAN := M_KANAN + 1;
M_KIRI := 0;
IF (M_KANAN >= 1) THEN
FB := FB/2;
END;
UNTIL ((abs(a-b) < EPS1 ) OR (abs(FC) < EPS2 ));
WRITELN ('hampiran akarnya :' , c : 10 :10 );
END;
begin clrscr;
a:= 1;
b:= 1.5;
REGULA_FALSI(a,b);
readln;
end.
Kamis, 11 Oktober 2012
PROGRAM REGULA false
17.01
Guardian
No comments
0 komentar:
Posting Komentar