Solving a matrix differential equation in Mathematica

In summary, the conversation discussed solving a differential equation of the form d/dt (R) = B(t), where R and B are complex matrices with time dependent functions as their coefficients. The goal was to solve these 3x3 differential equations and obtain a matrix form for R using DSolve. The conversation also included a discussion on how to modify the code to solve a larger system of equations. Finally, it was suggested to check the structure of the dsolve function before replacing it with DSolve to ensure the problem was correctly set up.
  • #1
Qubix
82
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
  • #2
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:
  • #3
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:
  • #4
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
  • #5
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.
 
  • #6
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:
  • #7
Now it seems to be working. Thank you very much Bill. :)
 

What is a matrix differential equation?

A matrix differential equation is a mathematical equation that involves matrices and their derivatives. It is used to model systems that involve multiple variables and their rates of change over time.

How do I solve a matrix differential equation in Mathematica?

To solve a matrix differential equation in Mathematica, you can use the built-in function DSolve, which takes in the equation and initial conditions as input and gives a solution in terms of a list of functions.

Can Mathematica handle systems of matrix differential equations?

Yes, Mathematica has the capability to solve systems of matrix differential equations using the function NDSolve. This function takes in multiple equations and corresponding initial conditions and gives a numerical solution.

What are the advantages of using Mathematica to solve matrix differential equations?

Mathematica is a powerful computational software that can handle complex equations and provide accurate solutions. It also has a user-friendly interface and can handle large matrices efficiently.

Are there any limitations to using Mathematica for solving matrix differential equations?

One limitation of using Mathematica for solving matrix differential equations is that it can become computationally expensive for large systems of equations. It also requires some knowledge of the software and its syntax to use effectively.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
16
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Linear and Abstract Algebra
Replies
6
Views
485
  • Calculus and Beyond Homework Help
Replies
5
Views
892
  • Engineering and Comp Sci Homework Help
Replies
28
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
7
Views
246
  • STEM Educators and Teaching
Replies
25
Views
2K
Back
Top