I need to change this code into one that can solve complex roots
7 ビュー (過去 30 日間)
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 2022 年 9 月 12 日
編集済み: John D'Errico 2022 年 9 月 13 日
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?)