tan -- Compute the Trigonometric Tangent

SYNOPSIS

 #include <math.h>

 double tan(double x);
 

DESCRIPTION

tan computes the trigonometric tangent of an argument x expressed in radians.

Because the tangent function is periodic, only the value of x mod 2 pi is used to compute the tangent. If x is very large, only a limited precision is left to represent x mod 2 pi. Thus, an error message is written for very large negative or positive arguments (see DIAGNOSTICS).

RETURN VALUE

tan returns the value of the tangent of the argument x, provided that this value is defined and computable. The return value is a double-precision, floating-point number.

DIAGNOSTICS

The tangent is not defined if x is +- pi/2, +-3pi/2, or any other value of the following form:
 pi/2 + n(pi)
 
n is an integer.

If the value of x is so close to an odd multiple of pi/2 that the tangent cannot be represented accurately, the function returns HUGE_VAL. The run-time library writes an error message to stderr (the standard error file).

If the value of x is greater than 6.7465e9, the function returns 0.0. In this case, the message "total loss of significance" is also written to stderr.

If an error occurs in tan, the _matherr routine is called. You can supply your own version of _matherr to suppress the diagnostic message or modify the value returned.

EXAMPLE

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

  #define YVAL 1.04

  main()
  {
     double cotan;

        /* The cotangent is 1 divided by the */
        /*  tangent of YVAL.                 */
     cotan = 1 / tan(YVAL);
     printf("1 / tan(%f) = %fn", YVAL, cotan);
  }

 

RELATED FUNCTIONS

cos, _matherr, sin

SEE ALSO

Mathematical Functions

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.