Rectangular and polar conversion
A complex number is a point: in rectangular form a + bi, a fixes the horizontal position, b the vertical. To convert to polar, the modulus r = sqrt(a2 + b2) and the argument theta = atan2(b, a) are computed; atan2 keeps the angle's sign correct in all four quadrants. Converting back, a = r cos(theta) and b = r sin(theta).