{"id":25443,"date":"2021-11-10T14:59:51","date_gmt":"2021-11-10T09:29:51","guid":{"rendered":"https:\/\/python-programs.com\/?p=25443"},"modified":"2021-11-14T15:03:01","modified_gmt":"2021-11-14T09:33:01","slug":"python-cmath-rect-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-cmath-rect-method-with-examples\/","title":{"rendered":"Python cmath.rect() Method with Examples"},"content":{"rendered":"

cmath.rect() Method in Python:<\/strong><\/p>\n

The cmath.rect() method converts polar coordinates to the complex number’s rectangular form. It generates a complex number that includes phase and modulus.<\/p>\n

This method equals r * (math.cos(phi) + math.sin(phi)*1j).<\/p>\n

The radius r is the vector’s length, and phi (phase angle) is the angle formed with the real axis.<\/p>\n

Syntax:<\/strong><\/p>\n

cmath.rect(r, phi)<\/pre>\n

Parameters<\/strong><\/p>\n

r:<\/strong> This is Required. The modulus of a complex number is represented by this symbol.<\/p>\n

phi:<\/strong> This is Required. It represents a complex number’s phase.<\/p>\n

Return Value:<\/strong><\/p>\n

Returns a\u00a0complex value that represents a complex number in its rectangular form.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given modulus = 2.135667\r\nGiven phase = 6.1111116<\/pre>\n

Output:<\/strong><\/p>\n

The rectangular form of the complex number =  (2.104127071172476-0.3656812864341552j)<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given modulus = 5\r\nGiven phase = 2<\/pre>\n

Output:<\/strong><\/p>\n

The rectangular form of the complex number =  (-2.080734182735712+4.546487134128409j)<\/pre>\n

cmath.rect() Method with Examples in Python<\/h2>\n