You are on page 1of 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