I want to find a function $g$ such that it is a contraction and such that finding its fixed point is the same as finding the zeros of $f(x)=x^3+x-3$ because I have implemented the fixed-point iteration method in MATLAB as follows
function fixedpointt(x0)
%example of fixed point iteration
%zeros of f(x)=x^3+x-3
tol=10^-6; % tolerance
itmax=1000; % max number of iterations
itnum=0; % iterations counter
%x0=10; % initial condition
disp([itnum,x0])
x1=g3(x0);
itnum=itnum+1;
disp([itnum,x1,abs((x0-x1)/x0)])
while abs((x0-x1)/x0)>tol && itnum<itmax
x0=x1;
x1=g3(x0);
itnum=itnum+1;
disp([itnum,x1,abs((x0-x1)/x0)])
end
end
function y=g3(x)
y=3/(x^2+1);
end
The thing is that I figured out $g(x)=\frac{3}{x^2+1}$ but it didn't worked, so Can someone help me to find a function that fits with the above characteristics please?
Thanks a lot in advance.