C++ Standard Library C++ STL Library

C++ <complex> - atan() Function



The C++ <complex> atan() function returns the complex arc tangent of a complex number z. It is a function on complex plane, and has two branch cuts:

  • Extends from 1j along the imaginary axis to ∞j, continuous from the right.
  • Extends from -1j along the imaginary axis to -∞j, continuous from the left.

Mathematically, it can be expressed as:

complex atan

Syntax

template<class T> complex<T> atan (const complex<T>& z);        

Parameters

z Specify the complex number.

Return Value

Returns the complex arc tangent of z.

Example:

The example below shows the usage of <complex> atan() function.

#include <iostream>
#include <complex>
using namespace std;
 
int main (){
  complex<double> z1 (2, 2);
  complex<double> z2 (2, 0);
  complex<double> z3 (0, 2);

  //calculate the complex arc tangent
  cout<<"atan(z1): "<<atan(z1)<<"\n";
  cout<<"atan(z2): "<<atan(z2)<<"\n";
  cout<<"atan(z3): "<<atan(z3)<<"\n";

  return 0;
}

The output of the above code will be:

atan(z1): (1.31122,0.238878)
atan(z2): (1.10715,0)
atan(z3): (1.5708,0.549306)

❮ C++ <complex> Library

5