Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'NDSolve question' topicStudent Support Forum > General > Archives > "NDSolve question"

Help | Reply To Topic
Author Comment/Response
Josh
02/24/05 8:49pm

I have a situation where I have two differential equations that I am looking to solve. One of them is independent, but the other is dependent on the first. I can use NDSolve to find a numerical solution of the first equation, but when I try to construct a command to integrate the two of them simultaneously, it fails and I have no clue why. Hopefully the commands will post correctly, here they are:

1) This integrates fine:
\!\(\*
RowBox[{\(m\ = \ 1;\), "\[IndentingNewLine]", \(M\ = \
100;\), "\[IndentingNewLine]", \(R1\ = \ 1.83;\),
"\[IndentingNewLine]", \(R2\ = \ 0.61;\), "\[IndentingNewLine]", \(r\ \
= \ 0.305;\), "\[IndentingNewLine]", \(g\ = \
9.81;\), "\[IndentingNewLine]",
RowBox[{"positionθ", "=", " ",
RowBox[{"NDSolve", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{
SuperscriptBox["θ", "′′",
MultilineFunction->None], "[", "t", "]"}], "==",
FractionBox[
RowBox[{"2", " ", \(Sin[θ[t]]\), " ",
RowBox[{"(",

RowBox[{\(g\ m\ \((r + R1)\)\), "-", \(g\ M\ R2\), "+",
RowBox[{
"m", " ", \(\((r + R1)\)\^2\), " ", \(Cos[θ[t]]\), " ",
SuperscriptBox[
RowBox[{
SuperscriptBox["θ", "′",

MultilineFunction->None], "[", "t", "]"}],
"2"]}]}], ")"}]}], \(\(-m\)\ \((r +
R1)\)\^2 - 2\ M\ R2\^2 + m\ \((r + R1)\)\^2\
Cos[2\ θ[
t]]\)]}], ",", "
", \(θ[0]\ == \ \((\((1/4)\)\ *\ π)\)\), ",",
RowBox[{
RowBox[{
SuperscriptBox["θ", "′",

MultilineFunction->None], "[",
"0", "]"}], " ", "==", " ", "0"}]}], "}"}], ",", " ", \(θ[
t]\), ",", " ", \({t, \ 0, \ 10}\)}], "]"}]}],
"\[IndentingNewLine]", \(Plot[θ[t]\ /. \
positionθ, \ {t, \ 0, \ 10}];\), "\[IndentingNewLine]",
RowBox[{
RowBox[{"velocityθ", " ", "=", " ",
RowBox[{"NDSolve", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{
SuperscriptBox["θ", "′′",
MultilineFunction->None], "[", "t", "]"}], "==",
FractionBox[
RowBox[{"2", " ", \(Sin[θ[t]]\), " ",
RowBox[{"(",
RowBox[{\(g\ m\ \((r + R1)\)\), "-", \(g\
M\ R2\), "+",
RowBox[{"m", " ", \(\((r + R1)\)\^2\), " ", \(Cos[θ[
t]]\), " ",
SuperscriptBox[
RowBox[{
SuperscriptBox["θ", "′",
MultilineFunction->None], "[", "t", "]"}], "
2"]}]}],
")"}]}], \(\(-m\)\ \((r + R1)\)\^2 - 2\ M\ R2\^2 +
m\ \((r + R1)\)\^2\ Cos[2\ θ[t]]\)]}], ",", "
", \(θ[
0]\ == \ \((\((1/4)\)\ *\ π)\)\), ",", " ",
RowBox[{
RowBox[{
SuperscriptBox["θ", "′",
MultilineFunction->None],
"[", "0", "]"}], " ", "==", " ", "0"}]}],
"}"}], ",", " ",
RowBox[{
SuperscriptBox["θ", "′",
MultilineFunction->None], "[", "t", "]
"}], ",", " ", \({t, \ 0, \ 10}\)}], "]"}]}], ";"}], "\
\[IndentingNewLine]", \(Plot[\(θ'\)[t]\ /. \ velocityθ\ , \ {
t, \ 0, \ 10}];\)}]\)

2) However, when I try to integrate this system of equations where the second equation is dependent on the first, Mathematica 5.1 outputs a message about a singularity being detected, with the graph giving nonsensical results:

\!\(\*
RowBox[{
RowBox[{
RowBox[{"MotionEqs", " ", "=", " ",
RowBox[{"NDSolve", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{
RowBox[{
SuperscriptBox["θ", "′′",
MultilineFunction->None], "[", "t", "]"}], "==",
FractionBox[
RowBox[{"2", " ", \(Sin[θ[t]]\), " ",
RowBox[{"(",

RowBox[{\(g\ m\ \((r + R1)\)\), "-", \(g\ M\ R2\), "+",
RowBox[{"m", "
", \(\((r + R1)\)\^2\), " ", \(Cos[θ[t]]\), " ",
SuperscriptBox[
RowBox[{
SuperscriptBox["θ", "′",

MultilineFunction->None], "[", "t", "]"}], "2"]}]}], ")
"}]}], \(\(-m\)\ \((r + R1)\)\^2 - 2\ M\ R2\^2 + m\ \((
r + R1)\)\^2\ Cos[2\ θ[t]]\)]}], ",",
RowBox[{
RowBox[{
SuperscriptBox["ϕ", "′′",
MultilineFunction->None], "[", "t", "]"}], "==", " ",
FractionBox[
RowBox[{\(Sec[ϕ[t]]\), " ",
RowBox[{"(",
RowBox[{
RowBox[{"R1", " ", \(Sin[θ[t]]\), " ",
SuperscriptBox[
RowBox[{
SuperscriptBox["θ", "′",
MultilineFunction->None], "[", "t", "]"}], "
2"]}], "-",
FractionBox[

RowBox[{"2", " ", "R1", " ", \(Cos[θ[t]]\), "
", \(Sin[θ[t]]\), " ",
RowBox[{"(",
RowBox[{\(g\ m\ \((r + R1)\)\), "-", \(g\ M\
R2\), "+",

RowBox[{"m", " ", \(\((r + R1)\)\^2\), "
", \(Cos[θ[t]]\), " ",
SuperscriptBox[
RowBox[{
SuperscriptBox["θ", "′",
MultilineFunction->
None], "[", "t", "]"}], "2"]}]}],
")"}]}], \(\(-m\)\ \((r + R1)\)\^2 -
2\ M\ R2\^2 + m\ \((r + R1)\)\^2\ Cos[
2\ θ[t]]\)], "+",
RowBox[{"r", " ", \(Sin[ϕ[t]]\), " ",
SuperscriptBox[
RowBox[{
SuperscriptBox["ϕ", "′",
MultilineFunction->None], "[", "t", "]"}], "
2"]}]}], ")"}]}], "r"]}], " ", ",", " ", \(θ[
0]\ == \ \((\((1/4)\)\ *\ π)\)\), ",",
RowBox[{
RowBox[{
SuperscriptBox["θ", "′",

MultilineFunction->None], "[", "0", "]"}],
" ", "==", " ", "0"}], ",", " ", \(ϕ[0]\ == \
0\), ",",
RowBox[{
RowBox[{
SuperscriptBox["ϕ", "′",
MultilineFunction->None], "[", "0", "]"}], " ", "==
", " ", "0"}]}], "}"}], ",", " ", \({ϕ, \ \ θ}\), ",", "
", \({t, \ 0, \ 5}\)}], "]"}]}], ";"}],
"\[IndentingNewLine]", \(Plot[ϕ[t]\ /. \ MotionEqs, \ {t, \ 0, \
5}]\)}]\)

I'm not sure what I'm doing wrong. Any help would be much appreciated.

Thanks!

Josh

URL: ,
Help | Reply To Topic