PHP | expm1() Function
Euler’s Number or commonly known as e is a very popular irrational number which approximates to 2.718281828 and is one of the most important mathematical constants. e is the base of the Natural system of logarithms. The exponential values are broadly used in many occasions such as Compound Interests, Bernoulli trials, Normal Distribution, Calculus and many more.
The expm1() function is an inbuilt function in PHP and is used to calculate e raised to the power of the given argument minus one.
Syntax:
float expm1($power)
Parameter: This function takes a single parameter $power which defines the power e has to be raised to.
Return Value: This function returns a floating point value which is the value of e raised to the $power of the given argument -1. That is, it will return (e$power-1).
Examples:
Input : $power = 1 Output : (e1-1) = 1.718281828459 Input : $power = 0 Output : (e0-1) = 0
Below programs illustrate the expm1() function in PHP:
Program 1: PHP program to demonsrate the expm1() function.
<?php // PHP program to demonsrate the expm1() function $n1 = 1; $n2 = 0; //prints value of e^1 - 1 echo "e^", $n1, "-1 = ", expm1($n1), "\n"; //prints value of e^0 - 1 echo "e^", $n2, "-1 = ", expm1($n2), "\n"; ?> |
Output:
e^1-1 = 1.718281828459 e^0-1 = 0
Program 2: PHP program to demonstrate the expm1() function using an array.
<?php // PHP code to illustrate the working // of expm1() Function // input array $array = array(2, 3, 1, 5); // print all the e^x-1 value in the arrays foreach($array as $i) echo 'e^'.$i.'-1 = '.expm1($i)."\n"; ?> |
Output:
e^2-1 = 6.3890560989307 e^3-1 = 19.085536923188 e^1-1 = 1.718281828459 e^5-1 = 147.41315910258
Reference:
http://php.net/manual/en/function.expm1.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- p5.js | nfs() Function
- p5.js | box() Function
- PHP | max( ) Function
- CSS | rgb() Function
- D3.js | d3.map.set() Function
- PHP | Ds\Map get() Function
- p5.js | int() function
- PHP | min( ) Function
- p5.js | hex() function
- p5.js | str() function
- D3.js | d3.rgb() Function
- PHP | dir() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



