tan() — Calculate Tangent
Format
#include <math.h>
double tan(double x);
Language Level
ANSI
Threadsafe
Yes
Description
The tan()
function
calculates the tangent of x, where x is
expressed in radians. If x is too large,
a partial loss of significance in the result can occur and sets errno
to ERANGE. The value of errno may also be set to EDOM.
Return Value
The tan()
function
returns the value of the tangent of x.
Example
This example computes x as
the tangent of π⁄4.
#include <math.h>
#include <stdio.h>
int main(void)
{
double pi, x;
pi = 3.1415926;
x = tan(pi/4.0);
printf("tan( %lf ) is %lf\n", pi/4, x);
}
/****************** Output should be similar to: ****************
tan( 0.785398 ) is 1.000000
*/