%
% File name: comparisonnewton.m
% Author: Suh-Yuh Yang at NCU
% Date: September 21, 2018   
%
clear all;
format long 
x0        = 2.0; 
M         = 100;
delta     = 10^(-10);
epsilon = 10^(-10);
v          = (x0)^2- 1.0; 
%
%
%
if abs(v) < epsilon  
    display('The approximate is obtained')
    x0 
    break
end    
for k=1:1:M
    x1 = x0 - v/(2.0*x0);
    v   = (x1)^2 - 1.0;
    [k, x1, v]
    if abs(x1-x0) < delta | abs(v) < epsilon
        display('The approximate solution is obtained')  
        [k, x1, v]
        break 
    else
        x0 = x1;         
    end
end
