%program To Find Roots of Equation Using Biasing Method %MIS:111805033

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

%program to find roots of equation using biasing method

%MIS:111805033
clear all;
clc;

f=input('enter coefficients of your equation in []:');

a=input('enter the upper guess:');


b=input('enter the lower guess:');
dis=linspace(a,b);

x=polyval(f,a);
y=polyval(f,b);
acc=input('enter requaired accuracy:');
c=(a+b)/2;
n=polyval(f,c);
if (x*y>0)
disp('wrong guess');
else
while(abs(n)>acc)
c=(a+b)/2;
n=polyval(f,c);
if (x*n<0)
b=c;
else if (y*n<0)
a=c;
end
end

end
disp('one of the root is')
disp(c)
plot(dis,polyval(f,dis))
hold on
plot(c,0,'k*')
xlabel('x');
ylabel('f(x)');
end

OUTPUT:

enter coefficients of your equation in []:[2 1 -20 12]

enter the upper guess0

enter the lower guess1

enter requaired accuracy0.001


one of the root is

0.6482

EQUATIOn 2:

enter coefficients of your equation in []:[1 1 -2 -4]

enter the upper guess:2

enter the lower guess:1

enter requaired accuracy:0.001

one of the root is

1.6589
EQUATION 3:

enter coefficients of your equation in []:[-10 -32 32 8 9]

enter the upper guess:1

enter the lower guess:2

enter requaired accuracy:0.001

one of the root is

1.0921
EQUATION 4:

enter coefficients of your equation in []:[3 -23 41 -18]

enter the upper guess:1

enter the lower guess:0

enter requaired accuracy:0.001

one of the root is

0.6666

You might also like