PHP | exp() 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 exp() function is used to calculate e raised to the power of the given argument.
Syntax:
float exp($power)
Parameters: The function takes a single parameter $power which defines the power e has to be raised to.
Return Type: This function returns the value of e raised to the power of the given argument as a float.
Examples:
Input : $power = 0; Output : 1 Input : $power = 1; Output : 2.718281828459
Below program illustrates the working of exp() in PHP:
<?php // PHP code to illustrate the working of exp() Function for($i=-2;$i<=2;$i++) echo 'e^'.$i.' = '.exp($i)."\n"; ?> |
Output:
e^-2 = 0.13533528323661 e^-1 = 0.36787944117144 e^0 = 1 e^1 = 2.718281828459 e^2 = 7.3890560989307
Important points to note:
- exp() function is a very popular method to calculate exponential values.
- log() function is the functional counterpart of exp().
Reference:
http://php.net/manual/en/function.exp.php
Recommended Posts:
- PHP | ord() Function
- PHP | Ds\Set add() Function
- PHP | min( ) Function
- PHP | tan( ) Function
- PHP | cos( ) Function
- PHP | pi( ) Function
- PHP Ds\Map first() Function
- CSS | rgb() Function
- PHP | next() Function
- PHP | each() Function
- PHP | pow( ) Function
- PHP Ds\Map sum() Function
- PHP | dir() Function
- PHP | Ds\Set first() Function
- PHP | Ds\Set last() 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.



