Calculating multiple roots
One way to speed up convergence in finding multiple zero's is to use the function
instead of the function
itself.
Indeed, if
has a zero of multiplicity
at
, then
and,
> f:=x->(x-p)^m*q(x);
> mu:=x->f(x)/(D(f)(x));
> mu(x);
> simplify(mu(x));
which has a root at
as well, but a simple one. Therefore, applying Newton-Raphson on this function should yield quadratic convergence:
> f:=x->exp(x)-x-1;
> df:=D(f);
> mu:=x->f(x)/df(x):mu(x);
> mu1:=x->1-x/(exp(x)-1);
> dmu1:=D(mu1);
> p[0]:=5.0;
> for i from 1 to 5 do p[i]:=p[i-1]-mu1(p[i-1])/(dmu1(p[i-1])): print(i,p[i],abs(p[i]/p[i-1]),abs(p[i]/(p[i-1])^2)); od: