##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# ctanf, ctan, ctanl

From cppreference.com
< c‎ | numeric‎ | complex

Defined in header `<complex.h>` |  |
float complex ctanf( float complex z ); |  | (since C99)
double complex ctan( double complex z ); |  | (since C99)
long double complex ctanl( long double complex z ); |  | (since C99)

Computes the complex tangent of `z`.

### [edit] Parameters

z | - | complex argument

### [edit] Return value

The complex tangent of `z`.

### [edit] Example

Run this code

    #include <stdio.h>
    #include <complex.h>
    #include <math.h>

    #define PI acos(-1)

    int main(void)
    {
        double complex z;
        double x;

        /* Print familiar values. */
        int ndx;
        printf("             tan(x)             ctan(z)\n");
        printf("          ------------    ----------------------\n");
        for (ndx=0;ndx<9;ndx++) {
            x = ndx*0.25*PI;
            z = x+0.0*I;
            z = ctan(z);
            printf("%.2f*PI   %12g    %12g%+fi\n", ndx*0.25,tan(x),creal(z),cimag(z));
        }

        return 0;
    }

Output:

    tan(x)             ctan(z)
              ------------    ----------------------
    0.00*PI              0               0+0.000000i
    0.25*PI              1               1+0.000000i
    0.50*PI    1.63312e+16     1.63318e+16-0.000000i
    0.75*PI             -1              -1+0.000000i
    1.00*PI   -1.22465e-16    -1.22461e-16+0.000000i
    1.25*PI              1               1+0.000000i
    1.50*PI    5.44375e+15     5.44393e+15+0.000000i
    1.75*PI             -1              -1+0.000000i
    2.00*PI   -2.44929e-16    -2.44921e-16+0.000000i

### [edit] See also

csin csinf csinl (C99)(C99)(C99) | computes the complex sine (function) [edit]
ccos ccosf ccosl (C99)(C99)(C99) | computes the complex cosine (function) [edit]
catan catanf catanl (C99)(C99)(C99) | computes the complex arc tangent (function) [edit]
tan tanf tanl (C99)(C99) | computes tangent (tan(x)) (function) [edit]
C++ documentation for tan

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/ctan&oldid=70579"