I need to change this code into one that can solve complex roots
7 views (last 30 days)
Elena Cecilia Valero Garza on 12 Sep 2022
I have this Newton-Raphson method code, but I need to change it into a code that can actually solve polynomials and give as an answer complex roots.
function [tabla, raiz]=newtonraphsonMN(f,xa,errorD,imax)
while error>errorD && i<=imax
tabla=[tabla; [xa fxa fpxa xr error]];
John D'Errico on 12 Sep 2022
Edited: John D'Errico on 13 Sep 2022
Interesting. It does not work? :) Gosh, You could have fooled me. I'll try an example. (I've attached the code you gave, so it will be used.)
f = X^2 + X + 1;
Does f has complex roots?
Of course. I'd not have used an example that lacks complex roots, since that is your question.
[tabla, raiz]=newtonraphsonMN(f,1 + i,1e-12,100);
To me, it seems to have worked. But then, what do I know? :)
(Hint: Do you see what I did different?)