Mathematica Solve matrix differential system and asymptotic solution in mathematica

AI Thread Summary
The discussion revolves around solving the matrix differential equation d/dt(A) = B, where A and B are n by n matrices, and obtaining both analytical and numerical solutions. Key points include troubleshooting errors in Mathematica related to matrix definitions and assumptions, particularly ensuring variables are defined correctly. Users seek guidance on taking limits of multiple solutions collectively and obtaining results in matrix form for further computations, such as taking partial traces. The conversation emphasizes the importance of understanding Mathematica functions like Map, ReplaceAll, and Partition for manipulating solutions. For numerical solutions, the use of NDSolve is recommended, along with the necessity of specifying initial conditions. Participants share methods for transforming results into matrix form and suggest consulting Mathematica's online documentation for further learning.
yashar
Messages
31
Reaction score
0
hi
i want to solve equation d/dt(A)=B which A and B are n by n matrices. the matrices variable is t which is time.

1-how i can solve this equation?


2-how i can obtain asymptotic solution for time=infinite?

i use some help of this topic but i get error in mathematica.
https://www.physicsforums.com/showthread.php?t=512194

3-from what reference you obtain the right code? because i could not find the solution in mathematica documentation.

here is the mathematica file which i write the code within it.
http://www.mediafire.com/file/xk7k6ov74b999he/00.nb

thanks
 
Last edited by a moderator:
Physics news on Phys.org
1) Remove MatrixForm from your definition of p. It should work then.
2) Use the Limit function as t->Infinity.
3) The problem was an error in your code. There isn't any documentation for that. At each step you need to check that your variables are defined correctly. The error message was that you didn't have a valid equation. That should have tipped you off that either d'[t] or p was incorrect.
 
i manage to take limit .error was for lack of some assumptions on variables like positivity and ...

but i now have another question how i take limit from all 16 solution of the equation as a whole . without taking limit individually?

1-is there any method to take limit from all 16 solutions of the equation?
2-how can i have solutions of the equation in matrix form. i mean how solution of equation (d/dt)A=B which is A (a matrix) can be obtain in matrix form.
 
Last edited:
Try Limit[Map[(#[t] /. (soln[[1]])) &, dd, {2}], t -> Infinity] but of course you will have to add the positivity and other assumptions in also.
 
thanks
it works.

is there any reference for this code?

Code:
 Limit[Map[(#[t] /. (soln[[1]])) &, dd, {2}], t -> Infinity]

i want to understand the job of any part of it. like #[t] and /. and (soln[[1]]) and (soln[[1]]) and dd (which is the solution of equation) and {2} (why it is 2 not for example 4?!)

thanks again
 
Sure, every bit of my knowledge of Mathematica comes from reading the online documentation, which is very good. I almost never open Mathematica without hitting F1 at some point.

If you type # into the help browser you are brought to the entry on Slot which describes the usage of # in pure functions and has a direct link to the tutorial on pure functions. The tutorial even begins with an example using Map. I highly recommend reading it since pure functions in Mathematica fill the role of lambda functions in many other languages and are therefore very useful.

If you type /. into the help browser you are brought to the ReplaceAll entry, which explains how to use a list of rules to change an expression. Again, there is a link to a good tutorial on transformation rules.

If you type [[ into the help browser you are brought to the Part entry which explains how to access elements of a list. This is such a central part of the language that there are a bunch of tutorials. Most of which I have read at one time or another.

For {2}, that is an argument to Map, so if you type Map into the help browser you are given information on all of the arguments and examples. And, of course, useful links to good tutorials.
 
One other recommendation. When you are coding a project, start simple with things that you know the answer. E.g. your definition of p is what you want to know, but it is way too complicated for you to test and debug your code.

You should start with a simpler expression for p which you know the answer. Then develop and test your code at each step using that simple p until you get the answer that you know to be correct. Only then, once you know your code is good, run it on the complicated p.
 
thanks a lot. that was very useful
 
hi
how i modify below codes to solve problem numerically?
n = 4;
d[t_] = Array[Subscript[w, ##][t] &, {n, n}];
dd = Array[Subscript[w, ##] &, {n, n}];
soln = DSolve[LogicalExpand[d'[t] == p], Flatten@dd, t]

thanks
 
  • #10
To solve it numerically you will need to use NDSolve. However, in order to use NDSolve will require a little more information than you have given above. Specifically, you will also need to provide the initial conditions and the initial time and the final time.
 
  • #11
hi
suppose initial condition is d[0]=IdentityMatrix[4] and initial time =0 and final time 11.

and another question:
when i use
n = 4;
d[t_] = Array[Subscript[w, ##][t] &, {n, n}];
dd = Array[Subscript[w, ##] &, {n, n}];
soln = DSolve[LogicalExpand[d'[t] == p], Flatten@dd, t]

the results are not in matrix form. i need the results in matrix form to take partial trace from them. how can i cast the results automatically in matrix form
 
  • #12
Use the Partition function or dd/.soln
 
  • #13
hi i do not understand what you mean.

can you write an example for this two problem?

1-Numerically solving equation (d/dt)A=B . which A and B are n by n matrices with some initial condition for example A[0]=C.
after solving numerically i need to take partial trace and plot the resulting matrix elements. so solution of this equation {(d/dt)A=B} must be in matrix form.

2-for solving (d/dt)A=B analytically how i can obtain the result in matrix form for further computations like taking partial trace.

thank you very much
 
  • #14
I will be traveling until Thursday. Have you looked at the online help for NDSolve and Partition? They should each have examples showing how to do it for similar problems.
 
  • #15
yashar said:
2-for solving (d/dt)A=B analytically how i can obtain the result in matrix form for further computations like taking partial trace.

for this problem i use
Code:
Map[(#[t] /. (soln[[1]])) &, dd, {2}]

and it works.

but still have problem 1
 
  • #16
yashar said:
can you write an example for this problem?

1-Numerically solving equation (d/dt)A=B . which A and B are n by n matrices with some initial condition for example A[0]=C.
after solving numerically i need to take partial trace and plot the resulting matrix elements. so solution of this equation {(d/dt)A=B} must be in matrix form.

thank you very much

can anybody help me?
 
  • #17
Use Partition or dd/.soln
 

Similar threads

Back
Top