I'm kinda new to python and I need to draw the phase portrait of this system of equations:
x˙ = x(3 − 2x − y)
y˙ = y(2 − x − y)
I solved the system with the odeint
function and tried to plot the phase portrait using the 4 fixed points, but end up with a different plot.
Here's the code I wrote so far:
# function for the ODE
def f(u, t):
x, y = u
dxdt = x * (3 - 2*x - y)
dydt = y * (2 - x - y)
return np.array([dxdt, dydt])
#those are my fixed points + 0.01
values = np.array([[0.01,0.01], [0.01,2.01], [1.51, 0.01], [1.01,1.01])
t = np.linspace(0, 15, 1000)
for v in values:
X0 = [v[0], v[1]]
X = odeint(f, X0, t)
plt.plot(X[:,0], X[:,1], color="black")
plt.ylabel("Sheeps")
plt.xlabel("Rabbits")
plt.legend(loc="upper right")
plt.show()
I should get something like this:
but I'm not. Can anyone help?