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