0% found this document useful (0 votes)
29 views6 pages

Experiment No. 1: Que 1. Find The Real Root of The Equation X - X - 2 0 Using Bisection Method. Programme

The document contains the code to find the real roots of various equations (x4-x2-2=0, x5-x2-8=0, log(x)-1=0, log(x)2-x=0, ex-8x=0, e2x-8x=0) using the bisection method. For each equation, the code provides the initialization of variables, iterative calculation using bisection method to find the root within a tolerance of 0.0001, and output of the solution after the iterations.

Uploaded by

Sahil Shaikh
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)
29 views6 pages

Experiment No. 1: Que 1. Find The Real Root of The Equation X - X - 2 0 Using Bisection Method. Programme

The document contains the code to find the real roots of various equations (x4-x2-2=0, x5-x2-8=0, log(x)-1=0, log(x)2-x=0, ex-8x=0, e2x-8x=0) using the bisection method. For each equation, the code provides the initialization of variables, iterative calculation using bisection method to find the root within a tolerance of 0.0001, and output of the solution after the iterations.

Uploaded by

Sahil Shaikh
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/ 6

EXPERIMENT No.

1
Que 1. Find the real root of the equation x4-x2-2=0 using bisection method.
Programme:-
clc
deff('y=f(x)','y=x^4-x^2-2');
a=0;
b=1;
d=0.0001;
c=0;
printf('succesive approximation\n\ta\t\tb\t\tm\t\tf(m)\n');
while abs(a-b)>d
m=(a+b)/2;
printf('\t%f\t%f\t%f\t%f\n',a,b,m,f(m)),
if f(m)*f(a)>0
a=m;
else
b=m;
end
c=c+1;
end
printf('the solution of equation after %i iteration is %0.3g',c,m);

Output :-
Que 2. Find the real root of the equation x 5-x2-8=0 using bisection method.
Programme:-
clc
deff('y=f(x)','y=x^5-x^2-8');
a=0;
b=1;
d=0.0001;
c=0;
printf('succesive approximation\n\ta\t\tb\t\tm\t\tf(m)\n');
while abs(a-b)>d
m=(a+b)/2;
printf('\t%f\t%f\t%f\t%f\n',a,b,m,f(m)),
if f(m)*f(a)>0
a=m;
else
b=m;
end
c=c+1;
end
printf('the solution of equation after %i iteration is %0.3g',c,m);

Output:-
EXPERIMENT No. 1
Que 1. Find the real root of the equation log(x)-1=0 using bisection method.
Programme:-
clc
deff('y=f(x)','y=log(x)-1');
a=0;
b=1;
d=0.0001;
c=0;
printf('succesive approximation\n\ta\t\tb\t\tm\t\tf(m)\n');
while abs(a-b)>d
m=(a+b)/2;
printf('\t%f\t%f\t%f\t%f\n',a,b,m,f(m)),
if f(m)*f(a)>0
a=m;
else
b=m;
end
c=c+1;
end
printf('the solution of equation after %f iteration is %0.4f',c,m);

Output:-
Que 2. Find the real root of the equation log(x)^2-x=0 using bisection
method.
Programme:-
clc
deff('y=f(x)','y=log(x)^2-x');
a=0;
b=1;
d=0.0001;
c=0;
printf('succesive approximation\n\ta\t\tb\t\tm\t\tf(m)\n');
while abs(a-b)>d
m=(a+b)/2;
printf('\t%f\t%f\t%f\t%f\n',a,b,m,f(m)),
if f(m)*f(a)>0
a=m;
else
b=m;
end
c=c+1;
end
printf('the solution of equation after %f iteration is %0.4f',c,m);

Output:-
EXPERIMENT No. 1
Que 1. Find the real root of the equation ex-8*x=0 using bisection method.
Programme:-
clc
deff('y=f(x)','y=e^x-8*x');
a=0;
b=1;
e=2.7182;
d=0.0001;
c=0;
printf('succesive approximation\n\ta\t\tb\t\tm\t\tf(m)\n');
while abs(a-b)>d
m=(a+b)/2;
printf('\t%f\t%f\t%f\t%f\n',a,b,m,f(m)),
if f(m)*f(a)>0
a=m;
else
b=m;
end
c=c+1;
end
printf('the solution of equation after %f iteration is %0.4f',c,m);

Output:-
Que 2. Find the real root of the equation e2x-8*x=0 using bisection method.
Programme:-
clc
deff('y=f(x)','y=e^(2*x)-8*x');
a=0;
b=1;
e=2.7182;
d=0.0001;
c=0;
printf('succesive approximation\n\ta\t\tb\t\tm\t\tf(m)\n');
while abs(a-b)>d
m=(a+b)/2;
printf('\t%f\t%f\t%f\t%f\n',a,b,m,f(m)),
if f(m)*f(a)>0
a=m;
else
b=m;
end
c=c+1;
end
printf('the solution of equation after %f iteration is %0.4f',c,m);

Output:-

You might also like