function y = MyCubeRoot(x)
% x is a scaler and y is its cube root.

if x==0
    y = 0;
else
    %Compute cube root of x = sign(x)* cube root of abs(x)...
    if x< 0
        signX = -1;
    else
        signX = 1;
    end
    x = abs(x);
    % Determine m and e so that x = m*8^e where 1<=m<8 
    e = floor(log(x)/log(8));
    m = x/8^e;
    % Initial guess. Let L(z) be a line through (1,1) and (8,2), i.e., the
    % linear interpolant of x^(1/3) at x = 1 and x = 8.
    % Thus, L(z) = (6+z)/7. Set the initial gues of m^(1/3) to be L(m)...
    z = (6+m)/7;

    %  Five steps of Netwon renders full machine precision..
    for k=1:5
        z = (2*z + m/z^2)/3;
    end
    % x = m * 8^e means x^(1/3) = m^(1/3) * 2^e
    y = z*(2^e);
    y = signX*y;
end