Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

math(3m)

exp(3m)

NAME

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

SYNTAX

#include <math.h>

double exp(x)
double x;

float fexp(x)
float x;

double expm1(x)
double x;

float fexpm1(x)
float x;

double log(x)
double x;

float flog(x)
float x;

double log10(x)
double x;

float flog10(x)
float x;

double log1p(x)
double x;

float flog1p(fx)
float x;

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

DESCRIPTION

The exp and fexp functions return the exponential function of x for double and float data types respectively.

The expm1 and fexpm1 return exp(x)−1 accurately, including tiny x for double and float data types respectively.

The log and flog function return the natural logarithm of x for double and float data types respectively.

The log10 and flog10 functions return the logarithm of x to base 10 for double and float data types respectively.

The log1p and flog1p functions return log(1+x) accurately, including tiny x for double and float data types respectively.

The pow function returns x**y.

ERROR (for example, due to Roundoff)

The exp, log, expm1, and log1p functions are accurate to within an ulp, and log10 is accurate to within approximately 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 overflow or underflow thresholds until almost as many bits could be lost as are occupied by the floating−point format’s exponent field; 11 bits for IEEE 754 Double. No such drastic loss has been exposed by testing; the worst errors observed have been below 300 ulps for IEEE 754 Double.  Moderate values of pow are accurate enough that pow(integer,integer) is exact until it is bigger than 2**53 for IEEE 754 Double.

DIAGNOSTICS

The exp function returns ∞ when the correct value would overflow, or the smallest non-zero value when the correct value would underflow.

The log and log10 functions return the default quiet NaN when x is less than zero indicating the invalid operation.  The log and log10 functions return -∞ when x is zero. 

The pow function returns ∞ when x is 0 and y is non-positive. The pow function returns NaN when x is negative and y is not an integer indicating the invalid operation.  When the correct value for pow can overflow or underflow, pow returns ±∞ or 0 respectively.  The function pow returns 0 and sets errno to EDOM when the second argument is negative and non-integral and when both arguments are 0. 

SEE ALSO

math(3m)

Subroutines

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