% ECE 260 example for Lab1 (Newton's Method)
clear;
clc;
% x0=-1;
x0=10;
epsilon=1e-4;
for n=0:1:1000
    fx0=x0^2-2*x0;
    fpx0=2*x0-2;
    xn=x0-(fx0/fpx0);
    if abs(xn-x0) < epsilon
        break;
    end
    x0=xn;
end
display(xn);
display(n);
display(xn-x0);