PHP Function Reference

PHP expm1() Function



The PHP expm1() function returns e raised to the power of specified number minus 1, i.e., ex-1. Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282. In special cases it returns the following:

  • If the argument is NAN, the result is NAN.
  • If the argument is positive infinity, then the result is positive infinity.
  • If the argument is negative infinity, then the result is -1.0.

Syntax

expm1(x)   

Parameters

x Required. Specify the exponent of e.

Return Value

Returns e raised to the power of specified number minus 1, i.e., ex-1.

Example:

In the example below, expm1() function is used to calculate e raised to the power of specified number minus one.

<?php
echo "expm1(-2) = ".expm1(-2)."\n";
echo "expm1(-1) = ".expm1(-1)."\n";
echo "expm1(0) = ".expm1(0)."\n";
echo "expm1(1) = ".expm1(1)."\n";
echo "expm1(2) = ".expm1(2)."\n";
echo "expm1(INF) = ".expm1(INF)."\n";
echo "expm1(-INF) = ".expm1(-INF)."\n";
echo "expm1(NAN) = ".expm1(NAN)."\n";
?>

The output of the above code will be:

expm1(-2) = -0.86466471676339
expm1(-1) = -0.63212055882856
expm1(0) = 0
expm1(1) = 1.718281828459
expm1(2) = 6.3890560989307
expm1(INF) = INF
expm1(-INF) = -1
expm1(NAN) = NAN

❮ PHP Math Reference