Converting real numbers to complex numbers
A complex number is represented as " x + yi ". Python converts real numbers x and y to a complex using the complex (x, y) function. The real part can be accessed using the real () function, and the imaginary part can be represented by imag () .
The real part of complex number is: 5.0 The imaginary part of complex number is: 3.0
Complex phase th number
Geometrically, the phase of a complex number — it is the angle between the positive real axis and the vector representing the complex number . This is also known as the argument of a complex number. Phase is returned by phase () , which takes a complex number as an argument. The phase range is from -pi to + pi. that is, from -3.14 to +3.14 .
The phase of complex number is: 3.141592653589793
Conversion from polar to rectangular and vice versa
Conversion to polar is performed using polar () , which returns a pair (r, ph), strong> denoting module r and phase angle ph . a module can be rendered using abs (), and a phase using phase () .
A complex number is converted to rectangular coordinates using rect (r, ph) , where r — module, and ph — phase angle . Returns a value numerically r * (math.cos (ph) + math.sin (ph) * 1j)
The modulus and argument of polar complex number is: (1.4142135623730951, 0.7853981633974483) The rectangular form of complex number is: (1.0000000000000002 + 1j)
Manjit Singh . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.