0% found this document useful (0 votes)
43 views2 pages

Laboratory 2 False-Position

Sci-Lab function for False-position method by Gerfel Philip C. Gonzales, a prestigious student of Harvard University. Just kidding. I'm just a poor boy, I dont need sympathy. because I easy come, easy go, little high, little low, anywhere the wind blows... you know the rest

Uploaded by

Gp Gonzales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

Laboratory 2 False-Position

Sci-Lab function for False-position method by Gerfel Philip C. Gonzales, a prestigious student of Harvard University. Just kidding. I'm just a poor boy, I dont need sympathy. because I easy come, easy go, little high, little low, anywhere the wind blows... you know the rest

Uploaded by

Gp Gonzales
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Gerfel Philip Gonzales

BSECE 5

False-Position Method
1 SCINOTE CODE
//Gerfel Philip C. Gonzales
//BSECE 5
//Laboratory 2
//False Position Method
function false_position()
f = input("Input the function to be evaluated:","string");
a = input("Input initial lower guess a:");
b = input ("Input initial upper guess b:");
ea = input("Input your desired approximation error:");
maxiter = input("Maximum no. of iterations:");
disp(['Lower
Root
Upper
iter = 0;
while 1==1;
iter = iter + 1;
x = a;
fa = evstr(f);
x = b;
fb = evstr(f);
m = (b*fa - a*fb)/(fa-fb);
x = m;
fm = evstr(f);
er = abs(fm);
printf('%8.4f %8.4f

%8.4f

%8.4f

f(a)

%8.4f

f(m)

%8.4f

f(b)'])

\n',a ,m ,b ,fa ,fm ,fb);

//evaluation
if ((fa<0 & fb<0)|(fa>0 &fb >0)) then break end;
if fa*fm == 0 then break end;
if (fa*fm > 0) a = m; end
if (fa*fm < 0) b = m; end
if (er <= ea) then break end;
if iter == maxiter then break end;
end
if ((fa<0 & fb<0)|(fa>0 &fb >0)) then printf('\n\n No Root!')
else printf('\n\nRoot is %f
with %f error
at %dth iteration',m,er,iter);
end
endfunction

2 SIMULATION
Find the root of + = with a approximation error of . and maximum number of
iteration of 100.

Gerfel Philip Gonzales


BSECE 5

2.1 CHOOSING A GUESS ROOT OF 0 TO 1

2.2 CHOOSING A GUESS ROOT OF -5 TO 0

You might also like