Home Communities
IT Knowledge
Inspiration
Languages
EN

# Python - math.exp() method example

0 points
Created by:
350

`math.exp()` is a method that takes only one parameter and returns exponential function value in the range `0` (exclusive) to `infinity`.

``````import math

print(math.exp(-100))       # 3.720075976020836E-44
print(math.exp(-1))         # 0.36787944117144233
print(math.exp(0))          # 1
print(math.exp(1))          # 2.718281828459045
print(math.exp(100))        # 2.6881171418161356E43

print(math.exp(-math.inf))  # 0
print(math.exp(math.inf))   # ∞ / +Infinity
print(math.exp(math.nan))   # NaN``````

## 1. Documentation

 Syntax ``math.exp(number)`` Parameters `number` - value that specifies the exponent Result Exponential function value of a number in the range `0` (exclusive) to `infinity`. If the value can not be calculated `nan` is returned. Description `math.exp()` is a method that takes only one parameter and returns exponential function value.

## 2. Reversed console plot example

``````import math

def print_line(y1, y2, dy, character):
line = ""

y = y1
while y < y2:
line += " "
y += dy

print(line, character)

x1 = -4
x2 = 2.8

y1 = -1.0
y2 = +10.0

xSteps = 25
ySteps = 60

dx = (x2 - x1) / xSteps  # x axis step
dy = (y2 - y1) / ySteps  # y axis step

if y <= y1 or y >= y2:
print(" ")
else:
print_line(y1, y, dy, "+")

Output:

``````      +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+``````

## References

1. Exponential function - Wikipedia
Join to our subscribers to be up to date with content, news and offers.