arg() function for Complex Number in C++


A complex number is a number that is expressed in the form of a + bi, where a and b are real numbers. i is the imaginary part of number.

The argument is the angle between the positive axis and the vector of the complex number. For a complex number

z = x + iy denoted by arg(z),

For finding the argument of a complex number there is a function named arg() of a complex number in the complex header file.

Syntax

arg(complex_number);

Parameter

The function accepts a complex number as input to calculate the value of the argument for that complex number.

Returned value

The function returns the argument of the complex number.

Example

 Live Demo

#include<iostream>
#include<complex.h>
using namespace std;
int main (){
   double a = 12.0, b = 56.0;
   complex<double> complexnumber (a, b);
   cout<<"The argument of complex number "<<a<<" + i"<<b<< " is: ";
   cout<<arg(complexnumber)<<endl;
   return 0;
}

Output

The argument of complex number 12 + i56 is: 1.3597

Updated on: 24-Oct-2019

468 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements