VOOZH about

URL: https://www.geeksforgeeks.org/cpp/polar-function-for-complex-number-in-cpp/

⇱ polar() function for complex number in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

polar() function for complex number in C++

Last Updated : 17 Aug, 2022

The polar() function for complex numbers is defined in the complex header file. The polar function is used to find the complex number from phase angle and magnitude. 

Syntax:

polar(mag, angle)

Parameter:

  • mag: It represents the magnitude of the complex number.
  • angle: It represents the phase angle.

Return Type: This function returns a complex number which is obtained by phase angle and magnitude. 

Below program illustrate the above function is as follows:

Program 1: 

Output:
The complex number whose magnitude is 4.0 and phase angle 1.5 is (0.282949,3.98998)

Time Complexity: O(1)
Auxiliary Space: O(1)

Program 2: 

Output:
The complex number whose magnitude is 2.0 and phase angle 0.5 is (1.75517,0.958851)

Time Complexity: O(1)
Auxiliary Space: O(1)

Comment