% cube_root.m
% Carry out an iteration to estimate the cube root of a number.
%
%  We require X*Y*Z = W
%  and we try to "encourage" x=y=z.
%
w = 2017;
%
%  Initialize, so that X*Y*Z = W
x = w;
y = 1;
z = 1;
%
%  Replace X and Y by average of X, Y and Z.
%  Set Z so that it's still true that X*Y*Z = W.
%
x = ( x + y + z ) / 3.0;
y = x;
z = w / x / y;
%
%  Repeat this ... maybe 5 times.
%  we don't know yet how to decide when to stop!
%
x = ( x + y + z ) / 3.0;
y = x;
z = w / x / y;

x = ( x + y + z ) / 3.0;
y = x;
z = w / x / y;

x = ( x + y + z ) / 3.0;
y = x;
z = w / x / y;

x = ( x + y + z ) / 3.0;
y = x;
z = w / x / y;

x = ( x + y + z ) / 3.0;
y = x;
z = w / x / y;
%
%  Print final x, y, z, probably not good since we didn't take many steps.
%
x
y
z

