TANH(3POSIX)
π¦ TANH β hyperbolic tangent functions π
ok so bestie, gather round, because we're about to talk about tanh, tanhf, and tanhl β the hyperbolic tangent girlies of the POSIX Programmer's Manual. this is a POSIX Programmer's Manual page, iykyk.
πΈ PROLOG πΈ
real talk before we start: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β so like, consult the corresponding Linux manual page for details of Linux behavior β or honestly the interface may not even be implemented on Linux at all. π so don't come for me if it's giving "not found."
β¨ NAME β¨
tanh, tanhf, tanhl β hyperbolic tangent functions. that's the whole vibe. π
π SYNOPSIS π
#include <math.h>
double tanh(double x);
float tanhf(float x);
long double tanhl(long double x);
look at her. three sisters. one job. iconic behavior. π
π«Ά DESCRIPTION π«Ά
okay so the functionality described on this reference page is aligned with the ISO C standard. any conflict between the requirements described here and the ISO C standard is unintentional β no drama intended, fr fr. this volume of POSIX.1β2017 defers to the ISO C standard. she's humble like that.
these functions shall compute the hyperbolic tangent of their argument x. that's it. that's the whole assignment. β¨
now here's the practical bit, and it's lowkey important so pay attention bestie: an application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. then, on return, if errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. π that's the vibe check. do it every time or don't complain.
π RETURN VALUE π
upon successful completion, these functions shall return the hyperbolic tangent of x. periodt.
and now the special cases, because she has RULES:
- if
xis NaN, a NaN shall be returned. (garbage in, garbage out, but make it IEEE. π) - if
xis Β±0,xshall be returned. (she returns exactly what you gave her. no notes.) - if
xis Β±Inf, Β±1 shall be returned. (infinity gets humbled to 1. main character energy.) - if
xis subnormal, a range error may occur andxshould be returned. β οΈ - if
xis not returned,tanh(),tanhf(), andtanhl()shall return an implementation-defined value no greater in magnitude thanDBL_MIN,FLT_MIN, andLDBL_MIN, respectively.
π ERRORS π
these functions may fail if:
- Range Error β the value of
xis subnormal.
if the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE]. if the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow floating-point exception shall be raised.
the following sections are informative. (translation: the tea is optional but delicious. π)
π EXAMPLES π
None. bestie there are literally no examples. we're on our own out here. π§
π APPLICATION USAGE π
on error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. so like, they don't talk to each other, they're just both invited to the party. π
π₯ RATIONALE π₯
None. no rationale. she simply is. π
β FUTURE DIRECTIONS β
None. the future is unwritten, and honestly? she's not changing. π
πΈ SEE ALSO πΈ
atanh()feclearexcept()fetestexcept()isnan()tan()
the Base Definitions volume of POSIX.1β2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, and <math.h> β go read those, they're the lore. π
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page bestie!! brought to you by IEEE/The Open Group, dated 2017, living under the name TANH(3POSIX) β stay hyperbolic, stay tangent, and always clear your errno before you call her. πβ¨π¦
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms