Le nombre complexe de carré -1 est noté j.
a = 1-2j
a**2
(-3-4j)
i = complex(0,1)
i**2
(-1+0j)
Partie réelle, partie imaginaire :
print(a.real)
print(a.imag)
1.0 -2.0
Conjugué :
a.conjugate()
(1+2j)
Argument :
from cmath import phase
phase(a)
-1.1071487177940904
Module :
abs(a)
2.23606797749979
from cmath import polar
polar(a)
(2.23606797749979, -1.1071487177940904)
Forme exponentielle :
from math import pi
from cmath import exp
b=complex(0,pi/3)
c=exp(b)
print(c.real)
print(c.imag)
0.5000000000000001 0.8660254037844386