答案 0 :(得分:2)
https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.integrate.ode.html
这里是您要搜索的库,如果您在底部向下滚动,也会有一些示例。读得很好
答案 1 :(得分:0)
您的解决方案可能如下所示(如果删除所有与绘图相关的行,则很短)
import numpy as np
from scipy.integrate import odeint
import matplotlib
matplotlib.use('Qt4Agg')
import matplotlib.pyplot as pl
# define the ODE as a first order system
def func(y,x):
return [
y[1],
y[2],
( 7*x**1.5 - 5*x**2*y[2]-2*x*y[1] + 2*y[0]) / x**3
]
# initial values
y0=[ 10.6, -3.6, 31.2]
# points at which the solution value is requested
x = np.linspace(1,10,501)
# numerical integration
y=odeint(func, y0, x)
# y[-1,:] contains the value at x=10
print "[ y(10), y'(10), y''(10) ] = ", y[-1,:]
# plot the solution with subplots for each component
fig=pl.figure()
ax=fig.add_subplot(311)
ax.plot(x, y[:,0])
ax=fig.add_subplot(312)
ax.plot(x, y[:,1])
ax=fig.add_subplot(313)
ax.plot(x, y[:,2])
pl.show()