function [q,x] = m_newton(p,x,eps,N) % % Applies a modified Newton's method on (x-1)^d, % modefied to take the multiplicity into account. % n = size(p,2); d = [1 -x]; [q,r] = deconv(p,d); % fprintf(' real(x) imag(x) dx f(x) \n'); for i = 1:N [q1,r1] = deconv(q,d); dx = r(n)/r1(n-1); x = x - (n-1)*dx; d(2) = -x; [q,r] = deconv(p,d); % fprintf('%.15e %.15e %.2e %.2e\n', real(x), imag(x), dx, r(n)); if (abs(dx) < eps) | (abs(r(n)) < eps) % fprintf('succeeded after %d steps\n', i); return; end end fprintf('failed requirements after %d steps\n', N);