%
% File name: newton.m
% Author: Suh-Yuh Yang at NCU
% Date: September 21, 2018    
%
clear all;
format long 
x0        = -4.0; 
M         = 100;
delta     = 10^(-5);
epsilon = 10^(-5);
v          = exp(x0) - sin(x0); 
%
%
%
if abs(v) < epsilon  
    display('The approximate solution is obtained')
    x0 
    break
end    
for k=1:1:M
    x1 = x0 - v/(exp(x0) - cos(x0));
    v   = exp(x1) - sin(x1);
    [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
