VOOZH about

URL: https://www.geeksforgeeks.org/python/python-cmath-rect-method/

⇱ Python - cmath.rect() method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python - cmath.rect() method

Last Updated : 1 Jun, 2020

cmath is a Python built-in module that is used for complex number mathematics. cmath module has a method rect() that is used to convert polar coordinate into rectangular form.

Syntax: cmath.rect(r, phi)

Parameter: It take two arguments. First argument r, denotes the modulus of the complex number and the second argument denotes the phase. Both arguments are required. None is optional.

Return: Returns a complex number Z whose modulus is r and phase is phi.

Note: r * (math.cos(phi) + math.sin(phi)*1j) is equivalent to this method.

Example 1: 

Output:

(-2.517214587229357-1.6320633326681093j)

Example 2: In this example modulus is taken as zero.

Output:

0j

Example 3: In this example phase is taken as zero

Output:

(1+0j)
Comment
Article Tags: