xref: /freebsd/lib/msun/man/exp.3 (revision 02e9120893770924227138ba49df1edb3896112a)
1.\" Copyright (c) 1985, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
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.
15.\"
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
26.\" SUCH DAMAGE.
27.\"
28.Dd April 1, 2020
29.Dt EXP 3
30.Os
31.Sh NAME
32.Nm exp ,
33.Nm expf ,
34.Nm expl ,
35.\" The sorting error is intentional.  exp, expf, and expl should be adjacent.
36.Nm exp2 ,
37.Nm exp2f ,
38.Nm exp2l ,
39.Nm expm1 ,
40.Nm expm1f ,
41.Nm expm1l ,
42.Nm pow ,
43.Nm powf ,
44.Nm powl
45.Nd exponential and power functions
46.Sh LIBRARY
47.Lb libm
48.Sh SYNOPSIS
49.In math.h
50.Ft double
51.Fn exp "double x"
52.Ft float
53.Fn expf "float x"
54.Ft long double
55.Fn expl "long double x"
56.Ft double
57.Fn exp2 "double x"
58.Ft float
59.Fn exp2f "float x"
60.Ft long double
61.Fn exp2l "long double x"
62.Ft double
63.Fn expm1 "double x"
64.Ft float
65.Fn expm1f "float x"
66.Ft long double
67.Fn expm1l "long double x"
68.Ft double
69.Fn pow "double x" "double y"
70.Ft float
71.Fn powf "float x" "float y"
72.Ft long double
73.Fn powl "long double x" "long double y"
74.Sh DESCRIPTION
75The
76.Fn exp ,
77.Fn expf ,
78and
79.Fn expl
80functions compute the base
81.Ms e
82exponential value of the given argument
83.Fa x .
84.Pp
85The
86.Fn exp2 ,
87.Fn exp2f ,
88and
89.Fn exp2l
90functions compute the base 2 exponential of the given argument
91.Fa x .
92.Pp
93The
94.Fn expm1 ,
95.Fn expm1f ,
96and the
97.Fn expm1l
98functions compute the value exp(x)\-1 accurately even for tiny argument
99.Fa x .
100.Pp
101The
102.Fn pow ,
103.Fn powf ,
104and the
105.Fn powl
106functions compute the value
107of
108.Fa x
109to the exponent
110.Fa y .
111.Sh ERROR (due to Roundoff etc.)
112The values of
113.Fn exp 0 ,
114.Fn expm1 0 ,
115.Fn exp2 integer ,
116and
117.Fn pow integer integer
118are exact provided that they are representable.
119.\" XXX Is this really true for pow()?
120Otherwise the error in these functions is generally below one
121.Em ulp .
122.Sh RETURN VALUES
123These functions will return the appropriate computation unless an error
124occurs or an argument is out of range.
125The functions
126.Fn pow x y ,
127.Fn powf x y ,
128and
129.Fn powl x y
130raise an invalid exception and return an \*(Na if
131.Fa x
132< 0 and
133.Fa y
134is not an integer.
135.Sh NOTES
136The function
137.Fn pow x 0
138returns x**0 = 1 for all x including x = 0, \*(If, and \*(Na .
139Previous implementations of pow may
140have defined x**0 to be undefined in some or all of these
141cases.
142Here are reasons for returning x**0 = 1 always:
143.Bl -enum -width indent
144.It
145Any program that already tests whether x is zero (or
146infinite or \*(Na) before computing x**0 cannot care
147whether 0**0 = 1 or not.
148Any program that depends
149upon 0**0 to be invalid is dubious anyway since that
150expression's meaning and, if invalid, its consequences
151vary from one computer system to another.
152.It
153Some Algebra texts (e.g.\& Sigler's) define x**0 = 1 for
154all x, including x = 0.
155This is compatible with the convention that accepts a[0]
156as the value of polynomial
157.Bd -literal -offset indent
158p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n
159.Ed
160.Pp
161at x = 0 rather than reject a[0]\(**0**0 as invalid.
162.It
163Analysts will accept 0**0 = 1 despite that x**y can
164approach anything or nothing as x and y approach 0
165independently.
166The reason for setting 0**0 = 1 anyway is this:
167.Bd -ragged -offset indent
168If x(z) and y(z) are
169.Em any
170functions analytic (expandable
171in power series) in z around z = 0, and if there
172x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0.
173.Ed
174.It
175If 0**0 = 1, then
176\*(If**0 = 1/0**0 = 1 too; and
177then \*(Na**0 = 1 too because x**0 = 1 for all finite
178and infinite x, i.e., independently of x.
179.El
180.Sh SEE ALSO
181.Xr clog 3 ,
182.Xr cpow 3 ,
183.Xr fenv 3 ,
184.Xr ldexp 3 ,
185.Xr log 3 ,
186.Xr math 3
187.Sh STANDARDS
188These functions conform to
189.St -isoC-99 .
190.Sh HISTORY
191The
192.Fn exp
193function appeared in
194.At v1 .
195