% Newton iteration near a double root
% newton2.m
% function 1:       f1(x)=x^2-1         simple roots at x=1 and -1
% function 2:       f2(x)=x^2-2*x+1     double root at x=1
% initial guess:    x0=3
% tolerance:        tol=1e-6

clear all; format long; tol=1e-6; 
x1=2; x2=x1; loop=0;
disp([loop x1 x2]);
for loop=1:5
    f1x=x1*x1-1;        f2x=x2*x2-2*x2+1;
    f1p=2*x1;           f2p=2*x2-2;
    x1=x1-f1x/f1p;      x2=x2-f2x/f2p;
    disp([loop x1 x2]);
end;


