Share via


tan, tanh

Calculate the tangent (tan) or hyperbolic tangent (tanh).

doubletan(doublex**);**

doubletanh(doublex**);**

Routine Required Header Compatibility
tan <math.h> ANSI, Win 95, Win NT
tanh <math.h> ANSI, Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

tan returns the tangent of x. If x is greater than or equal to 263, or less than or equal to –263, a loss of significance in the result occurs, in which case the function generates a _TLOSS error and returns an indefinite (same as a quiet NaN). You can modify error handling with _matherr.

tanh returns the hyperbolic tangent of x. There is no error return.

Parameter

x

Angle in radians

Example

/* TAN.C:  This program displays the tangent of pi / 4
 * and the hyperbolic tangent of the result.
 */

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

void main( void )
{
   double pi = 3.1415926535;
   double x, y;

   x = tan( pi / 4 );
   y = tanh( x );
   printf( "tan( %f ) = %f\n", pi/4, x );
   printf( "tanh( %f ) = %f\n", x, y );
}

Output

tan( 0.785398 ) = 1.000000
tanh( 1.000000 ) = 0.761594

Floating-Point Support RoutinesLong Double Routines

See Also   acos, asin, atan, cos, sin