Bisection Method Problem. Determine the real root of f(x) = 5x^3 - 5x^2 + 6x-2 Using Matlab
(a) plot the function using Matlab from x=0 t0 1 and guess the root
(b) Write a Matlab function to do the Bisection Method. Print the code the answer for an error tolerance of 0.01%
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
format long
f=@(x) 5*x.^3-5*x.^2+6*x-2;
fplot(f,[0,1]);
grid on;
e=0.01e-2;
a=0;
b=1;
iter = 0;
if f(a)*f(b)>=0
disp('No Root')
else
prev = (a+b)/2;
p=a;
while (abs(f(p))>e)
prev=p;
iter =iter+ 1;
p = (a+b)/2;
if f(p) == 0
p
q=1
break;
end
if f(a)*f(p)<0
b = p;
else
a = p;
end
fprintf('Iteration %d, root=%2.8f\n',iter,p);
if(iter==100)
disp('the required accuracy is not reached in 50
iterations');
end
end
end
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.