1 .\" Copyright (c) 1985, 1991 Regents of the University of California.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91
29 .\" $NetBSD: exp.3,v 1.21 2003/08/07 16:44:47 agc Exp $
30 .\" $DragonFly: src/lib/libm/man/exp.3,v 1.1 2005/07/26 21:15:20 joerg Exp $
48 .Nd exponential, logarithm, power functions
74 .Fn pow "double x" "double y"
76 .Fn powf "float x" "float y"
80 function computes the exponential value of the given argument
85 function computes the value exp(x)\-1 accurately even for tiny argument
90 function computes the value of the natural logarithm of argument
95 function computes the value of the logarithm of argument
102 the value of log(1+x) accurately even for tiny argument
113 These functions will return the appropriate computation unless an error
114 occurs or an argument is out of range.
120 detect if the computed value will overflow,
121 set the global variable
125 and cause a reserved operand fault on a
133 is not an integer, in the event this is true,
140 generate a reserved operand fault.
146 and the reserved operand is returned
155 exp(x), log(x), expm1(x) and log1p(x) are accurate to within
158 and log10(x) to within about 2
172 magnitude is moderate, but increases as
175 the over/underflow thresholds until almost as many bits could be
176 lost as are occupied by the floating\-point format's exponent
177 field; that is 8 bits for
179 and 11 bits for IEEE 754 Double.
180 No such drastic loss has been exposed by testing; the worst
181 errors observed have been below 20
192 are accurate enough that
193 .Fn pow integer integer
194 is exact until it is bigger than 2**56 on a
200 The functions exp(x)\-1 and log(1+x) are called
203 on the Hewlett\-Packard
211 in Pascal, exp1 and log1 in C
214 Macintoshes, where they have been provided to make
215 sure financial calculations of ((1+x)**n\-1)/x, namely
216 expm1(n\(**log1p(x))/x, will be accurate when x is tiny.
217 They also provide accurate inverse hyperbolic functions.
221 returns x**0 = 1 for all x including x = 0,
233 Previous implementations of pow may
234 have defined x**0 to be undefined in some or all of these
236 Here are reasons for returning x**0 = 1 always:
237 .Bl -enum -width indent
239 Any program that already tests whether x is zero (or
240 infinite or \*(Na) before computing x**0 cannot care
241 whether 0**0 = 1 or not.
242 Any program that depends
243 upon 0**0 to be invalid is dubious anyway since that
244 expression's meaning and, if invalid, its consequences
245 vary from one computer system to another.
247 Some Algebra texts (e.g. Sigler's) define x**0 = 1 for
248 all x, including x = 0.
249 This is compatible with the convention that accepts a[0]
250 as the value of polynomial
251 .Bd -literal -offset indent
252 p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n
255 at x = 0 rather than reject a[0]\(**0**0 as invalid.
257 Analysts will accept 0**0 = 1 despite that x**y can
258 approach anything or nothing as x and y approach 0
260 The reason for setting 0**0 = 1 anyway is this:
261 .Bd -filled -offset indent
264 functions analytic (expandable
265 in power series) in z around z = 0, and if there
266 x(0) = y(0) = 0, then x(z)**y(z) \(-\*[Gt] 1 as z \(-\*[Gt] 0.
271 infinity**0 = 1/0**0 = 1 too; and
273 \(if**0 = 1/0**0 = 1 too; and
274 then \*(Na**0 = 1 too because x**0 = 1 for all finite
275 and infinite x, i.e., independently of x.
306 functions appeared in