The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 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. All advertising materials mentioning features or use of this software |
| 13 | .\" must display the following acknowledgement: |
| 14 | .\" This product includes software developed by the University of |
| 15 | .\" California, Berkeley and its contributors. |
| 16 | .\" 4. Neither the name of the University nor the names of its contributors |
| 17 | .\" may be used to endorse or promote products derived from this software |
| 18 | .\" without specific prior written permission. |
| 19 | .\" |
| 20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 | .\" SUCH DAMAGE. |
| 31 | .\" |
| 32 | .\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91 |
| 33 | .\" $FreeBSD: src/lib/msun/man/exp.3,v 1.22 2005/04/05 02:57:28 das Exp $ |
| 34 | .\" |
| 35 | .Dd April 5, 2005 |
| 36 | .Dt EXP 3 |
| 37 | .Os |
| 38 | .Sh NAME |
| 39 | .Nm exp , |
| 40 | .Nm expf , |
| 41 | .\" The sorting error is intentional. exp and expf should be adjacent. |
| 42 | .Nm exp2 , |
| 43 | .Nm exp2f , |
| 44 | .Nm expm1 , |
| 45 | .Nm expm1f , |
| 46 | .Nm log , |
| 47 | .Nm logf , |
| 48 | .Nm log10 , |
| 49 | .Nm log10f , |
| 50 | .Nm log1p , |
| 51 | .Nm log1pf , |
| 52 | .Nm pow , |
| 53 | .Nm powf |
| 54 | .Nd exponential, logarithm, power functions |
| 55 | .Sh LIBRARY |
| 56 | .Lb libm |
| 57 | .Sh SYNOPSIS |
| 58 | .In math.h |
| 59 | .Ft double |
| 60 | .Fn exp "double x" |
| 61 | .Ft float |
| 62 | .Fn expf "float x" |
| 63 | .Ft double |
| 64 | .Fn exp2 "double x" |
| 65 | .Ft float |
| 66 | .Fn exp2f "float x" |
| 67 | .Ft double |
| 68 | .Fn expm1 "double x" |
| 69 | .Ft float |
| 70 | .Fn expm1f "float x" |
| 71 | .Ft double |
| 72 | .Fn log "double x" |
| 73 | .Ft float |
| 74 | .Fn logf "float x" |
| 75 | .Ft double |
| 76 | .Fn log10 "double x" |
| 77 | .Ft float |
| 78 | .Fn log10f "float x" |
| 79 | .Ft double |
| 80 | .Fn log1p "double x" |
| 81 | .Ft float |
| 82 | .Fn log1pf "float x" |
| 83 | .Ft double |
| 84 | .Fn pow "double x" "double y" |
| 85 | .Ft float |
| 86 | .Fn powf "float x" "float y" |
| 87 | .Sh DESCRIPTION |
| 88 | The |
| 89 | .Fn exp |
| 90 | and the |
| 91 | .Fn expf |
| 92 | functions compute the base |
| 93 | .Ms e |
| 94 | exponential value of the given argument |
| 95 | .Fa x . |
| 96 | .Pp |
| 97 | The |
| 98 | .Fn exp2 |
| 99 | and the |
| 100 | .Fn exp2f |
| 101 | functions compute the base 2 exponential of the given argument |
| 102 | .Fa x . |
| 103 | .Pp |
| 104 | The |
| 105 | .Fn expm1 |
| 106 | and the |
| 107 | .Fn expm1f |
| 108 | functions compute the value exp(x)\-1 accurately even for tiny argument |
| 109 | .Fa x . |
| 110 | .Pp |
| 111 | The |
| 112 | .Fn log |
| 113 | and the |
| 114 | .Fn logf |
| 115 | functions compute the value of the natural logarithm of argument |
| 116 | .Fa x . |
| 117 | .Pp |
| 118 | The |
| 119 | .Fn log10 |
| 120 | and the |
| 121 | .Fn log10f |
| 122 | functions compute the value of the logarithm of argument |
| 123 | .Fa x |
| 124 | to base 10. |
| 125 | .Pp |
| 126 | The |
| 127 | .Fn log1p |
| 128 | and the |
| 129 | .Fn log1pf |
| 130 | functions compute |
| 131 | the value of log(1+x) accurately even for tiny argument |
| 132 | .Fa x . |
| 133 | .Pp |
| 134 | The |
| 135 | .Fn pow |
| 136 | and the |
| 137 | .Fn powf |
| 138 | functions compute the value |
| 139 | of |
| 140 | .Ar x |
| 141 | to the exponent |
| 142 | .Ar y . |
| 143 | .Sh ERROR (due to Roundoff etc.) |
| 144 | The values of |
| 145 | .Fn exp 0 , |
| 146 | .Fn expm1 0 , |
| 147 | .Fn exp2 integer , |
| 148 | and |
| 149 | .Fn pow integer integer |
| 150 | are exact provided that they are representable. |
| 151 | .\" XXX Is this really true for pow()? |
| 152 | Otherwise the error in these functions is generally below one |
| 153 | .Em ulp . |
| 154 | .Sh RETURN VALUES |
| 155 | These functions will return the appropriate computation unless an error |
| 156 | occurs or an argument is out of range. |
| 157 | The functions |
| 158 | .Fn pow x y |
| 159 | and |
| 160 | .Fn powf x y |
| 161 | raise an invalid exception and return an \*(Na if |
| 162 | .Fa x |
| 163 | < 0 and |
| 164 | .Fa y |
| 165 | is not an integer. |
| 166 | An attempt to take the logarithm of \*(Pm0 will result in |
| 167 | a divide-by-zero exception, and an infinity will be returned. |
| 168 | An attempt to take the logarithm of a negative number will |
| 169 | result in an invalid exception, and an \*(Na will be generated. |
| 170 | .Sh NOTES |
| 171 | The functions exp(x)\-1 and log(1+x) are called |
| 172 | expm1 and logp1 in |
| 173 | .Tn BASIC |
| 174 | on the Hewlett\-Packard |
| 175 | .Tn HP Ns \-71B |
| 176 | and |
| 177 | .Tn APPLE |
| 178 | Macintosh, |
| 179 | .Tn EXP1 |
| 180 | and |
| 181 | .Tn LN1 |
| 182 | in Pascal, exp1 and log1 in C |
| 183 | on |
| 184 | .Tn APPLE |
| 185 | Macintoshes, where they have been provided to make |
| 186 | sure financial calculations of ((1+x)**n\-1)/x, namely |
| 187 | expm1(n\(**log1p(x))/x, will be accurate when x is tiny. |
| 188 | They also provide accurate inverse hyperbolic functions. |
| 189 | .Pp |
| 190 | The function |
| 191 | .Fn pow x 0 |
| 192 | returns x**0 = 1 for all x including x = 0, \*(If, and \*(Na . |
| 193 | Previous implementations of pow may |
| 194 | have defined x**0 to be undefined in some or all of these |
| 195 | cases. |
| 196 | Here are reasons for returning x**0 = 1 always: |
| 197 | .Bl -enum -width indent |
| 198 | .It |
| 199 | Any program that already tests whether x is zero (or |
| 200 | infinite or \*(Na) before computing x**0 cannot care |
| 201 | whether 0**0 = 1 or not. |
| 202 | Any program that depends |
| 203 | upon 0**0 to be invalid is dubious anyway since that |
| 204 | expression's meaning and, if invalid, its consequences |
| 205 | vary from one computer system to another. |
| 206 | .It |
| 207 | Some Algebra texts (e.g.\& Sigler's) define x**0 = 1 for |
| 208 | all x, including x = 0. |
| 209 | This is compatible with the convention that accepts a[0] |
| 210 | as the value of polynomial |
| 211 | .Bd -literal -offset indent |
| 212 | p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n |
| 213 | .Ed |
| 214 | .Pp |
| 215 | at x = 0 rather than reject a[0]\(**0**0 as invalid. |
| 216 | .It |
| 217 | Analysts will accept 0**0 = 1 despite that x**y can |
| 218 | approach anything or nothing as x and y approach 0 |
| 219 | independently. |
| 220 | The reason for setting 0**0 = 1 anyway is this: |
| 221 | .Bd -ragged -offset indent |
| 222 | If x(z) and y(z) are |
| 223 | .Em any |
| 224 | functions analytic (expandable |
| 225 | in power series) in z around z = 0, and if there |
| 226 | x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0. |
| 227 | .Ed |
| 228 | .It |
| 229 | If 0**0 = 1, then |
| 230 | \*(If**0 = 1/0**0 = 1 too; and |
| 231 | then \*(Na**0 = 1 too because x**0 = 1 for all finite |
| 232 | and infinite x, i.e., independently of x. |
| 233 | .El |
| 234 | .Sh SEE ALSO |
| 235 | .Xr fenv 3 , |
| 236 | .Xr math 3 |