exponential functions

You're viewing an older version of this page (#3242). View the current version.

View versions (4)

NAME

exp, exp2, expm1

INTERFACE

#include <math.h>

double exp ( double x ) long expl ( long double x ) float expf ( float x ) double exp2 ( double x ) long exp2l ( long double x ) float exp2f ( float x ) double expm1 ( double x ) long expm1l ( long double x ) float expm1f ( float x )

DESCRIPTION

The exp function computes e^x, the base-e exponential of x.

The exp2 function computes 2^x, the base-2 exponential of x.

The expm1 function computes the base-e exponential of x, minus 1 accurately even for very small values of x.

Example 1

#include <stdio.h>
#include <math.h>

int main(void)
{
  double result, x = 4.0;
  result = exp(x);
  printf("'e' raised to the power of %lf (e^%lf)=%lf\n", x, x, result);
  return 0;
}

SPECIAL VALUES

exp ( &plusmn;0 ) and exp2 ( &plusmn;0 ) return 1.
exp ( -&infin; ) and exp2 ( -&infin; ) return +0.
exp ( +&infin; ) and exp2 ( +&infin; ) return +&infin;.
expm1 ( &plusmn;0 ) returns &plusmn;0.
expm1 ( -&infin; ) returns -1.
expm1 ( +&infin; ) returns +&infin;.

For all these functions, a range error occurs if the magnitude of x is too large.

STANDARDS

The exp , exp2 , and expm1 functions conform to ISO/IEC 9899:1999(E).