# expm1, expm1f, expm1l Functions in C

• Last Updated : 12 Apr, 2022

expm1(), expm1f(), expm1l() were introduced with C99, and are available under the <math.h> header file. These are used to calculate the Euler’s Number, e (2.7182818) raised to a power equal to the provided parameter minus 1.0, i.e ex – 1.

expm1(x), expm1f(x), exmp1l(x) = ex – 1

Example:

double expm1(double arg);

float  expm1f(float arg);

long double expm1l(long double arg);

Syntax:

expm1(x);

exmp1f(x);

exmp1l(x);

Parameters:

### Return Values:

1. If no error occurs:

2. If range error due to overflow occurs:

3. If range error due to underflow occurs: If a range error occurs due to underflow, the rounded result is returned.

4. Exceptional cases: The errors reported are handled as specified in  math_errhandling.

Example 1: Below is the C program to implement exp1():

## C

 `// C program to implement  ` `// exp1() ` `#include ` `#include ` ` `  `// Driver code ` `int` `main() ` `{ ` `    ``double` `arg = 2.2310233; ` `    ``printf``(``"%lf\n"``,  ` `            ``expm1(arg)); ` `    ``return` `0; ` `}`

Output

`8.309388`

Example 2: Below is the C program to implement exp1f():

## C

 `// C program to implement ` `// exp1f() ` `#include ` `#include ` ` `  `// Driver code ` `int` `main() ` `{ ` `    ``float` `arg = 4.121; ` `    ``printf``(``"%f\n"``,  ` `            ``expm1f(arg)); ` `    ``return` `0; ` `}`

Output

`60.620819`

Example 3: Below is the C program to implement exp1l():

## C

 `// C program to implement ` `// exp1l() ` `#include ` `#include ` ` `  `// Driver code ` `int` `main() ` `{ ` `    ``long` `double` `arg = 5.212323323441; ` `    ``printf``(``"%Lf\n"``,  ` `            ``expm1l(arg)); ` `    ``return` `0; ` `}`

Output

`182.519939`

Why use expm1, expm1f, expm1l?

• These functions are more accurate than the expression ex – 1if x → 0.
• They are very useful for financial calculations, like calculating (small) interest rates, and for calculating the inverse of hyperbolic functions.

My Personal Notes arrow_drop_up
Recommended Articles
Page :