<?Php
echo exp(3);// Output is 20.085536923188
echo "<br>";
echo exp(-1);// Output is 0.36787944117144
echo "<br>";
echo exp(0);// Output is 1
echo "<br>";
?>
Syntax
exp(X);
X is the input float . We get output as e raised to the power of X
<?php
$principal = 1000;
$rate = 0.08; // 8%
$time = 5;
$amount = $principal * exp($rate * $time);
echo "Amount after 5 years: $amount"; // Output: Amount after 5 years
?>
<?php
$initial_amount = 100;
$decay_constant = 0.03;
$time = 10;
$remaining_amount = $initial_amount * exp(-$decay_constant * $time);
echo "Remaining after 10 years: $remaining_amount";
?>
<?php
$initial_population = 1000;
$growth_rate = 0.02; // 2% annual growth
$years = 8;
$population = $initial_population * exp($growth_rate * $years);
echo "Population after 8 years: $population";
?>
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.