The exp function in Perl calculates "e" raised to the power of the real number taken as the parameter.
Here "e" is Euler’s Number or the base of the Natural system of logarithms or commonly known as an irrational number that approximates to 2.718281828, and is one of the most important mathematical constants. This "e" is broadly used in many occasions such as Compound Interests, Bernoulli trials, Normal Distribution, Calculus, and many more.
Syntax: exp value
Parameters:
value: It is the real value which defines the power "e" has to be raised to.
Returns: the value of e raised to the power of the given real value.
Example 1:
#!/usr/bin/perl
# Initialising some values for the
# parameter of the exp function
$A = 0;
$B = 1;
$C = 10;
$D = 20;
# Calling the exp function
$E = exp $A;
$F = exp $B;
$G = exp $C;
$H = exp $D;
# Getting the value of "e" raised to the
# power of the given parameter.
print "$E\n";
print "$F\n";
print "$G\n";
print "$H\n";
Output:
1 2.71828182845905 22026.4657948067 485165195.40979
Example 2:
#!/usr/bin/perl
# Calling the exp function
# Without Initializing values to variables
$A = exp 1;
$B = exp 2;
$C = exp 3;
$D = exp 4;
# Getting the value of "e" raised to the
# power of values taken as the parameter.
print "$A\n";
print "$B\n";
print "$C\n";
print "$D\n";
Output :
2.71828182845905 7.38905609893065 20.0855369231877 54.5981500331442