Skip to content

Python exponential numpy

  • by

Use the NumPy library numpy.exp() function to calculate the exponential value of each element in an array. The exp the function returns an array with the element-wise exponent.

Python exponential numpy example

Simple example code import the NumPy library and use the np.exp() function to calculate the exponential of a scalar value x and an array arr.

import numpy as np

# scalar value
x = 2
exp_x = np.exp(x)

# array
arr = np.array([1, 2, 3])
exp_arr = np.exp(arr)


Python exponential numpy

Comment if you have any doubts or suggestions on this Python exponential topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *