tan Functions

Description

Calculate the tangent (tan and _tanl) and hyperbolic tangent (tanh and _tanhl).

#include <math.h>

double tan( double x );

double tanh( double x );

long double _tanl( long double x );

long double _tanhl( long double x );

x Angle in radians  

Remarks

The tan functions return the tangent or hyperbolic tangent of their arguments. The list below describes the differences between the various tangent functions:

Function Description

tan Calculates tangent of x
tanh Calculates hyperbolic tangent of x
_tanl Calculates tangent of x (80-bit version)
_tanhl Calculates hyperbolic tangent of x (80-bit version)

The _tanl and _tanhl functions are the 80-bit counterparts and use an 80-bit, 10-byte coprocessor form of arguments and return values. See the reference page on the long double functions for more details on this data type.

Return Value

The tan function returns the tangent of x. If x is large, a partial loss of significance in the result may occur; in this case, tan sets errno to ERANGE and generates a _PLOSS error. If x is so large that significance is totally lost, tan prints a _TLOSS error message to stderr, sets errno to ERANGE, and returns 0. Error handling can be modified by using the _matherr function.

There is no error return for tanh.

Compatibility

tan, tanh

Standards:ANSI, UNIX

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

_tanl, _tanhl

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

acos functions, asin functions, atan functions, cos functions, sin functions

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", x, y );

printf( "tanh( %f ) = %f\n", y, x );

}

Output

tan( 1.000000 ) = 0.761594

tanh( 0.761594 ) = 1.000000