Solving a matrix differential equation in Mathematica

AI Thread Summary
The discussion focuses on solving a matrix differential equation of the form d/dt(R) = B(t) using Mathematica's DSolve function. The user initially presents a specific example with 3x3 matrices R and B, seeking guidance on how to structure the equations for proper resolution. After some trial and error, they modify their approach to accommodate a more complex system with time-dependent coefficients. They encounter an error indicating that DSolve cannot process the problem as structured, prompting further clarification on verifying the setup before attempting to solve. Ultimately, the user expresses gratitude for the assistance as they work towards a solution.
Qubix
Messages
82
Reaction score
1
I want to solve a differential equation of the form

d/dt (R) = B(t)

where R and B are two complex matrices, with time dependent functions as their coefficients.
I want to solve these 3x3 differential equations (ones on the diagonal are actually coupled) and to obtain a matrix form for R. So I must solve with DSolve , not numerical.

Any ideas?
 
Physics news on Phys.org
See if there are any mistakes in this idea

In[1]:= (*Make up some example data to have a concrete question*)
R = {{y[t], 2 y[t]^2}, {y[t], y[t]/2}};
B = {{-y[t], 4 y[t]}, {y[t], 2 y[t]}};
(*Now do some list hacking to rearrange the bits into the form you desire*)
Map[dsolve[#, y[t], t] &, MapThread[Equal, {Flatten[D[R, t]], Flatten[ B ] }]]

Out[3 ] = {dsolve[y'[t] == -y[t], y[t], t],
dsolve[4 y[t] y'[t] == 4 y[t], y[t], t],
dsolve[y'[t] == y[t], y[t], t],
dsolve[y'[t]/2 == 2 y[t], y[t], t]}

If all that appears to be giving you the equations you expect then you can change the dsolve into DSolve and do the actual calculations. If this isn't correct then provide a more specific simple example and we can work from that.

EDIT: D**n embedded formatting metacharacters had eaten part of the code. I think I've fixed that now. Sorry about that.
 
Last edited:
Thanks Bill, it seems to work. I just have to extend the code you've given to suit something like:

A={{A00,A01,A02},{A10,A11,A12},{A20,A21,A22}}

and

B={{cA11-dA22 , eA01, fA02},{gA10, hA11+jA22, kA12},{lA20,mA21,nA11-oA22}}

where a,b,c,d... are simple coefficients and A00,A01... are the 9 time dependent functions.

So the differential equation is dA/dt = B

The way I modified your code is :

Map[dsolve[#, {A00[t],A01[t],A02[t],A10[t],A11[t],A12[t],A20[t],A21[t],A22[t]}, t] &, MapThread[Equal, {Flatten[D[R, t]], Flatten[ B ] }]]

The error i get is

DSolve::dsmsm: Built-in routines cannot solve this problem. There is an equation that involves none of the dependent variables or there is a dependent variable that does not appear in any equation.
 
Last edited:
Are you trying to do a single DSolve for nine functions? If so then try something like this

R = {{y1[t], 2 y2[t]^2}, {y3[t], y4[t]/2}};
B = {{-y1[t], 4 y2[t]}, {y3[t], 2 y4[t]}};
dsolve[MapThread[Equal, {Flatten[D[R, t]], Flatten[B ]}], {y1[t], y2[t], y3[t], y4[t]}, t]

Or just post what your problem really is and we can get to the answer.
 
  • Like
Likes mariemarie
Hmm, if I use this one, I only get one vector listing all 9 equations, but it does not solve them. The real problem would be too big to write here, that is why I posted just a simple example.
 
Have you inspected the structure of the dsolve[{...},{...},t], verified that it is correct, then replaced dsolve with DSolve and finally found that DSolve cannot solve your system?

Or have you inspected the structure to verify that it is correct, but not then replaced the dsolve with DSolve?

I intentionally wrote dsolve for the example so you would be able to check the structure before DSolve would try to process the arguments without giving you any hint whether the problem was correctly set up first.
 
Last edited:
Now it seems to be working. Thank you very much Bill. :)
 

Similar threads

Back
Top