©
Ce document utilise Manuel du site Web PHP chinois Libérer
(PHP 4 >= 4.1.0, PHP 5)
expm1 — 返回 exp(number) - 1,甚至当 number 的值接近零也能计算出准确结果
$arg
) expm1() 返回 'exp(number
) - 1',甚至当
number
的值接近零也能计算出准确结果。但是当两个数值趋近于相等的时候,
'exp (number
) - 1' 就会变得不太准确。
arg
要处理的参数
'e' to the power of arg
minus one
版本 | 说明 |
---|---|
5.3.0 | 此函数在所有平台上均可用 |
[#1] brettz9 AAT yah [2009-04-02 20:07:47]
Note that exp(x)-1 can be approximated by x + x^2/2! + ... + x^n/n! and for any value
[#2] hagen at von-eitzen dot de [2003-02-24 03:57:51]
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:
<?php
function expm1($x) {
return ($x>-1.0e-6 && $x<1.0e-6) ? ($x + $x*$x/2) : (exp($x)-1);
}
?>