Illustration for “Cube root in Python” (1 of 3)

Quite a funny thing. It turned out that the Python works in the complex plane by default. Therefore when you are trying to take a cube root of a negative number ** operator thinks in complex plane in terms of argument and magnitude. The magnitude is 8 and its root is 2 - no surprise. The argument is 180 degrees, operator divides it by three and gives 60∘60^\circ. Real and imaginary parts are:

Illustration for “Cube root in Python” (2 of 3)

To avoid this surprise you can use

Illustration for “Cube root in Python” (3 of 3)

This function honestly looks for a real number whose cube is -8.