Complex Math : complex « Data Type « Python Tutorial






x = 4+3j
print x.real
print x.imag
print x

import cmath
print cmath.sqrt(-1)

print cmath.asin(100)
print cmath.asin(4+3j)








2.2.complex
2.2.1.import cmath for Complex number
2.2.2.Complex Number Attributes
2.2.3.imaginary numbers are written with a suffix of "j" or "J"
2.2.4.To extract these parts from a complex number z, use z.real and z.imag.
2.2.5.Use abs(z) to get its magnitude (as a float) or z.real to get its real part
2.2.6.Complex Math