Find the n-th roots of z = a + bi
atan(b/a)
to find the angle θ can be incorrect, as it doesn't distinguish between quadrants. For example, atan(1/-1)
and atan(-1/1)
both give -45°, but the numbers (-1 + i) and (1 - i) are in different quadrants. Using the atan2(b, a)
function is essential as it correctly identifies the angle in all four quadrants.+ 2πk
part is what generates the different roots. Forgetting it will only give you the principal root (for k=0).