75 views (last 30 days)

Show older comments

J. Alex Lee
on 4 May 2021

Jan
on 4 May 2021

J. Alex Lee
on 4 May 2021

It sounds like you already implemented Newton's method, so just save all your residuals and plot [the log of norm] versus the previous values. The slope of the best fit in the linear region (close to zero) should be order of convergence.

r = nan(MaxIter,1)

for k = 1:MaxIter

% newton iterations

r(k) = % residual calculation

end

ar = abs(r)

% need to filter values of r that are too big or too small...empirically,

% this works for me

mask = ar > 1e-1 | ar < 1e-12

ar(mask) = []

w = ar(1:end-1)

z = ar(2:end)

plot(w,z,'o')

pf = polyfit(w,z,1)

OrderConv = pf(1)

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

Start Hunting!