function [x, it] = newtonmv(w)
% multivariate Newton method
%w is initial guess
%tol is the tolerance to solve to
% requires function f coded separately
%and jacobian Jx of f coded separately

it = 0;
fx = S(w);

while it < 15
   Jx = jf(w);
   w = w - Jx \ fx;
   %w
   fx = S(w);
   it = it + 1;
   it
   w
end;