Objective: Software Used: Computer Specifications:: To Understand Bi-Section Method. Matlab
Objective: Software Used: Computer Specifications:: To Understand Bi-Section Method. Matlab
COMPUTER SPECIFICATIONS:
FLOWCHART:
MATLAB
CODE:
close all
clear all
clc
f=@(x)(x^3-x-2);
while((f(xl)*f(xu))>0)
end
while(abs(xu-xl)>acc)
xm=(xl-xu)/2;
if(f(x)*f(xm)<0)
xu=xm;
else
xl=xm;
end
end
4. Examine the sign of f(c) and replace either (a, f(a)) or (b, f(b)) with (c, f(c)) so that
there is a zero crossing within the new interval.
Iteration an bn cn f(cn)
1 1 2 1.5 −0.125
COMPUTER SPECIFICATIONS:
PLOT OF ERROR FOR REGULA-FALSI METHOD:
FLOWCHART:
MATLAB CODE:
Clear all
close all
clc;
f=@(x) x^3-2*x-5;
a=2; b=3;
for i=1:10
x0=a; x1=b;
x2(i)=x0-(x1-x0)/(f(x1)-f(x0))*f(x0);
if f(x2(i))>0
b=x2(i);
else a=x2(i);
end
p=x2(i);
end
OUTPUT/ITERATIONS:
RESULT:
The fact that regula falsi always converges, and has versions that do well at avoiding
slowdowns, makes it a good choice when speed is needed. However, its rate of
convergence can drop below that of the bisection method.
COMPUTER SPECIFICATIONS:
FLOWCHART:
MATLAB CODE:
a=input('Enter the function in the form of variable x:','s');
f=inline(a)
dif=diff(sym(a));
d=inline(dif);
for i=1:100
x(i+1)=x(i)-((f(x(i))/d(x(i))));
err(i)=abs((x(i+1)-x(i))/x(i));
if err(i)<error
break
end
end
root=x(i)
Sample output: