I have four ordinary differential equation written in mathmatica :
Simplify[DSolve[{y1'[x] == -0.162y1[x], y2'[x]=-0.148 y2[x]+ 0.055y1[x],y3'[x]==-0.134 y3[x]+ 0.033y1[x]+ 0.039y2[x],y4'[x]==-0.125y4[x]+0.021 y1[x]+0.025y2[x]+ 0.043y3[x], y1[0] == 100,y2[0]==4.76,y3[0]==69.7,y4[0]==0}, {y1[x], y2[x],y3[x],y4[x]}, x]]
I am trying to write them in python I have try the following :
def n1(y,x):
s1 = 0.162131
dydx = -s1 * y
return dydx
def n2(y,x):
s2 = 0.148234
s12= 0.0555877
dydx2 = -s2 * y + s12 * n1(y,x)
return dydx2
def n3(y,x):
s3 = 0.134337
s13= 0.0333526
s23= 0.0389114
dydx3 = -s3 * y + s13 * n1(y,x) + s23 * n2(y,x)
return dydx3
def n4(y,x):
s4= 0.125072
s14= 0.0213086
s24= 0.0254777
s34= 0.0430805
dydt4 = -s4 * y + s14 * n1(y,x) + s24 * n2(y,x) + s34 * n3(y,x)
return dydt4
## initial conditions
y01 = 100.
y02 = 4.74
y03 = 69.4
y04 = 0.
x = np.linspace(0,20)
sol = odeint(n4,[y01,y02,y03,y04],x)
I want to solve n4 which include n1,n2,n3 , But I am only getting a solution for single equation??? I do not know what is wrong/missing to get the wright solution
Any help I appreciate that!!!