In: Advanced Math
Numerical Analysis:
Use Muller's method to find a solution in [0.1, 1] accurate to within 600x^4−550x^3+200x^2−20x−1=0. Explain how the algorithm works.
Please show table with all values, not just the final root value.
%Matlab code for muller method for finding root
clear all
close all
%function for which root have to find
f=@(x) 600.*x.^4-550.*x.^3+200.*x.^2-20.*x-1;
%three initial guess for x
x0=0;
x1=0.1;
x2=1.0;
%error value for initiation of while loop
error=10;
%displaying the function
fprintf('The function is f(x)=')
disp(f)
%printing result after each iterations
fprintf('Printing result after each iterations\n')
fprintf('\titer,\tf(x0),\tf(x1),\tf(x2),\ta,\tb,\tc,\tx3,\terror\n\n')
cnt=0;
%Loop for Muller's method
while error>=10^-5
%function value corresponds to initial
guess
f0=f(x0);
f1=f(x1);
f2=f(x2);
cnt=cnt+1;
%all other terms for Muller method
h0=x1-x0;
h1=x2-x1;
del0=(f(x1)-f(x0))/h0;
del1=(f(x2)-f(x1))/h1;
a=(del1-del0)/(h1+h0);
b=a*h1+del1;
c=f(x2);
x31=x2+((-2*c)/(b+sqrt(b*b-4*a*c)));
x32=x2+((-2*c)/(b-sqrt(b*b-4*a*c)));
%checking root closer to zero
if abs(f(x31))>=abs(f(x32))
x3=x32;
else
x3=x31;
end
%percentage error after each iterations
error=(abs((x3-x2)/x3))*100;
fprintf('\t%d,\t%2.2f,\t%2.2f,\t%2.2f,\t%2.2f,\t%2.2f,\t%2.2f,\t%2.2f,\t%2.2e\n',...
cnt,f0,f1,f2,a,b,c,x3,error);
%changing x values after each iteration
x0=x1; x1=x2;x2=x3;
end
fprintf('\nThe root of the function is %f.\n',x3)
%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%