scipy - error in solving acoupled,first order differential equations in ipython -
i have following coupled, first order differential equations:
- db(t)/dt=-a*a(t);
- da(t)/dt=b*b(t);
- dj(t)/dt=ca(t)-db(t)
solve system using paramenters = 0.05, b = 0.02, c = 0.03 , d = 0.04 of own choice on time interval 0 200. here code:
a=0.05 b=0.02 c=0.03 d=0.04 def function(x,t): x1, x2, x3 = x[0], x[1], x[2] #x1, x2, x3 = a, b, j dx1=b*x1 dx2=-a*x0 dx3=c*x0-d*x1 return [dx1, dx2, dx3] x0 = [100,100, 1] t = linspace(0, 200, 200) x = odeint(function, x0, t)
the output got is:
--------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' --------------------------------------------------------------------------- typeerror traceback (most recent call last) <ipython-input-11-f8f398346307> in function(x, t) 8 #x1, x2, x3 = a, b, j 9 dx1=b*x1 ---> 10 dx2=-a*x0 11 dx3=c*x0-d*x1 12 return [dx1, dx2, dx3] typeerror: can't multiply sequence non-int of type 'float' repeated convergence failures (perhaps bad jacobian or tolerances). run full_output = 1 quantitative information.
what problem of code?
- you have 3 first-order equations, not second order. (or did mean write second order derivatives in equations 1, 2, , 3?)
deriv
should return 3 values da/dt, db/dt , dj/dt, returns array of length 5.zinit
should contain 3 values: a(0), b(0) , j(0).
Comments
Post a Comment