Home >>PHP Math Functions >PHP log1p() Function
PHP log1p() function is used to calculate log(1+number) of the given input value as $number argument, computed in such a way that is accurate even when the value of given number is close to zero. It accepts only a single parameter $number.
Syntax:
log1p($number);
Parameter | Description |
---|---|
number | This is a required parameter. This parameter defines the number to process. |
Here is an example of log1p() function in PHP:
<html> <body> <?php echo log1p(0)."<br>"; echo log1p(1)."<br>"; echo log1p(5)."<br>"; echo log1p(10)."<br>"; echo log1p(100)."<br>"; ?> </body> </html>
Here is another example of log1p() function in PHP:
<html> <body> <?php echo log(1)."<br>"; echo log1p(1)."<br>"; echo log(10)."<br>"; echo log(11)."<br>"; echo log1p(10)."<br>"; // log(10+1) echo log(100)."<br>"; echo log(101)."<br>"; echo log1p(100)."<br>"; // log(100+1) ?> </body> </html>