NumPy 提供了大量好用的通用函数,其中对于数据科学家最有用的就是三角函数。首先定
义一个角度数组:
In[15]: theta = np.linspace(0, np.pi, 3)
现在可以对这些值进行一些三角函数计算:
In[16]: print("theta = ", theta)
print("sin(theta) = ", np.sin(theta))
print("cos(theta) = ", np.cos(theta))
print("tan(theta) = ", np.tan(theta))
theta = [ 0. 1.57079633 3.14159265]
sin(theta) = [ 0.00000000e+00 1.00000000e+00 1.22464680e-16]