tan
Compute the tangent of the input radian.
Interface Definition
C interface:
float tanf(float x);
double tan(double x);
long double tanl(long double x);
Fortran interface:
RES = TANF(X);
RES = TAN(X);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of a radian angle. |
Input |
Return Value
- The tangent y of the radian angle x is returned. y ∈ (-INF, +INF)
- If the input is +0, the return value is +0.
- If the input is -0, the return value is -0.
- If the input is ±∞, the return value is NaN.
- If the input is NaN, the return value is NaN.
This function has a mathematical pole at π(1/2 + n). Because no general floating-point numbers can accurately represent the value at the pole, the return value for the pole cannot be considered reliable.
Dependencies
C: "km.h"
Fortran: "km.f03"
Examples
C interface:
double pi = acos(-1);
// typical usage
double a = pi/3, c = -3*pi/4, d = 0.0;
// special handling
double b = pi/2, e = INFINITY, f = -INFINITY, g = NAN;
double complex k = 0 + 0 * I;
// print result
printf("tan(pi/3) = %.15f\n", tan(a));
printf("tan(-3*pi/4) = %.15f\n", tan(c));
printf("tan(0.0) = %.15f\n", tan(d));
// mathematical poles
printf("tan(pi/2) = %.15f\n", tan(b));
printf("tan(INFINITY) = %.15f\n", tan(e));
printf("tan(-INFINITY) = %.15f\n", tan(f));
printf("tan(NAN) = %.15f\n", tan(g));
/*
* tan(pi/3) = 1.732050807568877
* tan(-3*pi/4) = 1.000000000000000
* tan(0.0) = 0.000000000000000
* tan(pi/2) = 16331239353195370.000000000000000
* tan(INFINITY) = nan
* tan(-INFINITY) = nan
* tan(NAN) = nan
*
* */
Fortran interface:
REAL(8) :: X = 0.0
PRINT*, TAN(X)
!
! OUTPUT
! 0.000000000000000
!
Parent topic: Function Syntax