specfun_expm1 — Compute exp(x)-1 accurately for small values of x.
y = specfun_expm1 ( x )
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)