expm1, expm1f, expm1l
Defined in header <math.h>
|
||
float expm1f( float arg ); |
(1) | (since 哋它亢99) |
double expm1( double arg ); |
(2) | (since 哋它亢99) |
long double expm1l( long double arg ); |
(3) | (since 哋它亢99) |
Defined in header <tgmath.h>
|
||
#define expm1( arg ) |
(4) | (since 哋它亢99) |
2.7182818
) raised to the given power arg
, minus 1.0. This function is more accurate than the expression MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 41 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(arg)-1.0 if arg
is close to zero.arg
has type long double, expm1l
is called. Otherwise, if arg
has integer type or the type double, expm1
is called. Otherwise, expm1f
is called.Parameters
arg | - | floating-point value |
Return value
If no errors occur earg
-1 is returned.
If a range error due to overflow occurs, MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 40 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE, +HUGE_VALF
, or +HUGE_VALL
is returned.
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 39 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
Error handling
Errors are reported as specified in math_errhandling.
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 38 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
- 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 expm1
and MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 37 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE are useful for financial calculations, for example, when calculating small daily interest rates: (1+x)n
-1 can be expressed as expm1(n * MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 36 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(x)). These functions also simplify writing accurate inverse hyperbolic functions.
For IEEE-compatible type double, overflow is guaranteed if 709.8 < arg.
Example
#include <errno.h> #include <fenv.h> #include <float.h> #include <math.h> #include <stdio.h> // #pragma STDC FENV_ACCESS ON int main(void) { MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 35 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("expm1(1) = %f\n", expm1(1)); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 34 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("Interest earned in 2 days on $100, compounded daily at 1%%\n" " on a 30/360 calendar = %f\n", 100*expm1(2*MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 33 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(0.01/360))); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 31 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("exp(1e-16)-1 = %g, but expm1(1e-16) = %g\n", MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 30 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(1e-16)-1, expm1(1e-16)); // special values MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 29 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("expm1(-0) = %f\n", expm1(-0.0)); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 28 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("expm1(-Inf) = %f\n", expm1(-INFINITY)); //error handling errno = 0; MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 27 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 26 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE); MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 25 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("expm1(710) = %f\n", expm1(710)); if (errno == MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 24 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE) MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 23 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(" errno == ERANGE"); if (MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 22 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 21 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE)) MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 20 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE(" FE_OVERFLOW raised"); }
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 06 HOURS 51 MINUTES 19 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
expm1(1) = 1.718282 Interest earned in 2 days on $100, compounded daily at 1% on a 30/360 calendar = 0.005556 exp(1e-16)-1 = 0, but expm1(1e-16) = 1e-16 expm1(-0) = -0.000000 expm1(-Inf) = -1.000000 expm1(710) = inf errno == ERANGE: Result too large FE_OVERFLOW raised
References
- 哋它亢23 standard (ISO/IEC 9899:2023):
- 7.12.6.3 The expm1 functions (p: TBD)
- 7.25 Type-generic math <tgmath.h> (p: TBD)
- F.10.3.3 The expm1 functions (p: TBD)
- 哋它亢17 standard (ISO/IEC 9899:2018):
- 7.12.6.3 The expm1 functions (p: 177)
- 7.25 Type-generic math <tgmath.h> (p: 272-273)
- F.10.3.3 The expm1 functions (p: 379)
- 哋它亢11 standard (ISO/IEC 9899:2011):
- 7.12.6.3 The expm1 functions (p: 243)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.3.3 The expm1 functions (p: 521)
- 哋它亢99 standard (ISO/IEC 9899:1999):
- 7.12.6.3 The expm1 functions (p: 223-224)
- 7.22 Type-generic math <tgmath.h> (p: 335-337)
- F.9.3.3 The expm1 functions (p: 458)
See also
(哋它亢99)(哋它亢99) |
computes e raised to the given power (ex) (function) |
(哋它亢99)(哋它亢99)(哋它亢99) |
computes 2 raised to the given power (2x) (function) |
(哋它亢99)(哋它亢99)(哋它亢99) |
computes natural (base-e) logarithm of 1 plus the given number (ln(1+x)) (function) |