exp(): The exponent of e

Calculate e raised to a power

exp() returns e raised to the supplied exponent. It is commonly used in exponential-growth and logarithmic calculations.

$value = exp(1);
echo $value; // approximately 2.718281828

This is the recommended starting pattern. The detailed examples below are retained and modernized for additional variations and explanation.

<?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
'e' is the base of the natural system of logarithms, its value is approximately 2.718282.

Example 1: Calculating Compound Interest

<?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
?>

Example 2: Exponential Decay

<?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";
?>

Example 3: Modeling Population Growth

<?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";
?>

Math Functions LOG() function


Subscribe to our YouTube Channel here



plus2net.com











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