The Python cmath.e constant returns Euler's number (e = 2.718281828459045). It is a predefined value commonly used in mathematical calculations, and every calculation has its own individual exponential growth, such as compound interest, population growth, and other engineering problems.
Euler's constant can't be expressed as a fraction because it is an irrational number, and its decimal representation goes on infinite without repeating.
SyntaxFollowing is the basic syntax of the Python cmath.e constant −
cmath.eReturn Values
This constant returns the value of mathematical constant e.
Example 1In the below example, we are using the Python cmath.e constant to calculate the compound interest. It will be issued on the principal amount over a specific period of time.
This involves applying the formula for compound interest with continuous compounding, where the Euler's number is raised to the power of the interest rate multiplied by time.
import cmath p = 2000 #principal r = 0.03 #rate t = 6 #time compound_interest = p * cmath.e ** (r * t) print("The compound interest after", t, "year is:", compound_interest)Output
The result will be obtained as follows −
The compound interest after 6 year is: 2394.4347262436204Example 2
Here, we are calculating the exponential growth of a quality over time using Euler's number (e). This is to compute the final amount after a specific period of time, providing the initial amount, growth rate, and time, using cmath.e Constant.
import cmath x = 40 #initial_amount y = 0.4 #growth_rate t = 4 #time result = x * cmath.e ** (y * t) print("The final amount after", t, "years of exponential growth is:", result)Output
The output obtained is as follows −
The final amount after 4 years of exponential growth is: 198.1212969758046Example 3
Here, we are calculating the probability density at a specified point "x" for a standard distribution using cmath.e constant.
import cmath x = 2 mu = 0 sigma = 1 probability_density = (1 / (cmath.sqrt(2 * cmath.pi) * sigma)) * cmath.e ** (-0.5 * ((x - mu) / sigma) ** 2) print("The probability density at x =", x, "for a standard normal distribution is:", probability_density)Output
We will get the output as shown below &minnus;
The probability density at x = 2 for a standard normal distribution is: (0.05399096651318806+0j)
python_modules.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4