I have attempted to code fixed point iteration to find the solution to (x+1)^(1/3). I keep getting the following error: error: 'g' undefined near line 17 column 6 error: called from fixedpoint at line 17 column 4
clear -all;
clc;
function f = f(x)
f = (x+1)^(1/3)
f = g(x)
end
# Start out iteration loop
x1 = 0;
x2 = g(x1);
iterations = 0; # iteration counter
while abs(x2-x1 > 1e-5)
plot([x1 x1], [x1 g(x1)], 'k-')
plot([x1 x1], [x1 g(x1)], 'k--')
pause
x1 = x2;
x2 = g(x1);
iterations = iterations + 1;
end
iterations
x1
x2
I have no idea what is wrong. My logic seems to be correct.

