📜  珀尔 | exp函数

📅  最后修改于: 2022-05-13 01:55:29.069000             🧑  作者: Mango

珀尔 | exp函数

Perl 中的 exp函数计算“e”作为参数的实数次方。
这里的“e”是欧拉数或自然对数系统的底数,或者俗称的无理数,近似于 2.718281828,是最重要的数学常数之一。这个“e”被广泛用于许多场合,例如复利、伯努利试验、正态分布、微积分等等。

示例 1:

Perl
#!/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";


Perl
#!/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";


输出:

1
2.71828182845905
22026.4657948067
485165195.40979

示例 2:

Perl

#!/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";

输出 :

2.71828182845905
7.38905609893065
20.0855369231877
54.5981500331442