%computer problem 3.2 #19 -- extended to repeated roots of any order

m = 10;
f = @(x) x^m + 2*x^(m+1);
f_p = @(x) m*x^(m-1) + 2*(m+1)*x^m;
n = 5;

x = 1;
y = 1;    %initial guesses

for i=1:n
    x = x - m*f(x)/f_p(x);
    y = y - f(y)/f_p(y);
end

disp('modified Newton method root estimate is...')
x
disp('standard Newton method root estimate is...')
y