In [1]:
import numpy as np
arr = np.arange(0,10)
In [2]:
arr + arr
Out[2]:
In [3]:
arr * arr
Out[3]:
In [4]:
arr - arr
Out[4]:
In [5]:
# Warning on division by zero, but not an error!
# Just replaced with nan
arr/arr
Out[5]:
In [6]:
# Also warning, but not an error instead infinity
1/arr
Out[6]:
In [7]:
arr**3
Out[7]:
Numpy comes with many universal array functions, which are essentially just mathematical operations you can use to perform the operation across the array. Let's show some common ones:
In [8]:
#Taking Square Roots
np.sqrt(arr)
Out[8]:
In [9]:
#Calcualting exponential (e^)
np.exp(arr)
Out[9]:
In [10]:
np.max(arr) #same as arr.max()
Out[10]:
In [11]:
np.sin(arr)
Out[11]:
In [12]:
np.log(arr)
Out[12]: