Compute exp(x)-1 accurately for small values of x.
y = specfun_expm1 ( x )
a matrix of doubles
a matrix of doubles, exp(x)-1
Returns exp(x)-1 accurately for small values of x.
The method suggested by Kahan is used to improve accuracy.
specfun_expm1(2) // Plot this function for positive inputs. scf(); plot(linspace(-0.5,2,1000),specfun_expm1) // Compare the precision of expm1 and exp // for small x: expm1 gives the exact result // while exp(x)-1 is not as accurate. x = 0.000001; e = 1.000000500000166666e-6 // From Wolfram Alpha y1 = specfun_expm1(x); abs(y1-e)/abs(e) y2 = exp(x)-1; abs(y2-e)/abs(e) | ![]() | ![]() |
Don Hatch, http://www.plunk.org/~hatch/rightway.php
http://www.opengroup.org/onlinepubs/000095399/functions/expm1.html