tan()

Return the tangent of the argument.

Syntax

tan(radians)

Parameter

Parameter

Definition

radians

arc length in radians whose tangent is to be determined

*Valid Values* 
–∞ ≤ radians ≤ ∞

Description

The tan() function returns the tangent of radians. The output range for the tan() function is – <∞ tan() <∞. The tan() function is undefined when radians = p(2n+1)/2 where n is an integer.

Example

The following example compares the output of the tan() function with the output of its trigonometric definition sin(x)/cos(x):

PI = 3.141593;
printf(" degrees tan(x) sin(x)/cos(x)\n");
printf(" ------- -------- -------------\n");
i = -10;
while ((i += 10) <= 360) {
radians = i * 2 * PI / 360;
if (fabs(cosine = cos(radians)) <= 0.000001) {
printf(" %3d*** tan(x) is undefined for this value\n",i);
next;
}
printf(" %3d %+8.5f %+8.5f\n",i,tan(radians),sin(radians) / cosine);
}

The example produces the following output:

degrees tan(x) sin(x)/cos(x)
------- -------- -------------
0 +0.00000 +0.00000
10 +0.17633 +0.17633
20 +0.36397 +0.36397
30 +0.57735 +0.57735
40 +0.83910 +0.83910
50 +1.19175 +1.19176
60 +1.73205 +1.73205
70 +2.74748 +2.74748
80 +5.67130 +5.67129
90*** tan(x) is undefined for this value
100 -5.67129 -5.67129
110 -2.74748 -2.74748
120 -1.73205 -1.73205
130 -1.19175 -1.19175
140 -0.83910 -0.83910
150 -0.57735 -0.57735
160 -0.36397 -0.36397
170 -0.17633 -0.17633
180 +0.00000 +0.00000
190 +0.17633 +0.17633
200 +0.36397 +0.36397
210 +0.57735 +0.57735
220 +0.83910 +0.83910
230 +1.19175 +1.19176
240 +1.73205 +1.73206
250 +2.74749 +2.74749
260 +5.67131 +5.67132
270*** tan(x) is undefined for this value
280 -5.67128 -5.67129
290 -2.74748 -2.74748
300 -1.73205 -1.73205
310 -1.19175 -1.19175
320 -0.83910 -0.83910
330 -0.57735 -0.57735
340 -0.36397 -0.36397
350 -0.17633 -0.17633
360 +0.00000 +0.00000

Was this page helpful? Yes No Submitting... Thank you

Comments