MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: DSolve and matrix form of system of equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61304] Re: [mg61294] DSolve and matrix form of system of equations
  • From: Pratik Desai <pdesai1 at umbc.edu>
  • Date: Fri, 14 Oct 2005 22:22:34 -0400 (EDT)
  • References: <200510140956.FAA28648@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Matt wrote:

>Hello,
>  I've been generally taking the 2 dimensional systems of differential
>equations that I've been working with and typing them out explicitly
>(e.g. x'[t] == x[t] + 2 y[t], y'[t] == -2 x[t] + y[t]), but tonight I
>decided to enter them into Mathematica in the matrix form:
>
>Cell[BoxData[
>    RowBox[{
>      RowBox[{"eqn", " ", "=", " ",
>        RowBox[{
>          RowBox[{"(", GridBox[{
>                {
>                  RowBox[{
>                    RowBox[{"x", "'"}], "[", "t", "]"}]},
>                {
>                  RowBox[{
>                    RowBox[{"y", "'"}], "[", "t", "]"}]}
>                }], ")"}], "\[Equal]",
>          RowBox[{
>            RowBox[{"(", GridBox[{
>                  {"a",
>                    RowBox[{
>                      SqrtBox["2"], " ", "+", " ",
>                      RowBox[{"a", "/", "2"}]}]},
>                  {
>                    RowBox[{
>                      SqrtBox["2"], " ", "-", " ",
>                      RowBox[{"a", "/", "2"}]}], "0"}
>                  }], ")"}], ".",
>            RowBox[{"(", GridBox[{
>                  {
>                    RowBox[{"x", "[", "t", "]"}]},
>                  {
>                    RowBox[{"y", "[", "t", "]"}]}
>                  }], ")"}]}]}]}], ";"}]], "Input"]
>
>and I was wondering what would be the preferred/efficient method of
>getting the actual equations back out of the expression denoted by
>'eqn' above?
>
>What I did was this:
>
>Cell[BoxData[
>    RowBox[{"sols", " ", "=", " ",
>      RowBox[{"Table", "[",
>        RowBox[{
>          RowBox[{"DSolve", "[",
>            RowBox[{
>              RowBox[{"{",
>                RowBox[{
>                  RowBox[{
>                    RowBox[{
>                      RowBox[{"eqn", "[",
>                        RowBox[{"[",
>                          RowBox[{"1", ",", "1"}], "]"}], "]"}], "[",
>
>                      RowBox[{"[", "1", "]"}], "]"}], " ", "\[Equal]",
>                     " ",
>                    RowBox[{
>                      RowBox[{"eqn", "[",
>                        RowBox[{"[",
>                          RowBox[{"2", ",", "1"}], "]"}], "]"}], "[",
>
>                      RowBox[{"[", "1", "]"}], "]"}]}], ",",
>                  RowBox[{
>                    RowBox[{
>                      RowBox[{"eqn", "[",
>                        RowBox[{"[",
>                          RowBox[{"1", ",", "2"}], "]"}], "]"}], "[",
>
>                      RowBox[{"[", "1", "]"}], "]"}], " ", "\[Equal]",
>                     " ",
>                    RowBox[{
>                      RowBox[{"eqn", "[",
>                        RowBox[{"[",
>                          RowBox[{"2", ",", "2"}], "]"}], "]"}], "[",
>
>                      RowBox[{"[", "1", "]"}], "]"}]}]}], "}"}], ",",
>              " ",
>              RowBox[{"{",
>                RowBox[{
>                  RowBox[{"x", "[", "t", "]"}], ",",
>                  RowBox[{"y", "[", "t", "]"}]}], "}"}], ",", "t"}],
>            "]"}], ",",
>          RowBox[{"{",
>            RowBox[{"a", ",",
>              RowBox[{"-", "2"}], ",", "2"}], "}"}]}],
>        "]"}]}]], "Input"]
>
>which worked for me, but again, I'm sure there's a better or more
>elegant Mathematica way to get the equations back out of 'eqn'.
>
>Thanks for any insight,
>
>Matt
>
>  
>
Maybe something like this
Cell[BoxData[{
    RowBox[{"Clear", "[",
      RowBox[{"x", ",", "y", ",", "A"}], "]"}], "\[IndentingNewLine]",
  
    RowBox[{"A", "=",
      RowBox[{"(", GridBox[{
            {"a",
              RowBox[{
                SqrtBox["2"], " ", "+", " ",
                RowBox[{"a", "/", "2"}]}]},
            {
              RowBox[{
                SqrtBox["2"], " ", "-", " ",
                RowBox[{"a", "/", "2"}]}], "0"}
            }], ")"}]}], "\[IndentingNewLine]",
    RowBox[{
      RowBox[{"z", "[", "t_", "]"}], "=",
      RowBox[{"{",
        RowBox[{
          RowBox[{"x", "[", "t", "]"}], ",",
          RowBox[{"y", "[", "t", "]"}]}],
        "}"}]}], "\[IndentingNewLine]",
    RowBox[{"Thread", "[",
      RowBox[{
        RowBox[{"{",
          RowBox[{
            RowBox[{
              RowBox[{"x", "'"}], "[", "t", "]"}], ",",
            RowBox[{
              RowBox[{"y", "'"}], "[", "t", "]"}]}], "}"}], "==",
        RowBox[{"A", ".",
          RowBox[{"z", "[", "t", "]"}]}]}], "]"}]}], "Input"]

Hope this helps

Pratik   .

-- 
Pratik Desai
Graduate Student
UMBC
Department of Mechanical Engineering
Phone: 410 455 8134



  • Prev by Date: Re: Language vs. Library
  • Next by Date: Re: challenge problem
  • Previous by thread: Re: DSolve and matrix form of system of equations
  • Next by thread: Re: DSolve and matrix form of system of equations