C++ Complex Library - Arg


Advertisements

Description

It is a phase angle of complex and returns the phase angle (or angular component) of the complex number x, expressed in radians.

Declaration

Following is the declaration for std::arg.

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

C++11

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

Parameters

x It is a complex value.

Return Value

It returns the phase angle (or angular component) of the complex number x, expressed in radians.

Exceptions

none

Example

In below example for std::arg.

#include <iostream>     
#include <complex>      

int main () {
   std::complex<double> mycomplex (1.0,4.0);

   std::cout << "The polar form of " << mycomplex;
   std::cout << " is " << std::abs(mycomplex) << "*e^i*" << std::arg(mycomplex)
      << "rad\n";

   return 0;
}

The sample output should be like this −

The polar form of (1,4) is 4.12311*e^i*1.32582rad
complex.htm
Advertisements