(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 9519, 344] NotebookOptionsPosition[ 8508, 307] NotebookOutlinePosition[ 8846, 322] CellTagsIndexPosition[ 8803, 319] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Weekly Exercises (2)", "Title"], Cell["\<\ Assigned: January 29, 2009 Due: before class on February 5, 2009\ \>", "Subsubtitle", CellChangeTimes->{{3.4422553649545813`*^9, 3.442255378095483*^9}, 3.4422555663358297`*^9}], Cell[CellGroupData[{ Cell["Verlet's Method (in-class)", "Subsection"], Cell[TextData[{ "Verlet's method uses a central-difference for the second-derivative of \ \[Theta]:\n\t", Cell[BoxData[ FormBox[ RowBox[{ SubscriptBox["\[PartialD]", "t"], " ", RowBox[{ SubscriptBox["\[PartialD]", "t"], " ", "\[Theta]"}]}], TraditionalForm]]], " = - (", StyleBox["g/L", FontSlant->"Italic"], ") Sin[\[Theta]] , or approximately as:\n\t", Cell[BoxData[ FormBox[ StyleBox[ FractionBox[ RowBox[{ RowBox[{"\[Theta]", "[", RowBox[{"t", "-", "\[Delta]t"}], "]"}], " ", "-", " ", RowBox[{"2", RowBox[{"\[Theta]", "[", "t", "]"}]}], " ", "+", " ", RowBox[{"\[Theta]", "[", RowBox[{"t", "+", "\[Delta]t"}], "]"}]}], SuperscriptBox[ RowBox[{"(", "\[Delta]t", ")"}], "2"]], FontSize->16], TraditionalForm]]], "~ -Sin[\[Theta][", StyleBox["t", FontSlant->"Italic"], "]] + O(", Cell[BoxData[ FormBox[ SuperscriptBox[ StyleBox[ RowBox[{"\[Delta]", StyleBox["t", FontSlant->"Italic"]}]], "2"], TraditionalForm]]], ")\nThis method computes only the position and not the velocity. \ Consequently, it is suitable for problems when the force depends only on the \ position (and not the velocity). Notice that the trunction error scales like \ ", Cell[BoxData[ FormBox[ SuperscriptBox["\[Delta]t", "4"], TraditionalForm]]], ". Verlet's method is relatively accurate and easy-to-program. Like the ", StyleBox["leap-frog", FontSlant->"Italic"], " method, this", " method is not ", StyleBox["self-starting", FontSlant->"Italic"], ". Use one step of Euler to start your integration, and then compute an \ approximation to the angular motion of the pendulum, \[Theta](", StyleBox["t", FontSlant->"Italic"], "), for several periods. You may start with any initial condition. You may \ also normalize length and time so that (", StyleBox["g", FontSlant->"Italic"], "/", StyleBox["L", FontSlant->"Italic"], ") = 1.0." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Period of a Nonlinear Pendulum (in-class)", "Subsection"], Cell[TextData[{ "A linear pendulum has a period that is ", StyleBox["independent ", FontSlant->"Italic"], " of the amplitude of oscillation. This is why pendulums can be used for \ clocks. A real pendulum is nonlinear, and the period changes as the amplitude \ of its swinging increases." }], "Text"], Cell[TextData[{ "Use ", StyleBox["NDSolve[\[Ellipsis]]", FontWeight->"Bold"], " and compute the period of our pendulum as a function of angle.\nYou should \ begin with the solution discussed in class:" }], "Text"], Cell[BoxData[ RowBox[{"eqs", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"\[Theta]", "'"}], "[", "t", "]"}], " ", "==", " ", RowBox[{"w", "[", "t", "]"}]}], ",", " ", RowBox[{ RowBox[{ RowBox[{"w", "'"}], "[", "t", "]"}], " ", "==", " ", RowBox[{"-", " ", RowBox[{"Sin", "[", RowBox[{"\[Theta]", "[", "t", "]"}], "]"}]}]}]}], "}"}]}]], "Input"], Cell[BoxData[{ RowBox[{ RowBox[{"initial", "=", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"\[Theta]", "[", "0", "]"}], "\[Equal]", RowBox[{"N", "[", RowBox[{"75", " ", "\[Degree]"}], "]"}]}], ",", RowBox[{ RowBox[{"w", "[", "0", "]"}], "\[Equal]", "0"}]}], "}"}]}], ";"}], "\n", RowBox[{ RowBox[{"sol", "=", RowBox[{"NDSolve", "[", RowBox[{ RowBox[{"Join", "[", RowBox[{"eqs", ",", "initial"}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"\[Theta]", "[", "t", "]"}], ",", RowBox[{"w", "[", "t", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "20"}], "}"}]}], "]"}]}], ";"}], "\n", RowBox[{"Plot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"\[Theta]", "[", "t", "]"}], "/.", "\[InvisibleSpace]", "sol"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "20"}], "}"}]}], "]"}]}], "CompatibilityInput"], Cell[TextData[{ "Next, you will need to use ", StyleBox["FindRoot[\[Ellipsis]]", FontWeight->"Bold"], ", to estimate the time when the pendulum crosses the horizontal:" }], "Text"], Cell[BoxData[ RowBox[{"?", "FindRoot"}]], "Input"], Cell[BoxData[ RowBox[{"FindRoot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"\[Theta]", "[", "t", "]"}], " ", "/.", " ", "sol"}], "]"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", " ", "2.0"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"\[Theta]", "[", "t", "]"}], " ", "/.", " ", "sol"}], ")"}], "/.", " ", "%", " ", RowBox[{"(*", " ", RowBox[{"should", " ", "be", " ", "near", " ", "zero"}], " ", "*)"}]}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"tGuess", " ", "=", " ", RowBox[{"2", " ", "\[Pi]"}]}], ";", RowBox[{ RowBox[{"(", RowBox[{"t", " ", "/.", " ", RowBox[{"FindRoot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"\[Theta]", "[", "t", "]"}], " ", "/.", " ", "sol"}], "]"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", " ", RowBox[{"5", " ", RowBox[{"tGuess", "/", "4"}]}]}], "}"}]}], "]"}]}], ")"}], " ", "-", " ", RowBox[{"(", RowBox[{"t", " ", "/.", " ", RowBox[{"FindRoot", "[", RowBox[{ RowBox[{"Evaluate", "[", RowBox[{ RowBox[{"\[Theta]", "[", "t", "]"}], " ", "/.", " ", "sol"}], "]"}], ",", " ", RowBox[{"{", RowBox[{"t", ",", RowBox[{"tGuess", "/", "4"}]}], " ", "}"}]}], "]"}]}], ")"}]}]}]], "Input"], Cell[TextData[{ "Combine these statements into a single ", StyleBox["Module[\[Ellipsis]]", FontWeight->"Bold"], " and define a function of the initial angle that returns the period." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["A \"Constant\" Restoring Force", "Subsection"], Cell[TextData[{ "Compute the motion of an object confined by a \"constant\" restoring force. \ The force is directed towards the origin, ", StyleBox["x", FontSlant->"Italic"], " = 0. When ", StyleBox["x", FontSlant->"Italic"], " < 0, then the force is ", Cell[BoxData[ FormBox[ SubscriptBox["F", "0"], TraditionalForm]]], "; and when ", StyleBox["x", FontSlant->"Italic"], " > 0, then the force is \[Dash] ", Cell[BoxData[ FormBox[ SubscriptBox["F", "0"], TraditionalForm]]], ". (For simplicity, let ", Cell[BoxData[ FormBox[ SubscriptBox["F", "0"], TraditionalForm]]], " = 1.0.)\nUse ", StyleBox["both", FontSlant->"Italic"], " the Euler-Cromer method and", " the built-in method in ", StyleBox["Mathematica", FontSlant->"Italic"], ", ", StyleBox["NDSolve[\[Ellipsis]]", FontWeight->"Bold"], ". Start with the object at rest (", StyleBox["v", FontSlant->"Italic"], " = 0.0) but with a non-zero initial position, ", StyleBox["x", FontSlant->"Italic"], "(0) \[NotEqual] 0. Note how the period of oscillation depends upon the \ amplitude. Finally, use ", StyleBox["NDSolve[\[Ellipsis]]", FontWeight->"Bold"], " and the technique used in the previous exercise to graph the period of \ oscillation as a function of the initial position. (Did you notice the \ geometric shape of the trajectory, ", StyleBox["x", FontSlant->"Italic"], "(", StyleBox["t", FontSlant->"Italic"], ")? The period should scale as ", Cell[BoxData[ FormBox[ SqrtBox[ RowBox[{"x", "(", "0", ")"}]], TraditionalForm]]], ".)" }], "Text"] }, Closed]] }, Open ]] }, WindowSize->{1064, 858}, WindowMargins->{{153, Automatic}, {128, Automatic}}, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (May 21, 2008)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 37, 0, 73, "Title"], Cell[630, 25, 191, 5, 45, "Subsubtitle"], Cell[CellGroupData[{ Cell[846, 34, 48, 0, 33, "Subsection"], Cell[897, 36, 1986, 65, 126, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[2920, 106, 63, 0, 25, "Subsection"], Cell[2986, 108, 305, 7, 59, "Text"], Cell[3294, 117, 218, 6, 43, "Text"], Cell[3515, 125, 429, 13, 28, "Input"], Cell[3947, 140, 980, 31, 59, "CompatibilityInput"], Cell[4930, 173, 185, 5, 27, "Text"], Cell[5118, 180, 51, 1, 28, "Input"], Cell[5172, 183, 261, 8, 28, "Input"], Cell[5436, 193, 260, 8, 28, "Input"], Cell[5699, 203, 906, 29, 28, "Input"], Cell[6608, 234, 199, 5, 27, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[6844, 244, 52, 0, 25, "Subsection"], Cell[6899, 246, 1581, 57, 99, "Text"] }, Closed]] }, Open ]] } ] *) (* End of internal cache information *)