function
<cmath> <ctgmath>
expm1
double expm1 (double x); float expm1f (float x);long double expm1l (long double x);
double expm1 (double x); float expm1 (float x);long double expm1 (long double x); double expm1 (T x); // additional overloads for integral types
Compute exponential minus one
Returns e raised to the power x minus one: ex-1.
For small magnitude values of x, expm1 may be more accurate than exp(x)-1.
Header
<tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (
<cmath> ) for the
integral types: These overloads effectively cast
x to a
double before calculations (defined for
T being any
integral type ).
Parameters
- x
- Value of the exponent.
Example
1
2
3
4
5
6
7
8
9
10
11
12
/* expm1 example */
#include <stdio.h> /* printf */
#include <math.h> /* expm1 */
int main ()
{
double param, result;
param = 1.0;
result = expm1 (param);
printf ("expm1 (%f) = %f.\n", param, result );
return 0;
}
Output:
expm1 (1.000000) = 1.718282.
See also
- exp
- Compute exponential function (function)
- log1p
- Compute logarithm plus one (function)
- pow
- Raise to power (function)