std::expm1,std::expm1f,std::expm1l (3) - Linux Manuals
std::expm1,std::expm1f,std::expm1l: std::expm1,std::expm1f,std::expm1l
NAME
std::expm1,std::expm1f,std::expm1l - std::expm1,std::expm1f,std::expm1l
Synopsis
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).
Parameters
arg - value of floating-point or Integral_type
Return value
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.
Error handling
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
Notes
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
Example
// Run this code
Possible output:
See also
exp
expf
expl returns e raised to the given power (ex)
(C++11)
(C++11)
exp2
exp2f
exp2l returns 2 raised to the given power (2x)
(C++11)
(C++11)
(C++11)
log1p
log1pf
log1pl natural logarithm (to base e) of 1 plus the given number (ln(1+x))
(C++11)
(C++11)
(C++11)