Solving a matrix differential equation in Mathematica

Click For Summary

Discussion Overview

The discussion revolves around solving a matrix differential equation of the form d/dt (R) = B(t) using Mathematica. Participants explore methods to apply DSolve for complex matrices with time-dependent coefficients, focusing on a specific example involving 3x3 matrices.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant seeks guidance on solving a matrix differential equation with time-dependent complex matrices using DSolve.
  • Another participant proposes a method involving example matrices and suggests using list manipulation to rearrange the equations for DSolve.
  • A later reply indicates a modification to the proposed code to accommodate a more complex matrix structure, but encounters an error related to the dependent variables.
  • Further suggestions include checking the structure of the DSolve arguments to ensure correctness before attempting to solve the equations.
  • Ultimately, one participant reports success after following the advice given, but the specifics of the original problem remain unspecified.

Areas of Agreement / Disagreement

Participants generally agree on the approach to use DSolve for solving the matrix differential equations, but there are differing opinions on the correct structure and implementation of the code, leading to unresolved issues in some cases.

Contextual Notes

Some participants express uncertainty about the structure of the equations and the conditions under which DSolve can be applied, indicating potential limitations in the examples provided.

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   Reactions: 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

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 28 ·
Replies
28
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K