tan Function

Calculates the trigonometric tangent function of a double precision floating-point value.

Include

<math.h>

Prototype

double tan (double x);

Argument

x
value for which to return the tangent

Return Value

Returns the tangent of x in radians.

Remarks

A domain error will occur if x is a NaN or infinity.

Example

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

int main(void)
{
  double x, y;

  errno = 0;
  x = -1.0;
  y = tan (x);
  if (errno)
    perror("Error");
  printf("The tangent of %f is %f\n", x, y);

  errno = 0;
  x = 0.0;
  y = tan (x);
  if (errno)
    perror("Error");
  printf("The tangent of %f is %f\n", x, y);
}

Example Output

The tangent of -1.000000 is -1.557408
The tangent of 0.000000 is 0.000000