expm1() calculates exp($x) - 1 with better numerical accuracy when the input is close to zero.
$x = 0.000001;
echo expm1($x);
This is the recommended starting pattern. The detailed examples below are retained and modernized for additional variations and explanation.
<?Php
echo expm1(5); // Output 147.41315910258
echo "<br>";
echo expm1(1); // Output 1.718281828459
echo "<br>";
echo expm1(0); // Output is 0
echo "<br>";
echo expm1(-1); // Output is -0.63212055882856
echo "<br>";
?>
Syntax
float expm1(float X);
X is the input float number . We get output as exp(X) - 1
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.