# std::atan(std::complex)

< cpp‎ | numeric‎ | complex

C++
 Language Headers Library concepts Language support library Diagnostics library Utilities library Strings library Containers library Algorithms library Iterators library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications

Numerics library
 Common mathematical functions Special mathematical functions Floating-point environment (C++11) Complex numbers Numeric arrays Pseudo-random number generation Compile-time rational arithmetic (C++11) Numeric algorithms gcd(C++17) lcm(C++17) Generic numeric operations iota(C++11) accumulate inner_product adjacent_difference partial_sum

std::complex
Member functions
Non-member functions
 real imag abs arg norm conj proj(C++11) polar operator""ioperator""ifoperator""il(C++14)(C++14)(C++14)
Exponential functions
Power functions
Trigonometric functions
 asin(C++11) acos(C++11) atan(C++11)
Hyperbolic functions
 asinh(C++11) acosh(C++11) atanh(C++11)

 Defined in header  template< class T > complex atan( const complex& z ); (since C++11)

Computes complex arc tangent of a complex value z. Branch cut exists outside the interval [−i ; +i] along the imaginary axis.

## Contents

### Parameters

 z - complex value

### Return value

If no errors occur, complex arc tangent of z is returned, in the range of a strip unbounded along the imaginary axis and in the interval [−π/2; +π/2] along the real axis.

Errors and special cases are handled as if the operation is implemented by -i * std::atanh(i*z), where i is the imaginary unit.

### Notes

Inverse tangent (or arc tangent) is a multivalued function and requires a branch cut on the complex plane. The branch cut is conventionally placed at the line segments (-∞i,-i) and (+i,+∞i) of the imaginary axis.

The mathematical definition of the principal value of inverse tangent is atan z = -
 1 2
i [ln(1 - iz) - ln (1 + iz]

### Example

#include <iostream>
#include <complex>
#include <cmath>
int main()
{
std::cout << std::fixed;
std::complex<double> z1(0, 2);
std::cout << "atan" << z1 << " = " << std::atan(z1) << '\n';

std::complex<double> z2(-0.0, 2);
std::cout << "atan" << z2 << " (the other side of the cut) = "
<< std::atan(z2) << '\n';

std::complex<double> z3(0, INFINITY);
std::cout << "2*atan" << z3 << " = " << 2.0*std::atan(z3) << '\n';
}

Output:

atan(0.000000,2.000000) = (1.570796,0.549306)
atan(-0.000000,2.000000) (the other side of the cut) = (-1.570796,0.549306)
2*atan(0.000000,inf) = (3.141593,0.000000)

### See also

 asin(std::complex)(C++11) computes arc sine of a complex number (arcsin(z)) (function template)  acos(std::complex)(C++11) computes arc cosine of a complex number (arccos(z)) (function template)  tan(std::complex) computes tangent of a complex number (tan(z)) (function template)  atan computes arc tangent (arctan(x)) (function)  atan(std::valarray) applies the function std::atan to each element of valarray (function template)  C documentation for catan