Home >>Python cmath Module >Python cmath.rect() Method

Python cmath.rect() Method

Python cmath.rect() Method

Python cmath.rect() method in python is used to converts polar coordinates to rectangular form of the complex given number and creates a complex number with phase and modulus. It is equivalent to r * (math.cos(phi) + math.sin(phi)*1j).

Syntax:
cmath.rect(r, phi)

Parameter Values

Parameter Description
r It is a required parameter used to Represents the modulus of a given complex number
phi It is a required parameter used to Represents the phase of a given complex number
Here is an Example of Python cmath.rect() Method:

import cmath
print(cmath.rect(3.1622776601683795, 1.2490457723982544))

Output:
(1+3j)
Example 2:

import cmath
print(cmath.rect(7.211102550927978, 0.982793723247329))

Output:
(4+6j)