create a function file in matlab that performs fixedpoint it
create a function file in matlab that performs fixed-point iteration to find the roots of a function. Test your code for the following functions. your inputs should be the g formula, its derivative, an intial guess, and tolerance. your code must also take convergence into consideration.
x3 -x2= x
cos(x)=x
Solution
clc
 clear;
 disp(\'x=x^3-x^2\');
 x=0.1;
 tol=1;
 itr=0;
 while(tol>0.000001),
 xi=x^3-x^2;
 tol=abs(x-xi);
 x=xi;
 itr=itr+1;
 end
 itr
 x
 disp(\'x=cos(x)\');
 x=0.1;
 tol=1;
 itr=0;
 while(tol>0.000001),
 xi=cos(x);
 tol=abs(x-xi);
 x=xi;
 itr=itr+1;
 end
 itr
 x
result:
x=x^3-x^2
itr =
4
 x =
-4.4625e-17
x=cos(x)
itr =
35
 x =
0.7391

