def cuberoot(z):
    z = complex(z)
x = z.real
y = z.imag
mag = abs(z)
arg = math.atan2(y, x)
resMag = mag ** (1.0 / 3)
resArg = [((arg + 2 * math.pi * n) / 3.0) for n in range(1, 4)]
return [(resMag * (math.cos(a) + math.sin(a) * 1j)) for a in resArg]
Cubic root of the negative number on python