function HW3_2(n) g1 = @(x)(3+x-2*x^2)^(1/4); g2 = @(x)((x+3-x^4)/2)^(1/2); g3 = @(x)((x+3)/(x^2+2))^(1/2); g4 = @(x)(3*x^4+2*x^2+3)/(4*x^3+4*x-1); %start iterations (Need to close the below) %p([1:4]) = 1; %initial values %for i = 1:n % p(1) = g1(p(1)); % p(2) = g2(p(2)); % p(3) = g3(p(3)); % p(4) = g4(p(4)); % fprintf('n = %2.0f %16.8f %16.8f %16.8f %16.8f\n', i, p(1), p(2), p(3), p(4)); %end %compute |p(i)-p(i+1)| in ith iteration (Need to close the above) p([1:4]) = 1; e([1:4]) = 0; for i = 1:n e(1) = abs( p(1) - g1(p(1)) ); e(2) = abs( p(2) - g2(p(2)) ); e(3) = abs( p(3) - g3(p(3)) ); e(4) = abs( p(4) - g4(p(4)) ); p(1) = g1(p(1)); p(2) = g2(p(2)); p(3) = g3(p(3)); p(4) = g4(p(4)); fprintf('n = %2.0f %16.8f %16.8f %16.8f %16.8f\n', i, e(1), e(2), e(3), e(4)); end end