![]() Chapter Contents |
![]() Previous |
![]() Next |
| tan |
| Portability: | ISO/ANSI C conforming, UNIX compatible |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| DIAGNOSTICS | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| 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
is used to compute the tangent. If
x
is very large, only a limited precision is left to represent x mod
2
. 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 ±
/2, ± 3
/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
/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) = %f\n", YVAL, cotan);
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.