HPlogo HP-UX Reference Volume 4 of 5 > e

expm1(3M)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

expm1() — computes exponential functions

SYNOPSIS

#include <math.h>

double expm1(double x);

DESCRIPTION

The expm1() function is equivalent to exp(x) - 1, but may be more accurate for very small values of x.

The expm1() and log1p() functions are useful to guarantee that financial calculations of (((1+x)**n)-1)/x, namely:

expm1(n * log1p(x))/x

are accurate when x is very small (for example, when calculating small daily interest rates).

The ISO/ANSI C committee has approved the expm1() function for inclusion in the C9X draft standard.

To use this function, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options. Make sure your program includes <math.h>. Link in the math library by specifying -lm on the compiler or linker command line.

RETURN VALUE

If x is +INFINITY, expm1() returns +INFINITY.

If x is -INFINITY, expm1() returns -1.0.

If x is NaN, expm1() returns NaN.

If the correct value after rounding would be smaller in magnitude than MINDOUBLE, expm1() returns zero.

If the value overflows, expm1() returns HUGE_VAL and sets errno to [ERANGE].

ERRORS

If expm1() fails, errno is set to the following value.

[ERANGE]

The result overflows.

STANDARDS CONFORMANCE

expm1(): XPG4.2

© Hewlett-Packard Development Company, L.P.