Cho số phức c = x + yj. Chuyển sang tọa độ cực (radius, angle):
radius = |c| = sqrt(x² + y²)(dùngabs(c)).angle = phase(c)(góc radian, dùngcmath.phase()).
Ví dụ: c = 2+5j → (5.385..., 1.190...).
Ví dụ mã nguồn
import cmath
def solve(c):
return (abs(c), cmath.phase(c))
c = 2+5j
print(solve(c)) # (5.385164807134504, 1.1902899496825317)
Đầu vào / Đầu ra
Input: 2+5j
Output: (5.385164807134504, 1.1902899496825317)