Note that exp(x)-1 can be approximated by x + x^2/2! + ... + x^n/n! and for any value
expm1
(PHP 4 >= 4.1.0, PHP 5)
expm1 — 返回 exp(number) - 1,甚至当 number 的值接近零也能计算出准确结果
expm1
brettz9 AAT yah
03-Apr-2009 04:07
03-Apr-2009 04:07
hagen at von-eitzen dot de
24-Feb-2003 11:57
24-Feb-2003 11:57
Compare this to log1p (which is its inverse).
Also, You may have to use a similar workaraound in case the underlying C library
does not support expm1:
function expm1($x) {
return ($x>-1.0e-6 && $x<1.0e-6) ? ($x + $x*$x/2) : (exp($x)-1);
}
