std::expm1,std::expm1f,std::expm1l (3) - Linux Man Pages
Defined in header <cmath>
float expm1 ( float arg ); (1) (since C++11)
float expm1f( float arg );
double expm1 ( double arg ); (2) (since C++11)
long double expm1 ( long double arg ); (3) (since C++11)
long double expm1l( long double arg );
double expm1 ( IntegralType arg ); (4) (since C++11)
1-3) Computes the e (Euler's number, 2.7182818) raised to the given power arg, minus 1.0. This function is more accurate than the expression std::exp(arg)-1.0 if arg is close to zero.
4) A set of overloads or a function template accepting an argument of any integral_type. Equivalent to 2) (the argument is cast to double).
arg - value of floating-point or Integral_type
If no errors occur earg
-1 is returned.
If a range error due to overflow occurs, +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL is returned.
If a range error occurs due to underflow, the correct result (after rounding) is returned.
Errors are reported as specified in math_errhandling.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
* If the argument is ±0, it is returned, unmodified
* If the argument is -∞, -1 is returned
* If the argument is +∞, +∞ is returned
* If the argument is NaN, NaN is returned
The functions std::expm1 and std::log1p are useful for financial calculations, for example, when calculating small daily interest rates: (1+x)n
-1 can be expressed as std::expm1(n * std::log1p(x)). These functions also simplify writing accurate inverse hyperbolic functions.
For IEEE-compatible type double, overflow is guaranteed if 709.8 < arg
// Run this code
expl returns e raised to the given power (ex)
exp2l returns 2 raised to the given power (2x)
log1pl natural logarithm (to base e) of 1 plus the given number (ln(1+x))