LOG10(): Base 10 logarithm

<?Php
echo LOG10(5);// Output is 0.69897000433602
echo "<br>";
echo LOG10(-6);// Output is NAN
echo "<br>";
echo LOG10(0);// Output is -INF
echo "<br>";
echo LOG10(8.6);// Output is 0.93449845124357
?>
Syntax
LOG10(X);
X is the input number with Base fixed base 10. We get output as LOG of X

Example 1: Logarithmic Scale for Sound Intensity

<?php
$intensity = 0.001;  // Sound intensity in watts per square meter
$reference = 0.00001;  // Reference intensity
$decibels = 10 * log10($intensity / $reference);
echo "Sound intensity: $decibels dB";
?>

Example 2: Finding Log Base 10 of a Percentage

<?php
$percentage = 75;
$log_percentage = log10($percentage / 100);
echo "Logarithm base 10 of 75%: $log_percentage";
?>
Output
Logarithm base 10 of 75%: -0.1249387366083

Example 3: Calculating Base-10 Logarithms of Positive Numbers

The log10() function computes the logarithm of a number with base 10. Here's a simple example:

<?php
echo log10(1000); // Logarithm base 10 of 1000
echo "<br>";
echo log10(10); // Logarithm base 10 of 10
?>

Example 4: Logarithms in Scientific Calculations

Base-10 logarithms are commonly used in scientific and engineering fields to represent large-scale measurements such as pH or decibels:

<?php
$intensity = 1000000; // Sound intensity
$decibels = 10 * log10($intensity);
echo "Decibels: " . $decibels;
?>

Example 5: Error Handling with log10()

Handle invalid input (e.g., negative numbers) when using log10():

<?php
$num = -10;
if ($num > 0) {
    echo log10($num);
} else {
    echo "Logarithm not defined for non-positive numbers.";
}
?>

Math Functions LOG() 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