% example for Newton method with 310 digits accuracy
% Find zero of f(x) = x - cos(x) starting with x0 = 0

digits(310)           % set number of digits used for computation    
x = vpa('0');         % define all constants using vpa, e.g. vpa('1/3'), vpa('pi')

for k=1:15
  k
  f = x - cos(x);     % f(x)
  fnorm = norm(double(f),Inf)
  fp = 1 + sin(x);    % f'(x)
  s = -fp\f;
  snorm = norm(double(s),Inf)
  x = x + s;
end
