In [1]:
import cmath
import math

In [2]:
c = 1 + 1j

In [3]:
print(math.atan2(c.imag, c.real))


0.7853981633974483

In [4]:
print(cmath.phase(c))


0.7853981633974483

In [5]:
print(cmath.phase(c) == math.atan2(c.imag, c.real))


True

In [6]:
print(math.degrees(cmath.phase(c)))


45.0

In [7]:
c = 1 + 1j

print(cmath.polar(c))
print(type(cmath.polar(c)))


(1.4142135623730951, 0.7853981633974483)
<class 'tuple'>

In [8]:
print(cmath.polar(c)[0] == abs(c))


True

In [9]:
print(cmath.polar(c)[1] == cmath.phase(c))


True

In [10]:
print(cmath.rect(1, 1))


(0.5403023058681398+0.8414709848078965j)

In [11]:
print(cmath.rect(1, 0))


(1+0j)

In [12]:
print(cmath.rect(cmath.polar(c)[0], cmath.polar(c)[1]))


(1.0000000000000002+1j)

In [13]:
r = 2
ph = math.pi

In [14]:
print(cmath.rect(r, ph).real == r * math.cos(ph))


True

In [15]:
print(cmath.rect(r, ph).imag == r * math.sin(ph))


True

In [16]:
print((-3 + 4j) ** 0.5)


(1.0000000000000002+2j)

In [17]:
print((-1) ** 0.5)


(6.123233995736766e-17+1j)

In [18]:
print(cmath.sqrt(-3 + 4j))


(1+2j)

In [19]:
print(cmath.sqrt(-1))


1j