tan(3)

โœจ tan(3) โ€” the tangent function, but make it make sense โœจ

okay so bestie, welcome to the Library Functions Manual entry for tan(3) ๐Ÿ’– this is a section 3 page (that's the C library girlies) and it's literally just... the tangent function. three flavors of it. let's go ๐Ÿฆ‹


๐ŸŽ€ NAME ๐ŸŽ€

tan, tanf, tanl โ€” tangent function


๐Ÿ“š LIBRARY ๐Ÿ“š

Math library (libm, -lm)

link it with -lm or she will simply Not work. no cap.

๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <math.h>

double tan(double x);
float tanf(float x);
long double tanl(long double x);

๐Ÿงš Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

tanf(), tanl():
    _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
        || /* Since glibc 2.19: */ _DEFAULT_SOURCE
        || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE

๐Ÿ’… DESCRIPTION ๐Ÿ’…

These functions return the tangent of x, where x is given in radians. that's it. that's the whole description. radians, not degrees โ€” I know, I know, tragic, but that's the vibe ๐ŸŒˆ


โญ RETURN VALUE โญ

On success, these functions return the tangent of x. iconic behaviour, honestly ๐Ÿ‘‘

If x is a NaN, a NaN is returned. (NaN in, NaN out, the circle of life ๐Ÿ’€)

If x is positive infinity or negative infinity, a domain error occurs, and a NaN is returned. she said nope ๐Ÿ™ˆ

If the correct result would overflow, a range error occurs, and the functions return HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the mathematically correct sign. so like, huge but make it signed โœจ


๐Ÿ˜ญ ERRORS ๐Ÿ˜ญ

See math_error(7) for information on how to determine whether an error has occurred when calling these functions. (fr fr, go read it, it's the receipts girlie ๐Ÿงพ)

The following errors can occur:

  • Domain error: x is an infinity โ€” errno is set to EDOM (but see BUGS). An invalid floating-point exception (FE_INVALID) is raised. ๐Ÿšจ
  • Range error: result overflow โ€” An overflow floating-point exception (FE_OVERFLOW) is raised.

๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

For an explanation of the terms used in this section, see attributes(7).

  • tan(), tanf(), tanl() โ€” Thread safety: MT-Safe ๐Ÿซถ
MT-Safe means you can call her from multiple threads and she will not start drama. we love a low-maintenance queen.

๐ŸŒˆ STANDARDS ๐ŸŒˆ

C11, POSIX.1-2008.


๐Ÿ•ฐ๏ธ HISTORY ๐Ÿ•ฐ๏ธ

C99, POSIX.1-2001.

The variant returning double also conforms to SVr4, 4.3BSD, C89. yes she's been around, she's a legacy icon ๐Ÿ’œ


๐Ÿ’€ BUGS ๐Ÿ’€

Before glibc 2.10, the glibc implementation did not set errno to EDOM when a domain error occurred. so if you're on some ancient glibc, don't trust the errno, bestie, check the floating-point exception instead ๐Ÿ˜ญ


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

acos(3), asin(3), atan(3), atan2(3), cos(3), ctan(3), sin(3)

the whole trig friend group. go say hi ๐Ÿ“

okay that's the page!! this cutie comes to you from Linux man-pages 6.20, dated 2026-02-08, and she ate, no crumbs ๐Ÿ’…โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms