The method of Weierstrass simultaneously approximates all roots
of a polynomial
of degree
, assumed to be monic, i.e.:
the coefficient with the highest degree term
of
equals one.
Starting at some initial approximation for all the roots in
,
the method uses the following formula:
>> p = randn(1,6); % degree 5 polynomial >> p = p/p(1); % make monic >> x = randn(1,5) + i*randn(1,5); % 5 random complex numbers >> [x,res] = weierstrass(p,x,1.0e-10,30)The last command returns in x the new vector of approximations for the roots of p after no more than 30 iterations. The method stops earlier if the desired accuracy of 1.0e-10 is reached. The res is the magnitude of p evaluated at x. If res is smaller than the desired accuracy, the method succeeded, otherwise it failed.