How can I solve a system of ode's?
That's what I've tried:
from sympy import *;
init_printing()
Ex,Ey,Ez,Bx,By,Bz,c,m0,t,u,we,wb,q=symbols('E_x E_y E_z B_x B_y B_z c m_0 t u omega_E omega_B q')
tau=dynamicsymbols('tau')
u0=Function('u^0')(tau)
u1=Function('u^1')(tau)
u2=Function('u^2')(tau)
u3=Function('u^0')(tau)
u=Matrix([u0,u1,u2,u3])
Emat=Matrix([[0,Ex/c,Ey/c,Ez/c],[Ex/c,0,Bz,-By],[Ey/c,-Bz,0,Bx],[Ez/c,By,-Bx,0]])
RHS=q/m0*Emat*u
odesys=[Eq(u0.diff(),RHS[0]),Eq(u1.diff(),RHS[1]),Eq(u2.diff(),RHS[2]),Eq(u3.diff(),RHS[3])]
odesys
dsolve(odesys,[u0(tau),u1(tau),u2(tau),u3(tau)])
Unfortunately it gives me a TypeError:
TypeError Traceback (most recent call last)
<ipython-input-94-f4af1f7e485c> in <module>()
16 odesys=[Eq(u0.diff(),RHS[0]),Eq(u1.diff(),RHS[1]),Eq(u2.diff(),RHS[2]),Eq(u3.diff(),RHS[3])]
17 odesys
---> 18 dsolve(odesys,[u0(t),u1(t),u2(t),u3(t)])
TypeError: 'u^0' object is not callable
I've tried so many things, but I just can't figure out the proper syntax for this to work.
Any ideas?
BTW: It doesn't help if I use dynamicsymbols instead of functions:
...
dsolve(odesys,[u0(tau),u1(tau),u2(tau),u3(tau)])
...
dsolve(odesys,[u0(t),u1(t),u2(t),u3(t)])
-> Same TypeError