Ini adalah salah satu metode Bisection and regulafalsi
dengan program Pascal yang bisa anda tiru untuk belajar .
LISTING PROGRAM
PROCEDURE RegulaFalsi(a,b,eps:Real; VAR xsol:Real);
{
Required condition: f(a)*f(b)<0 }
{
eps = accuracy of the root, e.g.: 0.000001 }
VAR
c,
fa, fb:Real;
BEGIN
REPEAT
fa:=f(a);
fb:=f(b);
c:=b
- (b-a)*fb/(fb-fa);
IF fa*f(c)<0 THEN b:=c
ELSE a:=c
UNTIL b-a<eps;
xsol:=c
END;
{Regula Falsi method - Pascal code}
PROCEDURE Bisection(a,b,eps:Real; VAR xsol:Real);
{
Required condition: f(a)*f(b)<0 }
{
eps = accuracy of the root, e.g.: 0.000001 }
VAR
c:Real;
BEGIN
REPEAT
c:=(a+b)/2;
IF f(a)*f(c)<0 THEN b:=c
ELSE a:=c
UNTIL b-a<eps;
xsol:=c
END;
{Bisection method - Pascal code}
Related Article:
0 komentar:
Posting Komentar