| 1 |
'\" t |
| 2 |
.\" Copyright 1993, David Metcalfe <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH tan 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
tan, tanf, tanl \- tangent function |
| 10 |
.SH LIBRARY |
| 11 |
Math library |
| 12 |
.RI ( libm ,\~ \-lm ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <math.h> |
| 16 |
.P |
| 17 |
.BI "double tan(double " x ); |
| 18 |
.BI "float tanf(float " x ); |
| 19 |
.BI "long double tanl(long double " x ); |
| 20 |
.fi |
| 21 |
.P |
| 22 |
.RS -4 |
| 23 |
Feature Test Macro Requirements for glibc (see |
| 24 |
.BR feature_test_macros (7)): |
| 25 |
.RE |
| 26 |
.P |
| 27 |
.BR tanf (), |
| 28 |
.BR tanl (): |
| 29 |
.nf |
| 30 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 31 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 32 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 33 |
.fi |
| 34 |
.SH DESCRIPTION |
| 35 |
These functions return the tangent of |
| 36 |
.IR x , |
| 37 |
where |
| 38 |
.I x |
| 39 |
is |
| 40 |
given in radians. |
| 41 |
.SH RETURN VALUE |
| 42 |
On success, these functions return the tangent of |
| 43 |
.IR x . |
| 44 |
.P |
| 45 |
If |
| 46 |
.I x |
| 47 |
is a NaN, a NaN is returned. |
| 48 |
.P |
| 49 |
If |
| 50 |
.I x |
| 51 |
is positive infinity or negative infinity, |
| 52 |
a domain error occurs, |
| 53 |
and a NaN is returned. |
| 54 |
.P |
| 55 |
If the correct result would overflow, |
| 56 |
a range error occurs, |
| 57 |
and the functions return |
| 58 |
.BR HUGE_VAL , |
| 59 |
.BR HUGE_VALF , |
| 60 |
or |
| 61 |
.BR HUGE_VALL , |
| 62 |
respectively, with the mathematically correct sign. |
| 63 |
.\" I think overflow can't occur, because the closest floating-point |
| 64 |
.\" representation of pi/2 is still not close enough to pi/2 to |
| 65 |
.\" produce a large enough value to overflow. |
| 66 |
.\" Testing certainly seems to bear this out. -- mtk, Jul 08 |
| 67 |
.\" |
| 68 |
.\" POSIX.1 allows an optional underflow error; |
| 69 |
.\" glibc 2.8 doesn't do this |
| 70 |
.\" POSIX.1 an optional range error for subnormal x; |
| 71 |
.\" glibc 2.8 doesn't do this |
| 72 |
.SH ERRORS |
| 73 |
See |
| 74 |
.BR math_error (7) |
| 75 |
for information on how to determine whether an error has occurred |
| 76 |
when calling these functions. |
| 77 |
.P |
| 78 |
The following errors can occur: |
| 79 |
.TP |
| 80 |
Domain error: \f[I]x\f[] is an infinity |
| 81 |
.I errno |
| 82 |
is set to |
| 83 |
.B EDOM |
| 84 |
(but see BUGS). |
| 85 |
An invalid floating-point exception |
| 86 |
.RB ( FE_INVALID ) |
| 87 |
is raised. |
| 88 |
.TP |
| 89 |
Range error: result overflow |
| 90 |
.\" Unable to test this case, since the best approximation of |
| 91 |
.\" pi/2 in double precision only yields a tan() value of 1.633e16. |
| 92 |
.\" .I errno |
| 93 |
.\" is set to |
| 94 |
.\" .BR ERANGE . |
| 95 |
An overflow floating-point exception |
| 96 |
.RB ( FE_OVERFLOW ) |
| 97 |
is raised. |
| 98 |
.SH ATTRIBUTES |
| 99 |
For an explanation of the terms used in this section, see |
| 100 |
.BR attributes (7). |
| 101 |
.TS |
| 102 |
allbox; |
| 103 |
lbx lb lb |
| 104 |
l l l. |
| 105 |
Interface Attribute Value |
| 106 |
T{ |
| 107 |
.na |
| 108 |
.nh |
| 109 |
.BR tan (), |
| 110 |
.BR tanf (), |
| 111 |
.BR tanl () |
| 112 |
T} Thread safety MT-Safe |
| 113 |
.TE |
| 114 |
.SH STANDARDS |
| 115 |
C11, POSIX.1-2008. |
| 116 |
.SH HISTORY |
| 117 |
C99, POSIX.1-2001. |
| 118 |
.P |
| 119 |
The variant returning |
| 120 |
.I double |
| 121 |
also conforms to |
| 122 |
SVr4, 4.3BSD, C89. |
| 123 |
.SH BUGS |
| 124 |
Before glibc 2.10, the glibc implementation did not set |
| 125 |
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=6782 |
| 126 |
.I errno |
| 127 |
to |
| 128 |
.B EDOM |
| 129 |
when a domain error occurred. |
| 130 |
.SH SEE ALSO |
| 131 |
.BR acos (3), |
| 132 |
.BR asin (3), |
| 133 |
.BR atan (3), |
| 134 |
.BR atan2 (3), |
| 135 |
.BR cos (3), |
| 136 |
.BR ctan (3), |
| 137 |
.BR sin (3) |