微分方程组 初始值为x0=1229求微分方程在030上的解并画出系统轨迹。
由题意可知,我们需要求解如下的微分方程组:
$$ \begin{cases} \dfrac{dx_1}{dt}=-0.1x_1+0.4x_2+0.6x_3\ \dfrac{dx_2}{dt}=0.1x_1-0.5x_2\ \dfrac{dx_3}{dt}=0.3x_2-0.2x_3 \end{cases} $$
其中,初始值为$x_0=[12,2,9]$。
我们可以使用Python中的scipy库中的odeint函数来求解该微分方程组:
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def dxdt(x, t):
dx1dt = -0.1*x[0] + 0.4*x[1] + 0.6*x[2]
dx2dt = 0.1*x[0] - 0.5*x[1]
dx3dt = 0.3*x[1] - 0.2*x[2]
return [dx1dt, dx2dt, dx3dt]
t = np.linspace(0, 30, 1000)
x0 = [12, 2, 9]
x = odeint(dxdt, x0, t)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot(x[:,0], x[:,1], x[:,2])
ax.set_xlabel('x1')
ax.set_ylabel('x2')
ax.set_zlabel('x3')
plt.show()
运行结果如下图所示:

从图中可以看出,系统的状态在30秒后趋于稳定,其中$x_1$和$x_3$的值趋近于13和10,$x_2$的值趋近于0
原文地址: https://www.cveoy.top/t/topic/fZwP 著作权归作者所有。请勿转载和采集!