% P1: Checks out MyCubeRoot
n = 100;
x = [linspace(-100,-1,n) -logspace(-3,0,n) 0 logspace(-3,0,n) linspace(1,100,n)];
y = zeros(1,length(x));
RelErr = zeros(1,length(x));
for i=1:length(x)
    y(i) = MyCubeRoot(x(i));
    if x(i) < 0
        exact = -(-x(i))^(1/3);
    else
        exact = x(i)^(1/3);
    end
    if exact==0 && y(i)==0
        RelErr(i) = 0;
    else
        RelErr(i) = abs(y(i) - exact)/abs(exact);
    end
end
semilogy(x,RelErr+eps)
title(sprintf('Relative Error in MyCubeRoot   (Max = %10.3e)',max(RelErr)))
shg