In [1]:
import cmath
import math
In [2]:
c = 1 + 1j
In [3]:
print(math.atan2(c.imag, c.real))
In [4]:
print(cmath.phase(c))
In [5]:
print(cmath.phase(c) == math.atan2(c.imag, c.real))
In [6]:
print(math.degrees(cmath.phase(c)))
In [7]:
c = 1 + 1j
print(cmath.polar(c))
print(type(cmath.polar(c)))
In [8]:
print(cmath.polar(c)[0] == abs(c))
In [9]:
print(cmath.polar(c)[1] == cmath.phase(c))
In [10]:
print(cmath.rect(1, 1))
In [11]:
print(cmath.rect(1, 0))
In [12]:
print(cmath.rect(cmath.polar(c)[0], cmath.polar(c)[1]))
In [13]:
r = 2
ph = math.pi
In [14]:
print(cmath.rect(r, ph).real == r * math.cos(ph))
In [15]:
print(cmath.rect(r, ph).imag == r * math.sin(ph))
In [16]:
print((-3 + 4j) ** 0.5)
In [17]:
print((-1) ** 0.5)
In [18]:
print(cmath.sqrt(-3 + 4j))
In [19]:
print(cmath.sqrt(-1))