Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ exp(3M) — AOS 4.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

math(3M)

EXP(3M)  —  

NAME

exp, expm1, log, log10, log1p, pow − exponential, logarithm, power

SYNOPSIS

#include <math.h>

double exp(x)
double x;

double expm1(x)
double x;

double log(x)
double x;

double log10(x)
double x;

double log1p(x)
double x;

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

DESCRIPTION

Exp returns the exponential function of x. 

Expm1 returns exp(x)−1 accurately (even if x is close to 0 ). 

Log returns the natural logarithm of x.

Log10 returns the base 10 logarithm of x.

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

Pow returns xy. 

NOTES

Pow defines x0 = 1 for all x, including zero, ∞ and NaN.  Previous implementations of pow may have defined x0 to be undefined in some or all of those cases.  The reasons for setting x0 = 1 in all cases are these:

(1)Any program that already tests whether x is 0 (or ∞ or NaN) before computing x0 will be indifferent to whether 00 = 1 or not.  Any program that expects 00 to be invalid is dubious anyway since that expression’s meaning and, if valid, its consequences vary from one computer system to another. 

(2)Some Algebra texts (e.g. Sigler’s) define x0 = 1 for all x, including x = 0.  This is compatible with the convention for polynomials that accepts
p(x) = a[n]∗x∗∗n a0∗x0 + a1∗x1 + ... + an∗xn
and evaluates p(0) = a0 rather than reject a0∗00 as invalid. 

(3)Analysts will accept 00 = 1 despite that xy can approach anything or nothing as x and y approach zero independently.  The reason for setting 00 = 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) → 1 as z → 0. 

(4)If 00 = 1, then ∞0 = 1/00 = 1 too, and then NaN0 = 1 because x0 = 1 for all finite and infinite x. 

DIAGNOSTICS

Exp, expm1 and pow return a NaN when the correct value would overflow; errno is set to ERANGE.  Pow returns a NaN and sets errno to EDOM when the first argument is negative and the second is non-integral. 

Log returns a NaN when x is negative and −∞ when x is zero; errno is set to EDOM. 

ERRORS

Exp, log, expm and loglp are accurate to within an ulp and log10 to within about 2 ulps; an ulp is one Unit in the Last Place.  The error in pow is below about 2 ulps when its magnitude is moderate, but increases as pow approaches the over/underflow thresholds until as many bits could be lost as are occupied by the floating-point format’s exponent field (11 bits for double precision).  No such drastic loss has been exposed by testing;  the worst errors observed have been below 300 ulps.  Moderate values of pow are accurate enough that pow(integer,integer) is exact until it is bigger than 2∗∗53. 

SEE ALSO

math(3M)

PRPQs 5799-WZQ/5799-PFF: IBM/4.3  —  15 Dec 1986

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026