edit on this code and solve the question

function [x, flag] = newtonsolver_template(x0, tol)

flag = 1;
r0 = zeros();
J = zeros();
x = zeros();
rtest = zeros();

r0(1) = ;
r0(2) = ;

r = r0;
counter = 1;
while (norm(r)/norm(r0) > tol)

J(1,1) = ;
J(1,2) = ;
J(2,1) = ;
J(2,2) = ;

s = Jr;
lambda = 1.0;
while (1)
x = x0 – lambda*s;
rtest(1) = ;
rtest(2) = ;
if (norm(rtest) < 1.001*norm(r))
r = rtest;
x0 = x;
break;
else
lambda = lambda/2;
end
end

counter = counter + 1;
disp(norm(r))
if counter == 100
flag = 0;
break;
end

end

end

 

"Is this question part of your assignment? We Can Help!"

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp