function xout = newton(x) % % example of Newton's method for solving g(x) = 0 % % here: g(x) = x^3 - 2 % g = x*x*x-2; gprime = 3*x*x; xout = x - g ./ gprime;