Solve matrix differential system and asymptotic solution in mathematica

Click For Summary

Discussion Overview

The discussion revolves around solving a matrix differential equation of the form d/dt(A) = B, where A and B are n by n matrices. Participants explore both analytical and numerical solutions, including obtaining asymptotic solutions as time approaches infinity, and the representation of solutions in matrix form for further computations such as taking partial traces.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant seeks guidance on how to solve the matrix differential equation and obtain asymptotic solutions.
  • Another participant suggests removing MatrixForm from the definition of variables to resolve errors in Mathematica.
  • There is a question about taking limits of multiple solutions collectively rather than individually.
  • Participants discuss the use of the Limit function and the importance of defining variables correctly to avoid errors.
  • One participant expresses a need for references to understand specific Mathematica code components.
  • Another participant recommends starting with simpler expressions for debugging purposes.
  • A participant inquires about modifying code to solve the problem numerically, highlighting the need for initial conditions.
  • There are requests for examples to illustrate numerical and analytical solutions in matrix form.
  • Participants suggest using functions like Partition and dd/.soln to format results in matrix form.

Areas of Agreement / Disagreement

Participants generally agree on the methods to approach the problem, but there are multiple competing views on how to implement solutions in Mathematica, particularly regarding numerical versus analytical methods and the formatting of results.

Contextual Notes

Participants mention limitations related to assumptions about variables, such as positivity, and the need for initial conditions for numerical solutions. There are also unresolved questions about specific Mathematica syntax and functionality.

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

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K