Math Log1p In PHP

In this article I explain the PHP math log1p function.
  • 1646

PHP log1p() function

The PHP math log function is used to return the log(1+a) , where a is a number, computed in a way that is accurate even when the value of a is close to zero.

Syntax

log1p( number)


Parameters in
 log10 function

It takes one parameter; it is:
 

Parameter Description
number It specifies a number.

Example of log1p function

<?php

$val1=log1p(2);

$val2=log1p(0);

$val3=log1p(1.232);

$val4=log1p(1);

echo "log1p value of <b>2</b> is <b>$val1</b> <br />";

echo "log1p value of <b>0</b> is <b>$val2</b> <br />";

echo "log1p value of <b>1.232</b> is <b>$val3</b> <br />";

echo "log1p value of <b>1</b> is <b>$val4</b> <br />";

?>

Note: The above code is used to convert numbers to the log(1+a). So in the above example the numbers "2", "0", "1.232" and "1" are converted to log(1+a).

Output

log1p-math-function-in-php.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.