function template

std::arg

<complex>
template<class T> T arg (const complex<T>& x);
Return phase angle of complex
Returns the phase angle (or angular component) of the complex number x, expressed in radians.

The phase angle of a complex number is the angle the theoretical vector to (real,imag) forms with the real axis (i.e., its arc tangent). It returns the same as:
 
atan2(x.imag(),x.real());


Parameters

x
Complex value.

Return value

Phase angle of x.
T is x's complex template type (i.e., its value type).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// arg complex example
#include <iostream>
#include <complex>
using namespace std;

int main ()
{
  complex<double> mycomplex (3.0,4.0);

  cout << "The polar form of " << mycomplex;
  cout << " is " << abs(mycomplex) << "*e^i*" << arg(mycomplex) << "rad" << endl;

  return 0;
}


Output:

The polar form of (3,4) is 5*e^i*0.927295rad

See also