C++ complex arg

The C++ complex arg compute the phase angle of the complex number.The declaration of the function is given below.

template<class T> T arg(const complex<T>& x);

x -The complex number whose phase angle is to be computed.

Return type
T -A phase angle of T type.

Some points to note:

i)This function is equivalent to atan2(imag(x), real(x)).

Link :C++ cmath atan2

ii)Suppose x+iy is a complex number then consider the value ‘x’ and ‘y’ depicted in the imaginary-axis and real-axis.

C++ complex phase angle

The angle ‘Θ’ is known as the phase angle of the complex number.

This function is same as the C <complex.h> header carg function.

Code example

complex< double > c1(23.4 , 5.78);

cout<< arg( c1 ) << endl ;

cout<< atan2( imag(c1) , real(c1)) ;

Output ,


Link :C++ complex real

Link :C++ complex imag