xref: /csrg-svn/lib/libm/common_source/exp.3 (revision 23565)
EXP 3M "8 May 1985"
C 4
NAME
E, L, exp, log, log10, pow - exponential, logarithm, power
SYNOPSIS
 #include <math.h> 

double E(x) double x;

double L(x) double x;

double exp(x) double x;

double log(x) double x;

double log10(x) double x;

double pow(x, y) double x, y;

DESCRIPTION
E returns exp(x)-1 accurately (even if x is close to 0 ).

L returns log(1+x) accurately (even if x is close to 0 ).

Exp returns the exponential function of x.

Log returns the natural logarithm of x ; log10 returns the base 10 logarithm.

Pow returns x**y. x\u\s8y\s10\d.

SEE ALSO
intro(3M)
DIAGNOSTICS
E, L, exp and pow return the reserved operand on the VAX when the correct value would overflow; errno is set to ERANGE. Pow returns the reserved operand on the VAX and sets errno to EDOM when the first argument is negative and the second is non-integral.

Log returns the reserved operand on the VAX when x is zero or negative; errno is set to EDOM.

NOTES
Pow defines x**0 x\u\s80\s10\d = 1 for all x, including zero, infinity \(if (not applicable on the VAX) and NaN (the reserved operand on the VAX). Previous implementations of pow may have defined x**0 x\u\s80\s10\d to be undefined in some or all of those cases. The reasons for setting x**0 x\u\s80\s10\d = 1 in all cases are these:
(1)
Any program that already tests whether x is 0 (or infinity \(if or NaN) before computing x**0 x\u\s80\s10\d will be indifferent to whether 0**0 0\u\s80\s10\d = 1 or not. Any program that expects 0**0 0\u\s80\s10\d to be invalid is dubious anyway since that expectation is bound to be contradicted by some computer systems.
(2)
Some Algebra texts (e.g. Sigler's) define x**0 x\u\s80\s10\d = 1 for all x, including x = 0. This is compatible with the convention for polynomials that accepts

p(x) = a[0]*x**0 + a[1]*x**1 + ... + a[n]*x**n \} a\d\s80\s10\u\(**x\u\s80\s10\d + a\d\s81\s10\u\(**x\u\s81\s10\d + ... + a\d\s8n\s10\u\(**x\u\s8n\s10\d \} and evaluates p(0) = a[0] a\d\s80\s10\u rather than reject a[0]*0**0 a\d\s80\s10\u\(**0\u\s80\s10\d as invalid.

(3)
Analysts will accept 0**0 0\u\s80\s10\d = 1 despite that x**y x\u\s8y\s10\d can approach anything or nothing as x and y approach zero independently. The reason for setting 0**0 0\u\s80\s10\d = 1 anyway is this:

If x(z) and y(z) are any functions analytic (expressible as power series) in z at z = 0, and if x(0) = y(0) = 0, then x(z)**y(z) x(z)\u\s8y(z)\s10\d \(-> 1 as z \(-> 0.

(4)
If 0**0 0\u\s80\s10\d = 1, then infinity**0 \(if\u\s80\s10\d = 1/0\u\s80\s10\d 1/0**0 = 1 too; and then NaN**0 NaN\u\s80\s10\d = 1 because x**0 x\u\s80\s10\d = 1 for all finite and infinite x.
AUTHOR
Kwok-Choi Ng, W. Kahan