LOG(): The logarithm of a number to base

<?Php
echo LOG(2);// Output is 0.69314718055995
echo "<br>";
echo LOG(-1);// Output is NAN
echo "<br>";
echo LOG(0);// Output is -INF
echo "<br>";
echo LOG(5.7);// Output is 1.7404661748405
?>
Syntax
LOG(X,Y);
X is the input number with Base Y (optional) . We get output as LOG of X

LOG() with Base

<?Php
echo LOG(5,2);// Output is 2.3219280948874
echo "<br>";
echo LOG(5,10);// Output is 0.69897000433602 
echo "<br>";
echo LOG(5,2.7183);// Output is 1.609427153552
?>

Example: Calculating Logarithms with Different Bases

$value = 100;
$base = 2;
$log_base2 = log($value, $base);  // Output: 6.643856
echo $log_base2;

Example: Handling Invalid Inputs

$value = -10;
$result = log($value);
if (is_nan($result)) {
    echo "Logarithm undefined for negative values.";
}
Output
Logarithm undefined for negative values.

Questions


Math Functions LOG10() function LOG1P() function
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com











    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer