Universal functions

Lesson 5 Chapter 2

NumPy, for performing element-wise operations, provides some universal functions. Take a look at some of the universal functions demonstrated below:

# Import Numpy library import numpy as np v = np.array([1, 3, 5]) w = np.array([2, 4, 6]) # Exponential opration print('e^v= ', np.exp(v)) # The squere root of an array print('v^{1/2}= ', np.sqrt(v)) # Adding two vectors print('v+w= ', np.add(v, w)) # Sin and Cos of an array print('Sin(v)= ', np.sin(v)) print('Cos(v)= ', np.cos(v))