0% found this document useful (0 votes)
19 views

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

The document is a MATLAB program that uses the bisection method to find the roots of polynomial equations. The program takes in the coefficients of the polynomial, an upper and lower guess for the root, and a required accuracy. It then iteratively calculates the midpoint between the guesses, evaluates the polynomial there, and updates the upper or lower guess depending on the sign of the evaluation until the difference between the guesses is less than the required accuracy, at which point it outputs the root. It runs this process for 4 example polynomial equations provided by the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

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

The document is a MATLAB program that uses the bisection method to find the roots of polynomial equations. The program takes in the coefficients of the polynomial, an upper and lower guess for the root, and a required accuracy. It then iteratively calculates the midpoint between the guesses, evaluates the polynomial there, and updates the upper or lower guess depending on the sign of the evaluation until the difference between the guesses is less than the required accuracy, at which point it outputs the root. It runs this process for 4 example polynomial equations provided by the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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