.\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. The Berkeley software License Agreement .\" specifies the terms and conditions for redistribution. .\" .\" @(#)exp.3m 6.9 (Berkeley) 5/27/86 .\" .TH EXP 3 "May 27, 1986" .UC 4 .ds up \fIulp\fR .SH NAME exp, expm1, log, log10, log1p, pow \- exponential, logarithm, power .SH SYNOPSIS .nf .ft B #include double exp(double \fIx\fP) double expm1(double \fIx\fP) double log(double \fIx\fP) double log10(double \fIx\fP) double log1p(double \fIx\fP) double pow(double \fIx\fP, double \fIy\fP) .ft R .fi .SH DESCRIPTION .PP Exp returns the exponential function of x. .PP Expm1 returns exp(x)\-1 accurately even for tiny x. .PP Log returns the natural logarithm of x. .PP Log10 returns the logarithm of x to base 10. .PP Log1p returns log(1+x) accurately even for tiny x. .PP Pow(x,y) returns .if n x**y. .if t x\u\s8y\s10\d. .SH "ERROR (due to Roundoff etc.)" exp(x), log(x), expm1(x), log(x) and log1p(x) are accurate to within an \*(up, and log10(x) to within about 2 \*(ups; an \*(up is one \fIU\fRnit in the \fIL\fRast \fIP\fRlace. Pow(x,y) returns .if n x**y .if t x\u\s8y\s10\d nearly rounded. In particular pow(integer,integer) always returns the correct integer provided it is representable. .SH DIAGNOSTICS exp(Inf) = Inf, exp(NaN) = NaN. .br For a finite argument, only exp(0) = 1 is exact. .br Overflow of exp(x) if x > 7.09782712893383973096e+02. .br Underflow of exp(x) if x < \-7.45133219101941108420e+02. .PP expm1(Inf) = Inf, expm1(NaN) = NaN, expm1(\-Inf) = \-1. .br For a finite argument, only expm1(0) = 0 is exact. .br Overflow of expm1(x) if x > 7.09782712893383973096e+02. .PP log(x) = NaN with signal if x < 0 (including \-Inf). .br log(NaN) = that NaN with no signal. .br log(+Inf) = +Inf. .br log(0) = \-Inf with signal. .PP log10(x) = NaN with signal if x < 0. .br log10(NaN) = that NaN with no signal. .br log10(+Inf) = +Inf. .br log10(0) = \-Inf with signal. .br .if n log10(10**n) .if t log10(10\u\s8n\s10\d) = n for n = 0, 1, ..., 22. .PP log1p(x) = NaN with signal if x < \-1 (including \-Inf). .br log1p(NaN) = that NaN with no signal. .br log1p(+Inf) = +Inf. .br log1p(\-1) = \-Inf with signal. .PP pow([anything], 0) = 1 .br pow([anything], 1) = [that anything] .br pow([anything], NaN) = NaN .br pow(NaN, [anything except 0]) = NaN .br pow(\(+-[|x| > 1], +Inf) = +Inf .br pow(\(+-[|x| > 1], \-Inf) = +0 .br pow(\(+-[|x| < 1], +Inf) = +0 .br pow(\(+-[|x| < 1], \-Inf) = +Inf .br pow(\(+-1 , \(+-Inf) = NaN .br pow(+0, [+anything except 0, NaN]) = +0 .br pow(\-0, [+anything except 0, NaN, odd integer]) = +0 .br pow(+0, [\-anything except 0, NaN]) = +Inf .br pow(\-0, [\-anything except 0, NaN, odd integer]) = +Inf .br pow(\-0, [odd integer]) = \-( +0 ** [odd integer] ) .br pow(+Inf, [+anything except 0, NaN]) = +Inf .br pow(+Inf, [\-anything except 0, NaN]) = +0 .br pow(\-Inf, [anything]) = \-0 ** [\-anything]) .br pow([\-anything], [integer]) = (\-1)**integer*(+anything**integer) .br pow([\-anything except 0 and Inf], [non-integer]) = NaN .SH NOTES To guarantee .if n log10(10**n) .if t log10(10\u\s8n\s10\d) = n, where .if n 10**n .if t 10\u\s8n\s10\d is normal, the rounding mode must set to Round-to-Nearest. Log10 is monotonic on all binary break points. .SH SEE ALSO .BR math (3). .SH AUTHOR Kwok\-Choi Ng, W. Kahan