Sie sind auf Seite 1von 5

FLOWCHART:

START

INPUT TERM
F(x), xL, XU, ES

SET F(X)=0.
REPLACE XL TO
THE TERM F(X) TO
A
GET F(XL) AND XU
TO GET F(XU)

SOLVE FOR XM BY GETTING THE


AVERAGE OF XL AND XU AND REPACE
XM TO F(X) TO GET F(XM)

SOLVE FOR [F(XL)][F(XM)] AND CHECK


IF IT IS <, >, = TO 0

SOLVE FOR |EA|. CHECK IF |EA|<ES


C
YES
IS |EA|<ES? DISPLAY XL AND
C XU

NO

B STOP
YES
SET XL=XL, [F(XL)][F(XM)]<0?
A XU=XM

NO

YES
SET XL=XM,
A [F(XL)][F(XM)]>0?
XU=XU

NO

YES
B DISPLAY [F(XL)][F(XM)]=0?
XM
CODE:
function XM = bisection(F, XL, XU, ES)
disp('Bisection Method');
F = input('Enter a function [@(x) 3*x^4-5;]: ');
XL = input('Enter XL: ');
XU = input('Enter XU: ');
ES = input('Enter ES: ');

% Evaluate both ends of the interval


y1 = feval(F, XL);
y2 = feval(F, XU);
i = 0;

% Display error and finish if signs are not different


if y1 * y2 > 0
disp('Have not found a change in sign. Will not continue...');
XM = 'Error'
return
end

% Work with the limits modifying them until you find a function close
enough to zero.
disp('Iter XL XU XM');
while (abs(XU - XL) >= ES)
i = i + 1;
% Find a new value to be tested as a root
XM = (XU + XL)/2;
y3 = feval(F, XM);
if y3 == 0
fprintf('Root at x = %f \n\n', XM);
return
end
fprintf('%2i \t %f \t %f \t %f \n', i-1, XL, XU, XM);

% Update the limits


if y1 * y3 > 0
XL = XM;
y1 = y3;
else
XU = XM;
end
end

% Show the last approximation considering the tolerance


w = feval(F, XM);
fprintf('\n x = %f produces f(x) = %f \n %i iterations\n', XM, y3, i-
1);
fprintf(' Approximation with tolerance = %f \n', ES);
EXPLANATION:
BISECTION METHOD IS SOMEWHAT SIMILAR TO GAUSS SEIDEL METHOD
INTERMS OF PROCESS. BISECTION METHOD PROCESS ASSUME BASED ON THE UPPER
AND THE LOWER LIMIT AND NARROWING IT THE LIMIT DOWN TO THE POINT THAT THE
REQUIRED ANSWER GETS CLOSER TO THE LIMITS BASED ON THE GIVEN TOLERANCE.
De La Salle Lipa
College of Information Technology and Engineering
Electrical Engineering Department

Exercise 4 Laboratory
Bisection Method

Submitted to: Submitted by:


Engr. Davidson Dimaano Castro, Jess Israel
Centeno, Nathaniel
De Silva, Alfred

NumMeth
April 17, 2017

Das könnte Ihnen auch gefallen