Answered step by step
Verified Expert Solution
Question
1 Approved Answer
fixedpoint.m: function [ x, k ] = fixed_point( gfunc, x0, atol, nmax ) xk = rand; % Just to start the while loop. res =
fixedpoint.m:
function [ x, k ] = fixed_point( gfunc, x0, atol, nmax )
xk = rand; % Just to start the while loop.
res = xk - x0;
k = 0; % Iteration index.
iflag = 0;
while abs(res)>atol
xk = feval(gfunc,x0); % x_{k+1} = g(x_{k})
res = xk - x0;
x0 = xk;
k = k + 1;
if(k == nmax)
iflag = -1;
break;
end
end
if(iflag==0)
k = k + 1;
x = xk;
else
disp(' maximum number of iterations reached!');
x = [];
k = [];
end
end
Using the m-file "fixed point.m", find the three roots of with lzk+1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started