The exp
function in NumPy is used to compute the exponent of all values present in the given array.
e
refers to Euler’s constant. It has an approximate value of 2.718.
The syntax of the exp
function is as follows:
numpy.exp(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'exp'>
The description of each parameter of the exp
function is given below:
Parameter | Description |
---|---|
array |
The array of numbers to compute exponents of. |
out |
The location where the result is stored. By default, a new array of results is created. |
where |
Takes an array-like object. At locations where it is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. |
dtype |
Data type of the resultant array. |
casting |
Determines which kind of casting is permissible. Can be ‘no’, ‘equiv’, ‘safe’, ‘same_kind’, or ‘unsafe’. |
order |
Determines the calculation iteration order or memory layout of the output array. |
subok |
If set to False , the output will always be a strict array and not a subtype. It is True by default. |
The exp
function returns an array with the element-wise exponent.
The code snippet below shows how the exp
function works in NumPy:
import numpy as npin_array = [1, 3, 5]print ("Input array : ", in_array)out_array = np.exp(in_array)print ("Output array : ", out_array)
Free Resources