略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: expm1

2024-04-16

expm1

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

expm1 返回 exp(number) - 1,甚至当 number 的值接近零也能计算出准确结果

说明

expm1(float $arg): float

expm1() 返回 'exp(number) - 1',甚至当 number 的值接近零也能计算出准确结果。但是当两个数值趋近于相等的时候, 'exp (number) - 1' 就会变得不太准确。

参数

arg

要处理的参数

返回值

'e' to the power of arg minus one

更新日志

版本 说明
5.3.0 此函数在所有平台上均可用

参见

  • log1p() - 返回 log(1 + number),甚至当 number 的值接近零也能计算出准确结果
  • exp() - 计算 e 的指数
add a noteadd a note

User Contributed Notes 2 notes

up
0
hagen at von-eitzen dot de
19 years ago
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);
}
?>
up
-1
brettz9 AAT yah
13 years ago
Note that exp(x)-1 can be approximated by x + x^2/2! + ... + x^n/n!  and for any value

官方地址:https://www.php.net/manual/en/function.expm1.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3