% truncation_example_2.m % A finite number of iterations of the % currently mysterious iteration x <- x/2 + 1/x % to approximate the square root of 2. x(1) = 2; % initial (quite bad) approximation for i = 1:4 x(i+1) = x(i)/2 + 1/x(i); end format long format compact squares = x.^2; fprintf('\n x x^2\n'); [x;squares]'