NumPy Universal Functions

Author: Al-mamun Sarkar Date: 2020-03-30 21:04:37

NumPy Array universal functions. The following shows various universal functions such as np.exp(), np.sqrt(), np.add() functions of the NumPy array of Python NumPy module. 

 

import numpy as np

 

Code:

B = np.arange(3)
B

Output:

array([0, 1, 2])

 

Code:

np.exp(B)

Output:

array([ 1.        ,  2.71828183,  7.3890561 ])

 

Code:

np.sqrt(B)

Output:

array([ 0.        ,  1.        ,  1.41421356])

 

Code:

C = np.array([2., -1., 4.])
np.add(B, C)

Output:

array([ 2.,  0.,  6.])