MathGroup Archive 2001

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

Search the Archive

*** nonlinear system of ODE + Runge Kutta ?!!!! ***

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26658] *** nonlinear system of ODE + Runge Kutta ?!!!! ***
  • From: suvad at tfh-berlin.de (Suvad Sahovic)
  • Date: Wed, 17 Jan 2001 00:47:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
I have some problems with my nonlinear system. 
It was everything OK til Runge-Kutta, I don´t know how to solve it?
With NDSolve it wasn't problems, but how to solve it with Runge
Kutta??
Please, help me.
Thanks a lot.


That´s the NB.



\!\(y\_tt = \ \[PartialD]\_\(t, t\)\((A[t] x[t])\)\)
\!\(\*
  RowBox[{
    RowBox[{"2", " ", 
      RowBox[{
        SuperscriptBox["A", "\[Prime]",
          MultilineFunction->None], "[", "t", "]"}], " ", 
      RowBox[{
        SuperscriptBox["x", "\[Prime]",
          MultilineFunction->None], "[", "t", "]"}]}], "+", 
    RowBox[{\(x[t]\), " ", 
      RowBox[{
        SuperscriptBox["A", "\[DoublePrime]",
          MultilineFunction->None], "[", "t", "]"}]}], "+", 
    RowBox[{\(A[t]\), " ", 
      RowBox[{
        SuperscriptBox["x", "\[DoublePrime]",
          MultilineFunction->None], "[", "t", "]"}]}]}]\)
\!\(y\_tt\  = %\  /. \ \ {\(\(A'\)'\)[t]\  \[Rule] \ \(-A[t]\)}\)
\!\(\*
  RowBox[{\(\(-A[t]\)\ x[t]\), "+", 
    RowBox[{"2", " ", 
      RowBox[{
        SuperscriptBox["A", "\[Prime]",
          MultilineFunction->None], "[", "t", "]"}], " ", 
      RowBox[{
        SuperscriptBox["x", "\[Prime]",
          MultilineFunction->None], "[", "t", "]"}]}], "+", 
    RowBox[{\(A[t]\), " ", 
      RowBox[{
        SuperscriptBox["x", "\[DoublePrime]",
          MultilineFunction->None], "[", "t", "]"}]}]}]\)
\!\(\(gl1\  = \n\ 
    \(\(y'\)'\)[t]\  == \ 
      \(-\(\(\[Mu]\ \((y[t] - \ b\_1)\)\)\/\((D\_2)\)\^3\)\) - 
        \(\[Mu]'\ \((y[t] - \ b\_2)\)\)\/\((D\_1)\)\^3; \)\)
\!\(gl2\ \  = 
    \ %\  /. \ {y[t] \[Rule] A[t]\ x[t], \ \(\(y'\)'\)[t] \[Rule]
y\_tt, \n
        \t\t\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ \ \ 
        b\_1 \[Rule] A[t]\ a\_1, \ \ b\_2 \[Rule] A[t] a\_2\ }\)
\!\(\*
  RowBox[{
    RowBox[{\(\(-A[t]\)\ x[t]\), "+", 
      RowBox[{"2", " ", 
        RowBox[{
          SuperscriptBox["A", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}], " ", 
        RowBox[{
          SuperscriptBox["x", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}]}], "+", 
      RowBox[{\(A[t]\), " ", 
        RowBox[{
          SuperscriptBox["x", "\[DoublePrime]",
            MultilineFunction->None], "[", "t", "]"}]}]}], "==", 
    RowBox[{
    \(-\(\(\[Mu]\ \((\(-A[t]\)\ a\_1 + A[t]\ x[t])\)\)\/D\_2\%3\)\),
"-", 
      FractionBox[
        RowBox[{\((\(-A[t]\)\ a\_2 + A[t]\ x[t])\), " ", 
          SuperscriptBox["\[Mu]", "\[Prime]",
            MultilineFunction->None]}], \(D\_1\%3\)]}]}]\)
Map[Simplify,Map[ ((1/A[t])#)&, gl2]] /.
	      {A[t] \[Rule] 1/Inverse[A[t]]}
\!\(\*
  RowBox[{
    RowBox[{\(-x[t]\), "+", 
      RowBox[{"2", " ", \(Inverse[A[t]]\), " ", 
        RowBox[{
          SuperscriptBox["A", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}], " ", 
        RowBox[{
          SuperscriptBox["x", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}]}], "+", 
      RowBox[{
        SuperscriptBox["x", "\[DoublePrime]",
          MultilineFunction->None], "[", "t", "]"}]}], "==", 
    RowBox[{
    \(\(\[Mu]\ a\_1\)\/D\_2\%3\), "-", \(\(\[Mu]\ x[t]\)\/D\_2\%3\),
"+", 
      FractionBox[
        RowBox[{\((a\_2 - x[t])\), " ", 
          SuperscriptBox["\[Mu]", "\[Prime]",
            MultilineFunction->None]}], \(D\_1\%3\)]}]}]\)
\!\(\(\ Map[\((\ Collect[#, {D\_2, D\_1}])\)&, %]\)\)
\!\(\*
  RowBox[{
    RowBox[{\(-x[t]\), "+", 
      RowBox[{"2", " ", \(Inverse[A[t]]\), " ", 
        RowBox[{
          SuperscriptBox["A", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}], " ", 
        RowBox[{
          SuperscriptBox["x", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}]}], "+", 
      RowBox[{
        SuperscriptBox["x", "\[DoublePrime]",
          MultilineFunction->None], "[", "t", "]"}]}], "==", 
    RowBox[{\(\(\[Mu]\ a\_1 - \[Mu]\ x[t]\)\/D\_2\%3\), "+", 
      FractionBox[
        RowBox[{\((a\_2 - x[t])\), " ", 
          SuperscriptBox["\[Mu]", "\[Prime]",
            MultilineFunction->None]}], \(D\_1\%3\)]}]}]\)
gl3 = Map[( Collect[#,{\[Mu],\[Mu]'}])&,%,{3}]
\!\(\*
  RowBox[{
    RowBox[{\(-x[t]\), "+", 
      RowBox[{"2", " ", \(Inverse[A[t]]\), " ", 
        RowBox[{
          SuperscriptBox["A", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}], " ", 
        RowBox[{
          SuperscriptBox["x", "\[Prime]",
            MultilineFunction->None], "[", "t", "]"}]}], "+", 
      RowBox[{
        SuperscriptBox["x", "\[DoublePrime]",
          MultilineFunction->None], "[", "t", "]"}]}], "==", 
    RowBox[{\(\(\[Mu]\ \((a\_1 - x[t])\)\)\/D\_2\%3\), "+", 
      FractionBox[
        RowBox[{\((a\_2 - x[t])\), " ", 
          SuperscriptBox["\[Mu]", "\[Prime]",
            MultilineFunction->None]}], \(D\_1\%3\)]}]}]\)
\!\(\*
  RowBox[{
    RowBox[{\(A[t_]\), " ", "=", "  ", 
      RowBox[{"(", GridBox[{
            {\(Cos[t]\), \(-Sin[t]\)},
            {\(Sin[t]\), \(Cos[t]\)}
            }], ")"}]}], ";"}]\)
\!\(Simplify[Inverse[A[t]].\[PartialD]\_t\ A[t]]\)
{{0,-1},{1,0}}
\!\(\*
  RowBox[{
    RowBox[{\(x[t_]\), "=", " ", 
      RowBox[{"(", "\[NegativeThinSpace]", GridBox[{
            {\(x\_1[t]\)},
            {\(x\_2[t]\)}
            }], "\[NegativeThinSpace]", ")"}]}], ";", "   ", 
    RowBox[{\(a\_1\), " ", "=", " ", 
      RowBox[{"(", "\[NegativeThinSpace]", GridBox[{
            {\(\[Mu]'\)},
            {"0"}
            }], "\[NegativeThinSpace]", ")"}]}], ";", "  ", 
    RowBox[{\(a\_2\), " ", "=", " ", 
      RowBox[{"(", "\[NegativeThinSpace]", GridBox[{
            {\(-\[Mu]\)},
            {"0"}
            }], "\[NegativeThinSpace]", ")"}]}], ";"}]\)
\!\(\*
  RowBox[{"gl4", " ", "=", " ", "\n", "\t", 
    RowBox[{
      RowBox[{\(-x[t]\), " ", "+", 
        RowBox[{"2", " ", 
          RowBox[{
            RowBox[{"(", GridBox[{
                  {"0", \(-1\)},
                  {"1", "0"}
                  }], ")"}], ".", \(\(x'\)[t]\)}]}], " ", "+", " ", 
        \(\(\(x'\)'\)[t]\)}], " ", "==", " ", \(Last[gl3]\)}]}]\)
\!\(\*
  RowBox[{
    RowBox[{"{", 
      RowBox[{
        RowBox[{"{", 
          RowBox[{\(-x\_1[t]\), "-", 
            RowBox[{"2", " ", 
              RowBox[{
                SubsuperscriptBox["x", "2", "\[Prime]",
                  MultilineFunction->None], "[", "t", "]"}]}], "+", 
            RowBox[{
              SubsuperscriptBox["x", "1", "\[DoublePrime]",
                MultilineFunction->None], "[", "t", "]"}]}], "}"}],
",", 
        RowBox[{"{", 
          RowBox[{\(-x\_2[t]\), "+", 
            RowBox[{"2", " ", 
              RowBox[{
                SubsuperscriptBox["x", "1", "\[Prime]",
                  MultilineFunction->None], "[", "t", "]"}]}], "+", 
            RowBox[{
              SubsuperscriptBox["x", "2", "\[DoublePrime]",
                MultilineFunction->None], "[", "t", "]"}]}], "}"}]}],
"}"}], 
    "==", 
    RowBox[{"{", 
      RowBox[{
        RowBox[{"{", 
          RowBox[{
            FractionBox[
              RowBox[{
                SuperscriptBox["\[Mu]", "\[Prime]",
                  MultilineFunction->None], " ", \((\(-\[Mu]\) -
x\_1[t])\)}],
               \(D\_1\%3\)], "+", 
            FractionBox[
              RowBox[{"\[Mu]", " ", 
                RowBox[{"(", 
                  RowBox[{
                    SuperscriptBox["\[Mu]", "\[Prime]",
                      MultilineFunction->None], "-", \(x\_1[t]\)}],
")"}]}], 
              \(D\_2\%3\)]}], "}"}], ",", 
        RowBox[{"{", 
          RowBox[{\(-\(\(\[Mu]\ x\_2[t]\)\/D\_2\%3\)\), "-", 
            FractionBox[
              RowBox[{
                SuperscriptBox["\[Mu]", "\[Prime]",
                  MultilineFunction->None], " ", \(x\_2[t]\)}], 
              \(D\_1\%3\)]}], "}"}]}], "}"}]}]\)
\!\(\(\ ode\  = \n\t\ 
    Table[\(\(x\_i'\)'\)[t]\  == \ \ 
        First[\((
            \(\(x\_i'\)'\)[t]\  /. 
              Solve[\ gl4[\([1, i, 1]\)] == \ gl4[\([2, i, 1]\)], \n
                \t\t\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
                \(\(x\_i'\)'\)[t]\ ])\)], \ {i, 1, 2}]\)\)
\!\(\*
  RowBox[{"{", 
    RowBox[{
      RowBox[{
        RowBox[{
          SubsuperscriptBox["x", "1", "\[DoublePrime]",
            MultilineFunction->None], "[", "t", "]"}], "==", 
        RowBox[{
          FractionBox[
            RowBox[{
              SuperscriptBox["\[Mu]", "\[Prime]",
                MultilineFunction->None], " ", \((\(-\[Mu]\) -
x\_1[t])\)}], 
            \(D\_1\%3\)], "+", 
          FractionBox[
            RowBox[{"\[Mu]", " ", 
              RowBox[{"(", 
                RowBox[{
                  SuperscriptBox["\[Mu]", "\[Prime]",
                    MultilineFunction->None], "-", \(x\_1[t]\)}],
")"}]}], 
            \(D\_2\%3\)], "+", \(x\_1[t]\), "+", 
          RowBox[{"2", " ", 
            RowBox[{
              SubsuperscriptBox["x", "2", "\[Prime]",
                MultilineFunction->None], "[", "t", "]"}]}]}]}], ",", 
      RowBox[{
        RowBox[{
          SubsuperscriptBox["x", "2", "\[DoublePrime]",
            MultilineFunction->None], "[", "t", "]"}], "==", 
        RowBox[{\(x\_2[t]\), "-", \(\(\[Mu]\ x\_2[t]\)\/D\_2\%3\),
"-", 
          FractionBox[
            RowBox[{
              SuperscriptBox["\[Mu]", "\[Prime]",
                MultilineFunction->None], " ", \(x\_2[t]\)}],
\(D\_1\%3\)], 
          "-", 
          RowBox[{"2", " ", 
            RowBox[{
              SubsuperscriptBox["x", "1", "\[Prime]",
                MultilineFunction->None], "[", "t", "]"}]}]}]}]}],
"}"}]\)
\!\(Clear[x, y]\n
  x\_1[t_]\  = x[t]; \ \nx\_2[t_]\  = y[t]; \)
ode
\!\(\*
  RowBox[{"{", 
    RowBox[{
      RowBox[{
        RowBox[{
          SuperscriptBox["x", "\[DoublePrime]",
            MultilineFunction->None], "[", "t", "]"}], "==", 
        RowBox[{\(x[t]\), "+", 
          FractionBox[
            RowBox[{\((\(-\[Mu]\) - x[t])\), " ", 
              SuperscriptBox["\[Mu]", "\[Prime]",
                MultilineFunction->None]}], \(D\_1\%3\)], "+", 
          FractionBox[
            RowBox[{"\[Mu]", " ", 
              RowBox[{"(", 
                RowBox[{\(-x[t]\), "+", 
                  SuperscriptBox["\[Mu]", "\[Prime]",
                    MultilineFunction->None]}], ")"}]}], \(D\_2\%3\)],
"+", 
          RowBox[{"2", " ", 
            RowBox[{
              SuperscriptBox["y", "\[Prime]",
                MultilineFunction->None], "[", "t", "]"}]}]}]}], ",", 
      RowBox[{
        RowBox[{
          SuperscriptBox["y", "\[DoublePrime]",
            MultilineFunction->None], "[", "t", "]"}], "==", 
        RowBox[{\(y[t]\), "-", \(\(\[Mu]\ y[t]\)\/D\_2\%3\), "-", 
          FractionBox[
            RowBox[{\(y[t]\), " ", 
              SuperscriptBox["\[Mu]", "\[Prime]",
                MultilineFunction->None]}], \(D\_1\%3\)], "-", 
          RowBox[{"2", " ", 
            RowBox[{
              SuperscriptBox["x", "\[Prime]",
                MultilineFunction->None], "[", "t", "]"}]}]}]}]}],
"}"}]\)
\!\(\(D\_1 = \@\(\((x[t] + \[Mu])\)\^2\  + \ y[t]\^2\)\ ; \ \ 
   (*\ Entfernung\ zur\ Erde\ *) \n
  D\_2 = \@\(\((x[t] - \[Mu]')\)\^2\  + \ y[t]\^2\); \ \ 
   (*\ Entfernung\ zum\ Mond\ *) \)\)
\[Mu]=0.012277471;  (* Masse vom Mond *)
\[Mu]'=1-\[Mu];  (* Masse der Erde *)
ode
\!\(\*
  RowBox[{"{", 
    RowBox[{
      RowBox[{
        RowBox[{
          SuperscriptBox["x", "\[DoublePrime]",
            MultilineFunction->None], "[", "t", "]"}], "==", 
        RowBox[{\(x[t]\), "+", 
          FractionBox[
            RowBox[{
              StyleBox["0.0122774709999999998`",
                StyleBoxAutoDelete->True,
                PrintPrecision->8], " ", 
              \((\(0.987722529000000015`\[InvisibleSpace]\) -
x[t])\)}], 
            \(\((\((\(-0.987722529000000015`\) + x[t])\)\^2 +
y[t]\^2)\)\^\(3/
                  2\)\)], "+", 
          
          FractionBox[
            \(0.987722529000000015`\ 
              \((\(-0.0122774709999999998`\) - x[t])\)\), 
            SuperscriptBox[
              RowBox[{"(", 
                RowBox[{
                  SuperscriptBox[
                    RowBox[{"(", 
                      RowBox[{
                        RowBox[{
                          StyleBox["0.0122774709999999998`",
                            StyleBoxAutoDelete->True,
                            PrintPrecision->8], "\[InvisibleSpace]"}],
"+", 
                        \(x[t]\)}], ")"}], "2"], "+", \(y[t]\^2\)}],
")"}], 
              \(3/2\)]], "+", 
          RowBox[{"2", " ", 
            RowBox[{
              SuperscriptBox["y", "\[Prime]",
                MultilineFunction->None], "[", "t", "]"}]}]}]}], ",", 
      RowBox[{
        RowBox[{
          SuperscriptBox["y", "\[DoublePrime]",
            MultilineFunction->None], "[", "t", "]"}], "==", 
        RowBox[{
        \(y[t]\), "-", 
          \(\(0.0122774709999999998`\ 
                y[t]\)\/\((
                  \((\(-0.987722529000000015`\) + x[t])\)\^2 +
y[t]\^2)
                  \)\^\(3/2\)\), "-", 
          FractionBox[\(0.987722529000000015`\ y[t]\), 
            SuperscriptBox[
              RowBox[{"(", 
                RowBox[{
                  SuperscriptBox[
                    RowBox[{"(", 
                      RowBox[{
                        RowBox[{
                          StyleBox["0.0122774709999999998`",
                            StyleBoxAutoDelete->True,
                            PrintPrecision->8], "\[InvisibleSpace]"}],
"+", 
                        \(x[t]\)}], ")"}], "2"], "+", \(y[t]\^2\)}],
")"}], 
              \(3/2\)]], "-", 
          RowBox[{"2", " ", 
            RowBox[{
              SuperscriptBox["x", "\[Prime]",
                MultilineFunction->None], "[", "t", "]"}]}]}]}]}],
"}"}]\)
init2 = {x[0] ==0.994, y[0] == 0,
		                  x'[0] == 0,
y'[0]==-2.00158510637908252240537862224};
t2 =17.0652165601579625588917206249;
ode2 = ode\[Union]init2;
soln2=NDSolve[ ode2, {x,y}, {t,0,t2}]
{{x\[Rule]InterpolatingFunction[{{0.,17.0652}},"<>"],
    y\[Rule]InterpolatingFunction[{{0.,17.0652}},"<>"]}}


  • Prev by Date: Re: Partial Differential Equation
  • Next by Date: Shortcut for magnitude of a Vector?
  • Previous by thread: Re: Infinite loop while generating gcc.1
  • Next by thread: Shortcut for magnitude of a Vector?