Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Solve matrix differential system and asymptotic solution in mathematica

  1. Jul 11, 2011 #1
    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 [Broken]

    thanks
     
    Last edited by a moderator: May 5, 2017
  2. jcsd
  3. Jul 11, 2011 #2

    Dale

    Staff: Mentor

    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.
     
  4. Jul 12, 2011 #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: Jul 12, 2011
  5. Jul 12, 2011 #4

    Dale

    Staff: Mentor

    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.
     
  6. Jul 13, 2011 #5
    thanks
    it works.

    is there any reference for this code?

    Code (Text):
     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
     
  7. Jul 13, 2011 #6

    Dale

    Staff: Mentor

    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 /. in to 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 [[ in to 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.
     
  8. Jul 13, 2011 #7

    Dale

    Staff: Mentor

    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.
     
  9. Jul 13, 2011 #8
    thanks a lot. that was very useful
     
  10. Jul 15, 2011 #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
     
  11. Jul 15, 2011 #10

    Dale

    Staff: Mentor

    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.
     
  12. Jul 15, 2011 #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
     
  13. Jul 15, 2011 #12

    Dale

    Staff: Mentor

    Use the Partition function or dd/.soln
     
  14. Jul 18, 2011 #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
     
  15. Jul 18, 2011 #14

    Dale

    Staff: Mentor

    I will be travelling 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.
     
  16. Jul 20, 2011 #15
    for this problem i use
    Code (Text):
    Map[(#[t] /. (soln[[1]])) &, dd, {2}]
    and it works.

    but still have problem 1
     
  17. Jul 29, 2011 #16
    can anybody help me?
     
  18. Jul 29, 2011 #17

    Dale

    Staff: Mentor

    Use Partition or dd/.soln
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Solve matrix differential system and asymptotic solution in mathematica
Loading...