16.Numpy之函数运算

#NumPy之 函数运算
import numpy as np

#math calculations

print('math calculations for array:')
a=np.array([0,1,2,3])
b=np.array([2,-1,2,3])
print(np.exp(a))
print(np.sqrt(a))
print(np.add(a,b))
# output:
# [  1.           2.71828183   7.3890561   20.08553692]
# [ 0.          1.          1.41421356  1.73205081]
# [2 0 4 6]
c=np.linspace(0,8,20)
print('c:')
print(c)
# c:
# [ 0.          0.42105263  0.84210526  1.26315789  1.68421053  2.10526316
#   2.52631579  2.94736842  3.36842105  3.78947368  4.21052632  4.63157895
#   5.05263158  5.47368421  5.89473684  6.31578947  6.73684211  7.15789474
#   7.57894737  8.        ]
print('sin(c):')
print(np.sin(c))
# sin(c):
# [ 0.          0.40872137  0.74604665  0.95305133  0.9935755   0.86054034
#   0.57718464  0.19300541 -0.2248883  -0.60349817 -0.87668803 -0.99673665
#  -0.94267373 -0.72394309 -0.37875293  0.03259839  0.43825537  0.76735722
#   0.96241589  0.98935825]
原文地址:https://www.cnblogs.com/wjc920/p/9256148.html