How to add a Sequence of Estimates to my Newton Raphson Code? please help!!

1 view (last 30 days)
My code works BUT I need to add 1 more thing:
  1. output- a vector containing the sequence of estimates including the initial guess x0,
function [ r, n ] = myNewton( fHan,dfHan,x0,fTol, itermax )
i = 1;
while abs(fHan(x0)) >= fTol
r(i) = x0;
n(i) = abs(fHan(x0));
i = i+1;
x0 = x0-((fHan(x0))/(dfHan(x0)));
end
for j = 1:itermax;
dx = fHan(r) / dfHan(r);
r = r - dx
if r < fTol
return
end
end
if abs(fHan(x0)) < fTol
r(i) = x0;
n(i) = abs(fHan(x0));
end
end
how do I go about doing this? thanks!!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!