5.9.1. 常用¶
SciPy 是一个开源的 Python 算法库和数学工具包。SciPy 包含的模块有最优化、线性代数、积分、插值、特殊函数、快速傅里叶变换、信号处理和图像处理、常微分方程求解和其他科学与工程中常用的计算。
SciPy 官网:https://www.scipy.org/
SciPy 源代码:https://github.com/scipy/scipy
安装:
$ pip install numpy scipy matplotlib ipython jupyter pandas sympy nose
$ apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
$ brew install numpy scipy ipython jupyter
使用:
from scipy import optimize, special
from numpy import *
from pylab import *
x = arange(0,10,0.01)
for k in arange(0.5,5.5):
y = special.jv(k,x)
plot(x,y)
f = lambda x: -special.jv(k,x)
x_max = optimize.fminbound(f,0,6)
plot([x_max], [special.jv(k,x_max)],'ro')
title('Different Bessel functions and their local maxima')
show()