Compute exp(x)-1 accurately for small values of x.
double expm1( double x )
exp(x) - 1
EX1
void expm1_ex1() { double x = 0.0000000000000001; double answer = expm1(x); printf("expm1(%.30f) = %.30f\n", x, answer); // Result is "expm1(0.000000000000000100000000000000) = 0.000000000000000100000000000000" }
EX2
void expm1_ex2() { double x = 0.000000000000001; double answer = expm1(x); printf("expm1(%.30f) = %.30f\n", x, answer); // Result is "expm1(0.000000000000001000000000000000) = 0.000000000000001110223024625157" }
This funciton is used to calculate when x is very close to zero. For this case, expm1(x) is approximately x, whereas exp(x) - 1 can be zero.
exp
origin.h