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