exp(3)
β¨ exp β bestie we're doing e^x today β¨
okay so this is exp(3), from the Math library section of the manual (that's man section 3, iykyk). it's the base-e exponential function and it's literally the moment e gets raised to a power. iconic behavior honestly π
πΈ NAME πΈ
exp, expf, expl β base-e exponential function
like. the function. the e^x one. the main character of calculus π«Ά
π LIBRARY π
Math library (libm, -lm)
so bestie you gotta link it, okay? -lm. put it at the end of your compile line or gcc will simply not know her π
β¨ SYNOPSIS β¨
#include <math.h>
double exp(double x);
float expf(float x);
long double expl(long double x);
two things: one, #include <math.h> β mandatory, no exceptions, she lives there. two, pick your flavor: double gets you exp, float gets you expf, long double gets you expl. choose your fighter π
π¦ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): π¦
expf(), expl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
yep, this is the classic "glibc gatekeeps the declaration unless you define the right macro" situation. exp (the double one) doesn't need this, but her sisters expf() and expl() do. define one of those and you're in. don't, and the compiler will be like "who?" π
π DESCRIPTION π
These functions return the value of e (the base of natural logarithms) raised to the power of x.
that's it. that's the whole vibe. e^x. the growth curve. the compounding interest. the radioactive decay. the way she just... exponentially increases. no cap.
π₯ RETURN VALUE π₯
On success, these functions return the exponential value of x. slay π
- If x is a NaN, a NaN is returned. (NaN in, NaN out, the energy is conserved fr fr)
- If x is positive infinity, positive infinity is returned.
- If x is negative infinity,
+0is returned. - If the result underflows, a range error occurs, and zero is returned.
- If the result overflows, a range error occurs, and the functions return
+HUGE_VAL,+HUGE_VALF, or+HUGE_VALL, respectively.
so like. she either gives you a number, gives you a bigger number, gives you zero, or gives you +HUGE_VAL-coded drama. there is no in between π
π ERRORS π
See math_error(7) for information on how to determine whether an error has occurred when calling these functions. (bestie, that's the "how do i even know if it went wrong" page. go read it.)
The following errors can occur:
- Range error, overflow β
errnois set toERANGE. An overflow floating-point exception (FE_OVERFLOW) is raised. - Range error, underflow β
errnois set toERANGE. An underflow floating-point exception (FE_UNDERFLOW) is raised.
β οΈ heads up: both of these seterrnotoERANGE, one of them because the number got too big and the other because it got too smol. yes they share a code. yes that's annoying. that's just how it is π
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
exp(),expf(),expl() - Attribute: Thread safety
- Value: MT-Safe
translation: she's MT-Safe, so go ahead and call her from multiple threads, she can handle it, she's built different π«Ά
π STANDARDS π
C11, POSIX.1-2008.
certified. legit. standards-approved. periodt π
π HISTORY π
C99, POSIX.1-2001.
The variant returning double also conforms to SVr4, 4.3BSD, C89.
so the double girlie has been around since forever, retro icon, OG main character energy β
π¦ SEE ALSO π¦
cbrt(3), cexp(3), exp10(3), exp2(3), expm1(3), sqrt(3)
the whole exponent/root friend group honestly. go say hi πΈ
okay bestie that's the whole page π go forth and compute e^x responsibly.
this has been the Linux man-pages, version 6.20, dated 2026-02-08 β entry exp(3). mwah. no notes. β¨
π¦ 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
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms