Hello, I’m trying of solve this differential equations and graphing them , but i have this errors, and i dont know what I´m doing wrong, could you help me? it´s a predator-prey dinamics
import numpy as np
import matplotlib.pyplot as plt
from numpy import *
from numpy.random import *
from matplotlib.pyplot import *
from scipy.integrate import odeint
#tasa de crecimiento de las presas
r = 10
#interacciones
a = 1
#tasa de crecimiento de los lobos
c = 2
#mortalidad de los lobos
m = 2
def depre(t,IR):
M = IR[1]
W = IR[2]
dM= r*M-a*W
dW = a*M*c-m*W
dIR = [dM,dW]
return dIR
IR0 = [1000,0,11]
t = np.linspace(0,15,1000)
IR = odeint(depre, IR0, t)
M = IR[: , 0]
W = IR[: ,1]
plt.show()
the errors are:
RuntimeError Traceback (most recent call last)
<ipython-input-2-aa21044ab78e> in <module>
17 x0 = [1000, 0, 100]
18 t = np.linspace(0,15,1000)
---> 19 x = odeint(dep,x0,t)
20
21 M = x[:,0]
~\anaconda3\lib\site-packages\scipy\integrate\odepack.py in odeint(func, y0, t, args, Dfun, col_deriv, full_output, ml, mu, rtol, atol, tcrit, h0, hmax, hmin, ixpr, mxstep, mxhnil, mxordn, mxords, printmessg, tfirst)
239 t = copy(t)
240 y0 = copy(y0)
--> 241 output = _odepack.odeint(func, y0, t, args, Dfun, col_deriv, ml, mu,
242 full_output, rtol, atol, tcrit, h0, hmax, hmin,
243 ixpr, mxstep, mxhnil, mxordn, mxords,
RuntimeError: The size of the array returned by func (2) does not match the size of y0 (3).