복소수 계산기
복소수 사칙연산 및 직교형식·극좌표 상호 변환.
A = a + bi
B = a + bi
자주 묻는 질문
코드 구현
import cmath
import math
# Create complex numbers
z1 = 3 + 4j
z2 = 1 - 2j
# Arithmetic
print(z1 + z2) # (4+2j)
print(z1 - z2) # (2+6j)
print(z1 * z2) # (11-2j)
print(z1 / z2) # (-1+2j)
# Properties
print(z1.real) # 3.0
print(z1.imag) # 4.0
print(abs(z1)) # 5.0 (modulus)
print(z1.conjugate()) # (3-4j)
# Polar form
r, theta = cmath.polar(z1)
print(f"r={r:.3f}, theta={math.degrees(theta):.2f}°")
# r=5.000, theta=53.13°
# From polar back to rectangular
z_back = cmath.rect(r, theta)
print(z_back) # (3+4j)
# Complex math functions
print(cmath.exp(1j * math.pi)) # Euler: e^(i*pi) ≈ -1+0j
print(cmath.sqrt(-1)) # 1j
print(cmath.log(z1)) # complex logarithmComments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.