python有什么package是可以用来计算三角函数的?
比如tanh,sin,arctan之类的
2个回答
用numpy计算比较方便,虽然math里也有,但是math的输入值必须是单个数,不能是list或者array
>>> import numpy as np
# x可以是list或者np.ndarray
# cos(x)
>>> np.cos(x)
# sin(x)
>>> np.sin(x)
# tan(x)
>>> np.tan(x)
# acrcos(x)
>>> np.arccos(x)
# acrsin(x)
>>> np.arcsin(x)
# acrtan(x)
>>> np.arctan(x)
# cosh(x)
>>> np.cosh(x)
# sinh(x)
>>> np.sinh(x)
# tanh(x)
>>> np.tanh(x)
math里基本上都有了
>>> import math
# cos(x)
>>> math.cos(x)
# sin(x)
>>> math.sin(x)
# tan(x)
>>> math.tan(x)
# acrcos(x)
>>> math.acos(x)
# acrsin(x)
>>> math.asin(x)
# acrtan(x)
>>> math.atan(x)
# cosh(x)
>>> math.cosh(x)
# sinh(x)
>>> math.sinh(x)
# tanh(x)
>>> math.tanh(x)