Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP Math log1p() function returns the natural logarithm of (1 + number), i.e., log(1+number).

Syntax

log1p(number)

Parameters

number Required. Specify the number.

Return Value

Returns the natural logarithm of (1 + number), i.e., log(1+number).

Example:

In the below example, log1p() function is used to calculate the log(1+number).

<?php
$x = 0; 
$y = 1;
$z = 2;

echo "log1p($x) equal to: ".log1p($x)."\n";
echo "log1p($y) equal to: ".log1p($y)."\n";
echo "log1p($z) equal to: ".log1p($z)."\n";  
?>

The output of the above code will be:

log1p(0) equal to: 0
log1p(1) equal to: 0.69314718055995
log1p(2) equal to: 1.0986122886681

❮ PHP Math Functions