| 1 |
'\" t |
| 2 |
.\" Copyright 1995, James R. Van Zandt <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH log1p 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
log1p, log1pf, log1pl \- logarithm of 1 plus argument |
| 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 log1p(double " x ); |
| 18 |
.BI "float log1pf(float " x ); |
| 19 |
.BI "long double log1pl(long double " x ); |
| 20 |
.P |
| 21 |
.fi |
| 22 |
.RS -4 |
| 23 |
Feature Test Macro Requirements for glibc (see |
| 24 |
.BR feature_test_macros (7)): |
| 25 |
.RE |
| 26 |
.P |
| 27 |
.nf |
| 28 |
.BR log1p (): |
| 29 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 30 |
|| _XOPEN_SOURCE >= 500 |
| 31 |
.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED |
| 32 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 33 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 34 |
.fi |
| 35 |
.P |
| 36 |
.BR log1pf (), |
| 37 |
.BR log1pl (): |
| 38 |
.nf |
| 39 |
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
| 40 |
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE |
| 41 |
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE |
| 42 |
.fi |
| 43 |
.SH DESCRIPTION |
| 44 |
These functions return a value equivalent to |
| 45 |
.P |
| 46 |
.in +4n |
| 47 |
.EX |
| 48 |
log(1 + \f[I]x\f[]) |
| 49 |
.EE |
| 50 |
.in |
| 51 |
.P |
| 52 |
The result is computed in a way |
| 53 |
that is accurate even if the value of |
| 54 |
.I x |
| 55 |
is near zero. |
| 56 |
.SH RETURN VALUE |
| 57 |
On success, these functions return the natural logarithm of |
| 58 |
.IR "(1\ +\ x)" . |
| 59 |
.P |
| 60 |
If |
| 61 |
.I x |
| 62 |
is a NaN, |
| 63 |
a NaN is returned. |
| 64 |
.P |
| 65 |
If |
| 66 |
.I x |
| 67 |
is positive infinity, positive infinity is returned. |
| 68 |
.P |
| 69 |
If |
| 70 |
.I x |
| 71 |
is \-1, a pole error occurs, |
| 72 |
and the functions return |
| 73 |
.RB \- HUGE_VAL , |
| 74 |
.RB \- HUGE_VALF , |
| 75 |
or |
| 76 |
.RB \- HUGE_VALL , |
| 77 |
respectively. |
| 78 |
.P |
| 79 |
If |
| 80 |
.I x |
| 81 |
is less than \-1 (including negative infinity), |
| 82 |
a domain error occurs, |
| 83 |
and a NaN (not a number) is returned. |
| 84 |
.\" POSIX.1 specifies a possible range error if x is subnormal |
| 85 |
.\" glibc 2.8 doesn't do this |
| 86 |
.SH ERRORS |
| 87 |
See |
| 88 |
.BR math_error (7) |
| 89 |
for information on how to determine whether an error has occurred |
| 90 |
when calling these functions. |
| 91 |
.P |
| 92 |
The following errors can occur: |
| 93 |
.TP |
| 94 |
Domain error: \f[I]x\f[] is less than \-1. |
| 95 |
.I errno |
| 96 |
is set to |
| 97 |
.B EDOM |
| 98 |
(but see BUGS). |
| 99 |
An invalid floating-point exception |
| 100 |
.RB ( FE_INVALID ) |
| 101 |
is raised. |
| 102 |
.TP |
| 103 |
Pole error: \f[I]x\f[] is \-1. |
| 104 |
.I errno |
| 105 |
is set to |
| 106 |
.B ERANGE |
| 107 |
(but see BUGS). |
| 108 |
A divide-by-zero floating-point exception |
| 109 |
.RB ( FE_DIVBYZERO ) |
| 110 |
is raised. |
| 111 |
.SH ATTRIBUTES |
| 112 |
For an explanation of the terms used in this section, see |
| 113 |
.BR attributes (7). |
| 114 |
.TS |
| 115 |
allbox; |
| 116 |
lbx lb lb |
| 117 |
l l l. |
| 118 |
Interface Attribute Value |
| 119 |
T{ |
| 120 |
.na |
| 121 |
.nh |
| 122 |
.BR log1p (), |
| 123 |
.BR log1pf (), |
| 124 |
.BR log1pl () |
| 125 |
T} Thread safety MT-Safe |
| 126 |
.TE |
| 127 |
.SH STANDARDS |
| 128 |
C11, POSIX.1-2008. |
| 129 |
.SH HISTORY |
| 130 |
C99, POSIX.1-2001. |
| 131 |
.\" BSD |
| 132 |
.SH BUGS |
| 133 |
Before glibc 2.22, the glibc implementation did not set |
| 134 |
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6792 |
| 135 |
.I errno |
| 136 |
to |
| 137 |
.B EDOM |
| 138 |
when a domain error occurred. |
| 139 |
.P |
| 140 |
Before glibc 2.22, the glibc implementation did not set |
| 141 |
.\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6792 |
| 142 |
.I errno |
| 143 |
to |
| 144 |
.B ERANGE |
| 145 |
when a range error occurred. |
| 146 |
.SH SEE ALSO |
| 147 |
.BR exp (3), |
| 148 |
.BR expm1 (3), |
| 149 |
.BR log (3) |