テキストの画像のようなグラフを作るには初期値ごとに計算が必要です。
import numpy as np
import matplotlib.pyplot as plt
t0, te, dt = 0, 800, 0.05
ts = np.arange(t0, te + dt, dt)
# パラメータ
a = 3.0
b = 1.0
c = 2.0
d = 2.0
e = 1.0
f = 1.0
# 初期値の組のリスト
init = [
(2, 2),
(2, 1.3),
(0.2, 0.5),
(0.2, 0.25)
]
fig, ax = plt.subplots()
for x, y in init:
xs, ys = [], []
for t in ts:
xs.append(x)
ys.append(y)
x += (a - b * xs[-1] - c * ys[-1] ) * xs[-1] * dt
y += (d - e * xs[-1] - f * ys[-1] ) * ys[-1] * dt
print(f"(x, y) = ({x:.3f}, {y:.3f}) ({t:.2f} sec)\r", end=" ")
ax.plot(xs, ys, label=f"(x0, y0) = ({xs[0]:.1f}, {ys[0]:.1f})")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.legend()
plt.show()
Like!