clear all % Newton semplice semplice f = @(x) x.^2-2; f1 = @(x) 2*x; tol = 1e-8; maxiter = 10; iter = 0; x0 = 1; x = x0; stimaerrore = -f1(x)\f(x); while (norm(stimaerrore) > tol && iter < maxiter) x = x+stimaerrore; iter = iter+1; stimaerrore = -f1(x)\f(x); end if (norm(stimaerrore) > tol) warning('Troppe iterazioni') end x stimaerrore