PHP expm1() Function


Definition and Usage

The expm1() function returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero, a case where 'exp (number) - 1' would be inaccurate due to subtraction of two numbers that are nearly equal.

expm1(x) = exp(x) - 1

This function returns a float value .

Syntax

expm1 ( float $arg ) : float

Parameters

Sr.NoParameter & Description
1arg
A floating point number whose expm1 is to be calculated.

Return Values

PHP expm1() function returns a floating point value.

PHP Version

This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.

Example

 Live Demo

Following example calculates expm1(2) and tallies the return value with (exp(2)-1) −

<?php
   echo "expm1(2) = " . expm1(2) . "
";    echo "exp(2)-1 = " . (exp(2)-1); ?>

Output

This will produce following result −

expm1(2) = 6.3890560989307
exp(2)-1 = 6.3890560989307

Example

 Live Demo

Following example returns value of expm1(0) −

<?php
   echo "expm1(0) = " . expm1(0) . "
"; ?>

Output

This will produce following result −

expm1(0) = 0

Example

 Live Demo

Let's check find out expm1(-1).−

<?php
   echo "expm1(-1) = " . expm1(-1) . "
"; ?>

Output

This will produce following result −

expm1(-1) = -0.63212055882856

Example

 Live Demo

Following example returns values of expm1(1) −

<?php
   echo "expm1(1) = " . expm1(1) . "
"; ?>

Output

This will produce following result −

expm1(1) = 1.718281828459

Updated on: 29-Jun-2020

21 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements