# catanf, catan, catanl

> C++ Atlas: `cppatlas.com/w/c/numeric/complex/catan` | Source: https://en.cppreference.com/w/c/numeric/complex/catan | Domain: Numerics | Standards: C99

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.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <complex.h>
float complex       catanf( float complex z ); // (1) (since C99)
double complex      catan( double complex z ); // (2) (since C99)
long double complex catanl( long double complex z ); // (3) (since C99)
// Defined in header <tgmath.h>
#define atan( z ) // (4) (since C99)
```

1-3) Computes the complex arc tangent of `z` with branch cuts outside the interval [−i,+i] along the imaginary axis.

4) Type-generic macro: If `z` has type `long double complex`, `catanl` is called. if `z` has type `double complex`, `catan` is called, if `z` has type `float complex`, `catanf` is called. If `z` is real or integer, then the macro invokes the corresponding real function (`atanf`, `atan`, `atanl`). If `z` is imaginary, then the macro invokes the corresponding real version of the function `atanh`, implementing the formula atan(iy) = i atanh(y), and the return type of the macro is imaginary.

### Parameters

- `z` - complex argument

### 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 * catanh(I*z)`.

### 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

```c
#include <stdio.h>
#include <float.h>
#include <complex.h>

int main(void)
{
    double complex z = catan(2*I);
    printf("catan(+0+2i) = %f%+fi\n", creal(z), cimag(z));

    double complex z2 = catan(-conj(2*I)); // or CMPLX(-0.0, 2)
    printf("catan(-0+2i) (the other side of the cut) = %f%+fi\n", creal(z2), cimag(z2));

    double complex z3 = 2*catan(2*I*DBL_MAX); // or CMPLX(0, INFINITY)
    printf("2*catan(+0+i*Inf) = %f%+fi\n", creal(z3), cimag(z3));
}
```

Output:

```text
catan(+0+2i) = 1.570796+0.549306i
catan(-0+2i) (the other side of the cut) = -1.570796+0.549306i
2*catan(+0+i*Inf) = 3.141593+0.000000i
```

### References

- C11 standard (ISO/IEC 9899:2011):

  - 7.3.5.3 The catan functions (p: 191)

  - 7.25 Type-generic math \<tgmath.h> (p: 373-375)

  - G.7 Type-generic math \<tgmath.h> (p: 545)

- C99 standard (ISO/IEC 9899:1999):

  - 7.3.5.3 The catan functions (p: 173)

  - 7.22 Type-generic math \<tgmath.h> (p: 335-337)

  - G.7 Type-generic math \<tgmath.h> (p: 480)

### See also

- [`casin`](https://en.cppreference.com/w/c/numeric/complex/casin) (C99), [`casinf`](https://en.cppreference.com/w/c/numeric/complex/casin) (C99), [`casinl`](https://en.cppreference.com/w/c/numeric/complex/casin) (C99): computes the complex arc sine (function)
- [`cacos`](https://en.cppreference.com/w/c/numeric/complex/cacos) (C99), [`cacosf`](https://en.cppreference.com/w/c/numeric/complex/cacos) (C99), [`cacosl`](https://en.cppreference.com/w/c/numeric/complex/cacos) (C99): computes the complex arc cosine (function)
- [`ctan`](https://en.cppreference.com/w/c/numeric/complex/ctan) (C99), [`ctanf`](https://en.cppreference.com/w/c/numeric/complex/ctan) (C99), [`ctanl`](https://en.cppreference.com/w/c/numeric/complex/ctan) (C99): computes the complex tangent (function)
- [`atan`](https://en.cppreference.com/w/c/numeric/math/atan), [`atanf`](https://en.cppreference.com/w/c/numeric/math/atan) (C99), [`atanl`](https://en.cppreference.com/w/c/numeric/math/atan) (C99): computes arc tangent (arctan(x)) (function)
- [C++ documentation for `atan`](https://en.cppreference.com/w/cpp/numeric/complex/atan)

---
Attribution: content from https://en.cppreference.com/w/c/numeric/complex/catan (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.