Sample Matlab codes for Mapl/CMCS 466, Spring 2000 - Bo Li
% Newton's method for solving a nonlinear equation: 4 x^3 - 2 x^2 + 3 = 0
% starting with x_0 = -1.
clear;
format long
x = -1;
for k = 0:5
f = 4*x*x*x-2*x*x+3;
disp(sprintf('%5.0f %14.8f %14.8f',k,x,f));
fp = 12*x*x-4*x;
x = x-f/fp;
end