tangent function

You're viewing an older version of this page (#3442). View the current version.

View versions (4)

INTERFACE

#include <math.h>

double tan ( double x ) long tanl ( long double x ) float tanf ( float x )

#include <complex.h> complex tan(complex x) double complex ctan(double complex x) float complex ctan(float complex x) long double complex ctanl(long double complex x)

DESCRIPTION

The tan function computes the tangent of x (measured in radians). This is identical to the calculation of

\tan(x) = \frac{\sin(x)}{\cos(x)}
(1)

Example 1

#include <stdio.h>
#include <math.h>
 
int main()
{
  double x = 0.3333;
  double result = tan(x);
  printf("The tangent of %.4lf is %.4lf\n", x, result);
  return 0;
}

Output:

The tangent of 0.3333 is 0.3462

SPECIAL VALUES

tan ( &plusmn;0 ) returns &plusmn;0.
tan ( &plusmn;&infin; ) returns a NaN and raises the invalid floating-point exception.

SEE ALSO

acos, asin, atan, atan2, cos, cosh, sin, sinh, tanh

STANDARDS

The tan function conforms to ISO/IEC 9899:1999(E).

COMPATIBILITY

DOSUNIXWindowsANSI CC++ only
tanl••
Real tan••••
Complex tan•••
Complex ctan••