Re: Some problems with DSolve and NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg19769] Re: Some problems with DSolve and NDSolve
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Fri, 17 Sep 1999 01:36:33 -0400
- Organization: University of Western Australia
- References: <7rnjb1$ejs@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Chee Lim Cheung wrote: > I was somewhat surprised that DSolve is unable to solve the following > relatively innocuous system of 1st-order ODEs: > > DSolve[{2 i1[t] + 2 (i1'[t] - i2'[t]) == 80 t E^(-2t), 4 i2[t] + 2 (i2'[t] > - i1'[t]) == 0, i1[0] == 0, i2[0] == 0}, {i1[t],i2[t]}, t] > > The normally reliable NDSolve also falls down on the following: > > NDSolve[{2 i1[t] + 2(i1'[t] - i2'[t]) == 80 t E^(-2t), 4 i2[t] + 2(i2'[t] - > i1'[t]) == 0, i1[0] == 0, i2[0] == 0}, {i1[t], i2[t]}, {t, 0, 1}] > > What is wrong? Not sure. Looks like a problem with Solve (not DSolve or NDSolve) failing to correctly reduce the equations to simplest form. Here follows a Notebook which obtains the solution via Eliminate. Notebook[{ Cell["Here are the equations,", "Text"], Cell[BoxData[ FormBox[ RowBox[{ RowBox[{"\[ScriptCapitalE]", "=", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{\(2\ \(\(i\_1\)(t)\)\), "+", RowBox[{"2", " ", RowBox[{"(", RowBox[{ RowBox[{ SubsuperscriptBox["i", "1", "\[Prime]", MultilineFunction->None], "(", "t", ")"}], "-", RowBox[{ SubsuperscriptBox["i", "2", "\[Prime]", MultilineFunction->None], "(", "t", ")"}]}], ")"}]}]}], "==", \(80\ t\ \[ExponentialE]\^\(\(-2\)\ t\)\)}], ",", RowBox[{ RowBox[{\(4\ \(\(i\_2\)(t)\)\), "+", RowBox[{"2", " ", RowBox[{"(", RowBox[{ RowBox[{ SubsuperscriptBox["i", "2", "\[Prime]", MultilineFunction->None], "(", "t", ")"}], "-", RowBox[{ SubsuperscriptBox["i", "1", "\[Prime]", MultilineFunction->None], "(", "t", ")"}]}], ")"}]}]}], "==", "0"}]}], "}"}]}], ";"}], TraditionalForm]], "Input"], Cell["and the initial conditions,", "Text"], Cell[BoxData[ \(TraditionalForm\`\(ic = {\(i\_1\)(0) == 0, \(i\_2\)(0) == 0};\)\)], "Input"], Cell[TextData[{ "We can use ", StyleBox["Eliminate", "Input"], " to determine ", Cell[BoxData[ \(TraditionalForm\`\(i\_2\)(t)\)]], ":" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ FormBox[ RowBox[{"Eliminate", "[", RowBox[{"\[ScriptCapitalE]", ",", RowBox[{ SubsuperscriptBox["i", "2", "\[Prime]", MultilineFunction->None], "(", "t", ")"}]}], "]"}], TraditionalForm]], "Input"], Cell[BoxData[ \(TraditionalForm\`2\ \(\(i\_2\)(t)\) == 40\ \[ExponentialE]\^\(\(-2\)\ t\)\ t - \(i\_1\)(t)\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm\`s\_2 = i\_2 -> Function[t, Evaluate[\(i\_2\)(t) /. First[Solve[%, \(i\_2\)(t)]]]]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`i\_2 -> Function[t, 1\/2\ \((40\ \[ExponentialE]\^\(\(-2\)\ t\)\ t - \(i\_1\)( t))\)]\)], "Output"] }, Open ]], Cell["\<\ Substituting this back into the equations we see that they are \ consistent:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm\`\[ScriptCapitalE] /. % // Simplify\)], "Input"], Cell[BoxData[ FormBox[ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{\(2\ \(\(i\_1\)(t)\)\), "+", RowBox[{"3", " ", RowBox[{ SubsuperscriptBox["i", "1", "\[Prime]", MultilineFunction->None], "(", "t", ")"}]}]}], "==", \(40\ \[ExponentialE]\^\(\(-2\)\ t\)\)}], ",", RowBox[{\(40\ \[ExponentialE]\^\(\(-2\)\ t\)\), "==", RowBox[{\(2\ \(\(i\_1\)(t)\)\), "+", RowBox[{"3", " ", RowBox[{ SubsuperscriptBox["i", "1", "\[Prime]", MultilineFunction->None], "(", "t", ")"}]}]}]}]}], "}"}], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ "Now we can use ", StyleBox["DSolve", "Input"], " to determine ", Cell[BoxData[ \(TraditionalForm\`\(i\_1\)(t)\)]], ":" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm\`DSolve[{First[%], First[ic]}, \(i\_1\)(t), t]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`{{\(i\_1\)( t) -> \[ExponentialE]\^\(\(-2\)\ t\)\ \((\(-10\) + 10\ \[ExponentialE]\^\(\(4\ t\)/3\))\)}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm\`s\_1 = i\_1 -> Function[t, Evaluate[\(i\_1\)(t) /. First[%]]]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`i\_1 -> Function[t, \[ExponentialE]\^\(\(-2\)\ t\)\ \((\(-10\) + 10\ \[ExponentialE]\^\(\(4\ t\)/3\))\)]\)], "Output"] }, Open ]], Cell["\<\ We check to see that both equations and initial conditions are \ satisfied.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm\`Join[\[ScriptCapitalE], ic] //. {s\_1, s\_2} // Simplify\)], "Input"], Cell[BoxData[ \(TraditionalForm\`{True, True, True, True}\)], "Output"] }, Open ]], Cell["Here is a plot of the two solutions:", "Text"], Cell[BoxData[ \(TraditionalForm\`\(Plot[ Evaluate[{\(i\_1\)(t), \(i\_2\)(t)} //. \[InvisibleSpace]{s\_1, s\_2}], {t, 0, 1}, PlotStyle -> {Hue[0], Hue[1\/3]}];\)\)], "Input"], Cell[TextData[{ "Note the use of ", StyleBox["//.", "Input"], " because ", Cell[BoxData[ \(TraditionalForm\`\(i\_2\)(t)\)]], " is expressed in terms of ", Cell[BoxData[ \(TraditionalForm\`\(i\_1\)(t)\)]], "." }], "Text"] } ] ____________________________________________________________________ Paul Abbott Phone: +61-8-9380-2734 Department of Physics Fax: +61-8-9380-1014 The University of Western Australia Nedlands WA 6907 mailto:paul at physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul God IS a weakly left-handed dice player ____________________________________________________________________