Solve matrix differential system and asymptotic solution in mathematica

In summary, to numerically solve the equation (d/dt)A=B, where A and B are n by n matrices with the initial condition A[0]=C, you can use the NDSolve function. Then, to take the partial trace and plot the resulting matrix elements, you can use the Partition function or dd/.soln. For solving (d/dt)A=B analytically, you can use the Map function and input the results into dd/.soln to obtain the solution in matrix form for further computations.
  • #1
yashar
31
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
  • #2
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.
 
  • #3
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:
  • #4
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.
 
  • #5
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
 
  • #6
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.
 
  • #7
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.
 
  • #8
thanks a lot. that was very useful
 
  • #9
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
 

Related to Solve matrix differential system and asymptotic solution in mathematica

1. How do I input a matrix differential system into Mathematica?

To input a matrix differential system into Mathematica, you can use the DSolve function and specify the system using matrices and vectors. For example, if your system has the form x' = Ax + b, where x is a vector of variables, A is the matrix of coefficients, and b is a vector of constants, you can input it as DSolve[x'[t] == A.x[t] + b, x[t], t].

2. How do I specify initial conditions for a matrix differential system in Mathematica?

To specify initial conditions for a matrix differential system in Mathematica, you can use the DSolve function and include the initial conditions as a list in the third argument. For example, if your system has the form x' = Ax + b and you want to specify the initial condition x(0) = x0, you can input it as DSolve[{x'[t] == A.x[t] + b, x[0] == x0}, x[t], t].

3. How can I solve a matrix differential system numerically in Mathematica?

To solve a matrix differential system numerically in Mathematica, you can use the NDSolve function. This function allows you to specify the system using matrices and vectors, as well as any initial conditions. You can also specify the range of values for the independent variable and the method for numerical integration.

4. What is an asymptotic solution for a matrix differential system?

An asymptotic solution for a matrix differential system is a solution that describes the long-term behavior of the system as the independent variable approaches infinity. It is often used to analyze the stability of a system and can be found by solving for the eigenvalues and eigenvectors of the coefficient matrix.

5. How can I find the asymptotic solution for a matrix differential system in Mathematica?

To find the asymptotic solution for a matrix differential system in Mathematica, you can use the Eigensystem function to find the eigenvalues and eigenvectors of the coefficient matrix. Then, you can use the Exp function to construct the general solution in terms of these eigenvalues and eigenvectors. Finally, you can use the Limit function to find the asymptotic behavior as the independent variable goes to infinity.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
552
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
518
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top