EXP(3) | Library Functions Manual | EXP(3) |

`exp`

, `expf`

,
`expl`

, `exp2`

,
`exp2f`

, `exp2l`

,
`expm1`

, `expm1f`

,
`expm1l`

, `log`

,
`logf`

, `logl`

,
`log2`

, `log2f`

,
`log2l`

, `log10`

,
`log10f`

, `log10l`

,
`log1p`

, `log1pf`

,
`log1pl`

, `pow`

,
`powf`

, `powl`

—
exponential, logarithm, power functions

`#include <math.h>`

`double`

`exp`

(`double
x`);

`float`

`expf`

(`float
x`);

`long double`

`expl`

(`long
double x`);

`double`

`exp2`

(`double
x`);

`float`

`exp2f`

(`float
x`);

`long double`

`exp2l`

(`long
double x`);

`double`

`expm1`

(`double
x`);

`float`

`expm1f`

(`float
x`);

`long double`

`expm1l`

(`long
double x`);

`double`

`log`

(`double
x`);

`float`

`logf`

(`float
x`);

`long double`

`logl`

(`long
double x`);

`double`

`log2`

(`double
x`);

`float`

`log2f`

(`float
x`);

`long double`

`log2l`

(`long
double x`);

`double`

`log10`

(`double
x`);

`float`

`log10f`

(`float
x`);

`long double`

`log10l`

(`long
double x`);

`double`

`log1p`

(`double
x`);

`float`

`log1pf`

(`float
x`);

`long double`

`log1pl`

(`long
double x`);

`double`

`pow`

(`double
x`, `double y`);

`float`

`powf`

(`float
x`, `float y`);

`long double`

`powl`

(`long
double x`, `long double
y`);

`exp`

() function computes the base
e exponential value of the given argument
`expf`

() function is a
single precision version of `exp`

(). The
`expl`

() function is an extended precision version of
`exp`

().
The `exp2`

() function computes the base 2
exponential of the given argument `x`. The
`exp2f`

() function is a single precision version of
`exp2`

(). The `exp2l`

() function
is an extended precision version of `exp2`

().

The `expm1`

() function computes the value
exp(x) − 1 accurately even for tiny argument `x`.
The `expm1f`

() function is a single precision version
of `expm1`

(). The `expm1l`

()
function is an extended precision version of
`expm1`

().

The `log`

() function computes the value of
the natural logarithm of argument `x`. The
`logf`

() function is a single precision version of
`log`

(). The `logl`

() function
is an extended precision version of `log`

().

The `log2`

() function computes the value of
the logarithm of argument `x` to base 2. The
`log2f`

() function is a single precision version of
`log2`

(). The `log2l`

() function
is an extended precision version of `log2`

().

The `log10`

() function computes the value of
the logarithm of argument `x` to base 10. The
`log10f`

() function is a single precision version of
`log10`

(). The `log10l`

()
function is an extended precision version of
`log10`

().

The `log1p`

() function computes the value of
log(1 + x) accurately even for tiny argument `x`. The
`log1pf`

() function is a single precision version of
`log1p`

(). The `log1pl`

()
function is an extended precision version of
`log1p`

().

The `pow`

() function computes the value of
`x` to the exponent `y`. The
`powf`

() function is a single precision version of
`pow`

(). The `powl`

() function
is an extended precision version of `pow`

().

`exp`

(),
`expm1`

() and `pow`

() detect if
the computed value will overflow and set the global variable
`ERANGE`

. The function
`pow`

(`EDOM`

.
`pow`

(`pow`

(`pow`

() are accurate enough that
`pow`

(The function `pow`

(`x`,
`0`) returns x**0 = 1 for all x including x = 0 and
infinity. Previous implementations of `pow`

() may have
defined x**0 to be undefined in some or all of these cases. Here are reasons
for returning x**0 = 1 always:

- Any program that already tests whether x is zero (or infinite or NaN) before computing x**0 cannot care whether 0**0 = 1 or not. Any program that depends upon 0**0 to be invalid is dubious anyway since that expression's meaning and, if invalid, its consequences vary from one computer system to another.
- Some Algebra texts (e.g., Sigler's) define x**0 = 1 for all x, including x
= 0. This is compatible with the convention that accepts a[0] as the value
of polynomial
p(x) = a[0]*x**0 + a[1]*x**1 + a[2]*x**2 +...+ a[n]*x**n

at x = 0 rather than reject a[0]*0**0 as invalid.

- Analysts will accept 0**0 = 1 despite that x**y can approach anything or
nothing as x and y approach 0 independently. The reason for setting 0**0 =
1 anyway is this:
If x(z) and y(z) are
*any*functions analytic (expandable in power series) in z around z = 0, and if there x(0) = y(0) = 0, then x(z)**y(z) → 1 as z → 0. - If 0**0 = 1, then infinity**0 = 1/0**0 = 1 too; and then NaN**0 = 1 too because x**0 = 1 for all finite and infinite x, i.e., independently of x.

`exp`

() and `log`

() functions
first appeared in Version 1 AT&T UNIX;
`pow`

() in Version 3 AT&T
UNIX; `log10`

() in
Version 7 AT&T UNIX;
`log1p`

() and `expm1`

() in
4.3BSD.
June 1, 2016 | OpenBSD-current |