NumPy Tutorial NumPy Statistics NumPy References

NumPy - exp() function



The NumPy exp() function is used to calculate e raised to the power of given value, i.e., ex. Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282.

Syntax

numpy.exp(a, out=None)

Parameters

a Required. Specify array (array_like) containing elements, of which the exponential is calculated.
out Optional. Specify a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Return Value

Returns the exponential of each element of a.

Example:

In the example below, numpy exp() function is used to calculate the exponential of each element present in array Arr.

import numpy as np

Arr = np.array([0, 1, 2, 3])

print("The exponential of values:")
print(np.exp(Arr))

The output of the above code will be:

The exponential of values:
[  1.           2.71828183   7.3890561   20.08553692]

❮ NumPy - Functions