(* 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[ 42293, 1175] NotebookOptionsPosition[ 39566, 1085] NotebookOutlinePosition[ 40186, 1109] CellTagsIndexPosition[ 40143, 1106] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[TextData[{ "Continuous computation using ", Cell[BoxData["Dynamic"]] }], "Title", CellChangeTimes->{{3.3907458272729015`*^9, 3.390745835374874*^9}, { 3.390746922311163*^9, 3.3907469286805754`*^9}, {3.390747109577908*^9, 3.390747121535579*^9}, {3.3949919891510243`*^9, 3.3949920025093*^9}, { 3.395346125984375*^9, 3.39534614046875*^9}, {3.3954160997502937`*^9, 3.3954160998804817`*^9}, {3.3954170292761545`*^9, 3.3954170434566865`*^9}, {3.3954987906173086`*^9, 3.395498815643794*^9}, { 3.3954996494493756`*^9, 3.3954996553680043`*^9}, 3.3955127068553963`*^9, 3.395512766322091*^9}], Cell["\<\ Comp 160 Course Module 10 \ \>", "Subtitle", CellChangeTimes->{{3.390745838950158*^9, 3.3907458395911055`*^9}, 3.3907469187659235`*^9, {3.394991909622219*^9, 3.394991911955411*^9}, 3.3949920154269733`*^9, {3.395346122265625*^9, 3.395346122453125*^9}, 3.3954170235578747`*^9, {3.3954987841378627`*^9, 3.3954987842880816`*^9}, { 3.3955127681247187`*^9, 3.3955127701576824`*^9}, {3.427129960819272*^9, 3.4271299609394493`*^9}, {3.463333796890625*^9, 3.4633337998125*^9}}], Cell[TextData[{ "Up to now, our interactive graphics have changed only in response to input. \ In this module, we will revisit ", Cell[BoxData["Dynamic"]], " and learn how to use ", Cell[BoxData["Dynamic"]], " to create graphical expression that evolve ", StyleBox["continually", FontSlant->"Italic"], " in response to user input. This feature will start us on the path to make \ more interesting games." }], "Text", CellChangeTimes->{{3.394992012613124*^9, 3.3949921192690425`*^9}, { 3.395346151296875*^9, 3.395346266640625*^9}, {3.3954112081877975`*^9, 3.3954112189633994`*^9}, {3.3954161134100714`*^9, 3.3954161204402504`*^9}, 3.3954165079413137`*^9, {3.3954173283091245`*^9, 3.3954174277330804`*^9}, { 3.3954962908229303`*^9, 3.3954963027503185`*^9}, {3.395499665052122*^9, 3.3954997904148855`*^9}, {3.3955127784798155`*^9, 3.395512783637334*^9}, 3.3955129641705284`*^9, {3.3956016552547894`*^9, 3.3956017652841005`*^9}}], Cell[CellGroupData[{ Cell[TextData[{ "The current state of ", StyleBox["Disasteroids", FontSlant->"Italic"] }], "Section", CellChangeTimes->{{3.394384127590186*^9, 3.3943841323971944`*^9}, { 3.3943860065394526`*^9, 3.394386016584097*^9}, {3.3943862806590843`*^9, 3.3943862835232596`*^9}, {3.3944627701709642`*^9, 3.3944627761697097`*^9}, {3.39534637065625*^9, 3.39534638284375*^9}, 3.395358350984375*^9, {3.3954171137785053`*^9, 3.395417121559772*^9}}], Cell[TextData[{ "Since we will spend several modules working on ", StyleBox["Disasteroids", FontSlant->"Italic"], ", we will start with a clean version from the last module. Our \ implementation consisted of a background, a ship whose position was \ parameterized by a position and orientation and the helper function ", Cell[BoxData["vectorToAngle"]], "." }], "Text", CellChangeTimes->{{3.3954174417233367`*^9, 3.395417535108549*^9}, { 3.395601419633633*^9, 3.3956014395024014`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"background", "=", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}]}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"shipModel", "=", RowBox[{"Polygon", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", FractionBox["1", "2"]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", FractionBox[ RowBox[{"-", "1"}], "2"]}], "}"}]}], "}"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{ RowBox[{"ship", "[", RowBox[{"p_", ",", "\[Theta]_"}], "]"}], ":=", RowBox[{"Translate", "[", RowBox[{ RowBox[{"Rotate", "[", RowBox[{ RowBox[{"Scale", "[", RowBox[{"shipModel", ",", FractionBox["1", "10"]}], "]"}], ",", "\[Theta]"}], "]"}], ",", "p"}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"vectorToAngle", "[", RowBox[{"{", RowBox[{"x_", ",", "y_"}], "}"}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"y", "\[GreaterEqual]", "0"}], ",", RowBox[{"ArcCos", "[", "x", "]"}], ",", RowBox[{ RowBox[{"2", "\[Pi]"}], "-", RowBox[{"ArcCos", "[", "x", "]"}]}]}], "]"}]}]}], "Input", CellChangeTimes->{{3.394462114505088*^9, 3.3944621175595407`*^9}, { 3.394462182233827*^9, 3.3944622029840784`*^9}, {3.394559454232637*^9, 3.3945594679125805`*^9}, {3.3954154048541527`*^9, 3.395415411063143*^9}, { 3.395417155168434*^9, 3.3954171685077477`*^9}, {3.3956014098094087`*^9, 3.395601410981105*^9}, {3.395684096333052*^9, 3.3956841000684605`*^9}}], Cell[TextData[{ "Here is my latest version of ", StyleBox["Disasteroids", FontSlant->"Italic"], " that uses the gamepads to provide absolute control over the orientation \ and postion of the ship." }], "Text", CellChangeTimes->{{3.3956015301236115`*^9, 3.3956015644833612`*^9}, 3.3956710740695677`*^9}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DynamicModule", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"p", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}], ",", RowBox[{"\[Theta]", "=", "0"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Panel", "[", RowBox[{ RowBox[{"Column", "[", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"Graphics", "[", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ "background", ",", "\[IndentingNewLine]", "White", ",", "\[IndentingNewLine]", RowBox[{"Dynamic", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"p", "=", RowBox[{"{", RowBox[{ RowBox[{"ControllerState", "[", "\"\\"", "]"}], ",", RowBox[{"-", RowBox[{"ControllerState", "[", "\"\\"", "]"}]}]}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"\[Theta]", "=", RowBox[{"vectorToAngle", "[", RowBox[{"Normalize", "[", RowBox[{"{", RowBox[{ RowBox[{"ControllerState", "[", "\"\\"", "]"}], ",", RowBox[{"-", RowBox[{ "ControllerState", "[", "\"\\"", "]"}]}]}], "}"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ship", "[", RowBox[{"p", ",", "\[Theta]"}], "]"}]}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Button", "[", RowBox[{"\"\\"", ",", RowBox[{ RowBox[{"\[Theta]", "=", "0"}], ";", RowBox[{"p", "=", RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}]}]}]}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Style", "[", RowBox[{"\"\\"", ",", RowBox[{"FontSize", "\[Rule]", "36"}], ",", RowBox[{"Color", "\[Rule]", "Red"}], ",", "Italic"}], "]"}], ",", "Top"}], "]"}]}], "]"}]], "Input", CellChangeTimes->{{3.3944607240579944`*^9, 3.3944608783529367`*^9}, { 3.394460909508357*^9, 3.39446105302759*^9}, {3.3944611755261765`*^9, 3.3944612086544733`*^9}, {3.394461376819637*^9, 3.394461394565508*^9}, { 3.394461498316764*^9, 3.394461581467988*^9}, {3.3944616120726056`*^9, 3.394461855096904*^9}, {3.3944621652090073`*^9, 3.394462165869971*^9}, { 3.3944622961298733`*^9, 3.3944622987236547`*^9}, {3.3945600411282554`*^9, 3.39456008757597*^9}, {3.3945601200433035`*^9, 3.394560154613703*^9}, { 3.3954172615524673`*^9, 3.3954172657385283`*^9}, {3.3954195203529863`*^9, 3.395419556375142*^9}, {3.3954974223725843`*^9, 3.395497423263883*^9}, { 3.3954974922945213`*^9, 3.3954975070360126`*^9}, {3.3954982630581956`*^9, 3.3954983590481367`*^9}, {3.39550331643537*^9, 3.3955034100017776`*^9}, { 3.3955034569101644`*^9, 3.3955034940843596`*^9}, {3.395503525570262*^9, 3.3955035490344696`*^9}, 3.395503685092825*^9, {3.3955842937170095`*^9, 3.3955843973971276`*^9}, {3.395584451906051*^9, 3.3955845333639936`*^9}, { 3.395584590546789*^9, 3.3955846053181763`*^9}, {3.3955846862753944`*^9, 3.3955847021784205`*^9}, {3.3955848806368103`*^9, 3.395584882008797*^9}, { 3.39558512009352*^9, 3.3955851669012933`*^9}, {3.395598929928788*^9, 3.395599047418902*^9}, {3.395599102658884*^9, 3.3955991123829637`*^9}, { 3.395599179910737*^9, 3.3955991901956286`*^9}, {3.395599532180789*^9, 3.3955995364169226`*^9}, {3.3955995679325542`*^9, 3.3955995731100507`*^9}, {3.3955996393359394`*^9, 3.3955996461357846`*^9}, {3.395599689007859*^9, 3.395599689879121*^9}, { 3.395599724479218*^9, 3.3955997262017117`*^9}, {3.395599801010027*^9, 3.3955998072690897`*^9}, {3.3956001144338336`*^9, 3.3956002078090315`*^9}, 3.39560024539345*^9, {3.395668727081362*^9, 3.395668752197728*^9}, { 3.3956688026607933`*^9, 3.395668841336793*^9}, {3.3956840373176036`*^9, 3.395684056455313*^9}, {3.400340775367877*^9, 3.400340795258629*^9}}], Cell[BoxData[ DynamicModuleBox[{$CellContext`p$$ = {$Failed, -$Failed}, $CellContext`\ \[Theta]$$ = $CellContext`vectorToAngle[{ 2^Rational[-1, 2] ($Failed/Abs[$Failed]), (-2^Rational[-1, 2]) ($Failed/ Abs[$Failed])}]}, InterpretationBox[GridBox[{ { TagBox[ StyleBox[ StyleBox["\<\"Disasteroids\"\>", StripOnInput->False, FrontFaceColor->RGBColor[1, 0, 0], BackFaceColor->RGBColor[1, 0, 0], GraphicsColor->RGBColor[1, 0, 0], FontSize->36, FontSlant->Italic, FontColor->RGBColor[1, 0, 0]], "Panel", StripOnInput->False, Background->None], "Labeled", Editable->True, Selectable->True]}, { TagBox[ TagBox[ PanelBox[ TagBox[GridBox[{ { GraphicsBox[{RectangleBox[{-1, -1}, {1, 1}], {GrayLevel[1], DynamicBox[Typeset`ToBoxes[$CellContext`p$$ = { ControllerState["X Axis"], - ControllerState[ "Y Axis"]}; $CellContext`\[Theta]$$ = \ $CellContext`vectorToAngle[ Normalize[{ ControllerState["X Rotation"], - ControllerState[ "Y Rotation"]}]]; $CellContext`ship[$CellContext`p$$, \ $CellContext`\[Theta]$$], StandardForm, Graphics], ImageSizeCache->{{0., 0.}, {0., 0.}}]}}]}, { ButtonBox["\<\"Reset\"\>", Appearance->{Automatic, "DialogBox"}, ButtonFunction:>($CellContext`\[Theta]$$ = 0; $CellContext`p$$ = {0, 0}), Evaluator->Automatic, Method->"Preemptive"]} }, ColumnsEqual->False, GridBoxAlignment->{"Columns" -> {{Left}}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}, RowsEqual->False], "Column"]], "Labeled", Editable->True, Selectable->True], "SkipImageSizeLevel"]} }, BaselinePosition->{2, 1}, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Center}}, "RowsIndexed" -> {}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, "RowsIndexed" -> {}}], Labeled[ Panel[ Column[{ Graphics[{ Rectangle[{-1, -1}, {1, 1}], GrayLevel[1], Dynamic[$CellContext`p$$ = { ControllerState["X Axis"], - ControllerState[ "Y Axis"]}; $CellContext`\[Theta]$$ = $CellContext`vectorToAngle[ Normalize[{ ControllerState["X Rotation"], - ControllerState[ "Y Rotation"]}]]; $CellContext`ship[$CellContext`p$$, \ $CellContext`\[Theta]$$]]}], Button[ "Reset", $CellContext`\[Theta]$$ = 0; $CellContext`p$$ = {0, 0}]}]], { Style[ Style[ "Disasteroids", FontSize -> 36, $CellContext`Color -> RGBColor[1, 0, 0], Italic], "Panel", Background -> None]}, {Top}], Editable->False, Selectable->False], DynamicModuleValues:>{}]], "Output", CellChangeTimes->{3.395601572615135*^9, 3.395668893882874*^9, 3.395671075812091*^9, 3.39568252189342*^9, 3.395684110473526*^9, 3.4003407972117662`*^9, 3.400341531310215*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Concurrency and threading", "Section", CellChangeTimes->{{3.3942076761358576`*^9, 3.3942076798312454`*^9}, { 3.394214969488629*^9, 3.3942149761483383`*^9}, {3.3942153315965357`*^9, 3.394215336924303*^9}, {3.394289304576662*^9, 3.3942893174550514`*^9}, { 3.394305925791448*^9, 3.394305940723366*^9}, {3.3943064041536083`*^9, 3.3943064060363717`*^9}, 3.394375794641818*^9, {3.394462790730938*^9, 3.394462791772456*^9}, {3.395499808521282*^9, 3.3954998154914436`*^9}, { 3.395500139954469*^9, 3.3955001419974475`*^9}, {3.3955006858202715`*^9, 3.3955006919191628`*^9}, {3.3955126905416126`*^9, 3.3955126916732626`*^9}}], Cell[TextData[{ "Up to now, our graphical expression have reacted only to changes in user \ input. In the module on ", Cell[BoxData["EventHandler"]], ", we explained the behavior of ", StyleBox["Mathematica", FontSlant->"Italic"], " in terms a single evaluation thread occasionally interrupted by an event \ triggered by user input. In reality, the computations taking place in ", StyleBox["Mathematica", FontSlant->"Italic"], " are much more complex. How does ", StyleBox["Mathematica", FontSlant->"Italic"], " manage to evaluate an expression, allow editing of the notebook and read \ user input all at the same time? By performing these tasks ", StyleBox["concurrently.", FontSlant->"Italic"] }], "Text", CellChangeTimes->{{3.395601593174904*^9, 3.395601599494053*^9}, { 3.3956711150689306`*^9, 3.3956712848447495`*^9}, {3.4003345986565995`*^9, 3.400334599969108*^9}, {3.463333895046875*^9, 3.4633338955625*^9}}], Cell[TextData[{ "Concurrent processing involves performing multiple computations called ", StyleBox["processes", FontSlant->"Italic"], " simultaneously. Multiple processors maybe run directly by the computer \ using multiple processors or executed by a single processor that takes turns \ running each process for brief time. In many instances, these processes \ cooperate to perform a single calculations. Cooperating process are often \ referred to as ", StyleBox["threads", FontSlant->"Italic"], ". ", StyleBox["Mathematica", FontSlant->"Italic"], "'s computations consists of a large number of threaded processes. For \ example, one thread handles editing of the current notebook. Another thread \ runs kernel computations. Event handling has its own thread. By structuring \ ", StyleBox["Mathematica", FontSlant->"Italic"], "'s computation in terms of threads and letting the CPU handle prioritizing \ the threads, ", StyleBox["Mathematica", FontSlant->"Italic"], " can appear to perform multiple computations simultaneously even if the \ computer has only a single CPU." }], "Text", CellChangeTimes->{{3.3943058739153023`*^9, 3.394305883399223*^9}, { 3.3944619152245617`*^9, 3.394461930056185*^9}, {3.39550015721964*^9, 3.3955003238826127`*^9}, {3.3955004100782747`*^9, 3.3955006231088457`*^9}, { 3.395500767339115*^9, 3.3955007728972187`*^9}, {3.395671309780854*^9, 3.3956715606340647`*^9}}], Cell[TextData[{ "Most computer games are threaded for the same reason. For example, games \ usually have a ", StyleBox["rendering thread ", FontSlant->"Italic"], "(", Cell[BoxData["Dynamic"]], " updating ", Cell[BoxData["Graphics"]], " objects in ", StyleBox["Mathematica", FontSlant->"Italic"], "), an ", StyleBox["event handling", FontSlant->"Italic"], " thread", StyleBox[" ", FontSlant->"Italic"], "(", Cell[BoxData["EventHandler"]], " and ", Cell[BoxData["ControllerState"]], ") and a ", StyleBox["computation ", FontSlant->"Italic"], "thread that continually updates the game states. In games like ", StyleBox["Robotron", FontSlant->"Italic"], ", extra threads help to update the behavior of particles that models \ weapons effects and adversaries." }], "Text", CellChangeTimes->{{3.3944770920374703`*^9, 3.394477158644575*^9}, { 3.395671568555534*^9, 3.3956717125139713`*^9}, {3.4633339574375*^9, 3.463333980296875*^9}, 3.4633340253125*^9}] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Understanding the behavior of ", Cell[BoxData["Dynamic"]] }], "Section", CellChangeTimes->{{3.3944628822143087`*^9, 3.3944628877523828`*^9}, { 3.394474626760141*^9, 3.394474674859304*^9}, {3.395677526702338*^9, 3.395677542645422*^9}, {3.3956786974159575`*^9, 3.395678698397378*^9}, { 3.395680939892841*^9, 3.3956809400630875`*^9}, 3.400334605594144*^9}], Cell[TextData[{ "Given that we can generate interactive graphics that respond to user input \ in ", StyleBox["Mathematica", FontSlant->"Italic"], ", our next task is to add continuous computation to our interactive \ graphics so that the graphics object evolves over time without the need for \ user input. Of course, one method for achieving this goal would be to add a \ loop to our ", StyleBox["Mathematica", FontSlant->"Italic"], " definition that runs continually. However, we take advantage of the \ behavior of ", Cell[BoxData["Dynamic"]], " to achieve continuous update without the need for a loop." }], "Text", CellChangeTimes->{{3.394475789117981*^9, 3.3944758421152444`*^9}, { 3.395671737900729*^9, 3.395671909318926*^9}, {3.4003346068129015`*^9, 3.400334608219161*^9}}], Cell[TextData[{ "To use ", Cell[BoxData["Dynamic"]], " to its fullest extent, we need to fully understand how ", Cell[BoxData["Dynamic"]], " works. In our introduction to ", Cell[BoxData["Dynamic"]], ", we saw that when the ", StyleBox["Mathematica", FontSlant->"Italic"], " kernel encounters an expression of the form ", Cell[BoxData[ RowBox[{"Dyanamic", "[", "exp", "]"}]]], ", it returns ", Cell[BoxData[ RowBox[{"Dynamic", "[", "exp", "]"}]]], " to the front-end. The front-end places this expression into the \ appropriate place in the notebook. Finally, each time this expression in \ notebook is displayed (i.e., every frame), the front-end asks the kernel to \ evaluate ", Cell[BoxData["exp"]], " and its value is displayed in place of ", Cell[BoxData[ RowBox[{"Dynamic", "[", "exp", "]"}]]], ". To fully appreciate this behavior, let's consider some simple examples." }], "Text", CellChangeTimes->{{3.3956772334978075`*^9, 3.395677471422298*^9}, { 3.3956775129324007`*^9, 3.3956775156363153`*^9}, {3.463334161484375*^9, 3.46333419040625*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{"a", "=", "1"}], "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"2", "+", RowBox[{"Dynamic", "[", "a", "]"}]}]}]}], "Input", CellChangeTimes->{{3.395677550276471*^9, 3.3956775615728273`*^9}}], Cell[BoxData["1"], "Output", CellChangeTimes->{3.3956775623239145`*^9, 3.463334211375*^9}], Cell[BoxData[ RowBox[{"2", "+", DynamicBox[ToBoxes[$CellContext`a, StandardForm], ImageSizeCache->{11., {0., 8.}}]}]], "Output", CellChangeTimes->{3.3956775623239145`*^9, 3.463334211453125*^9}] }, Open ]], Cell[TextData[{ "This example illustrates the first curious facet of ", Cell[BoxData["Dynamic"]], ". At first glance, we would expect ", Cell[BoxData["b"]], " to have a value of ", Cell[BoxData["3"]], ". Let's look at ", StyleBox["Mathematica", FontSlant->"Italic"], "'s underlying representation of ", Cell[BoxData["b"]], " to see if we can understand why the answer is ", Cell[BoxData[ RowBox[{"2", "+", "1"}]]], "." }], "Text", CellChangeTimes->{{3.3956775720580087`*^9, 3.3956777129419947`*^9}, { 3.46333424334375*^9, 3.4633342473125*^9}, {3.4856910345056615`*^9, 3.485691035177528*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"FullForm", "[", "b", "]"}]], "Input", CellChangeTimes->{{3.3956776786323175`*^9, 3.3956776827582912`*^9}}], Cell[BoxData[ TagBox[ StyleBox[ RowBox[{"Plus", "[", RowBox[{"2", ",", RowBox[{"Dynamic", "[", "a", "]"}]}], "]"}], ShowSpecialCharacters->False, ShowStringCharacters->True, NumberMarks->True], FullForm]], "Output", CellChangeTimes->{3.395677683218959*^9}] }, Open ]], Cell[TextData[{ "The true value return by the kernel when evaluating ", Cell[BoxData[ RowBox[{"2", " ", "+", " ", RowBox[{"Dynamic", "[", "a", "]"}]}]]], " is actually ", Cell[BoxData[ RowBox[{"Plus", "[", RowBox[{"2", ",", " ", RowBox[{"Dynamic", "[", "a", "]"}]}], "]"}]]], ". Why did we see ", Cell[BoxData[ RowBox[{"2", "+", "1"}]]], " as the answer? Because everytime we view ", Cell[BoxData[ RowBox[{"Plus", "[", RowBox[{"2", ",", " ", RowBox[{"Dynamic", "[", "a", "]"}]}], "]"}]]], " printed as output, the ", StyleBox["Mathematica", FontSlant->"Italic"], " front-end asks the kernel for the current value of ", Cell[BoxData["a"]], ", the kernel returns the value ", Cell[BoxData["2"]], ", the ", StyleBox["front-end", FontWeight->"Bold"], " replaces ", Cell[BoxData[ RowBox[{"Dynamic", "[", "a", "]"}]]], " by ", Cell[BoxData["2"]], " and prints out the entire expression ", Cell[BoxData[ RowBox[{"2", "+", "1"}]]], ". The important point to note is the kernel is ", StyleBox["not", FontWeight->"Bold"], " asked to evaluate the expression ", Cell[BoxData[ RowBox[{"2", "+", "1"}]]], " after it has fetched the value for ", Cell[BoxData["a"]], ". Instead, the front-end simply replaces ", Cell[BoxData[ RowBox[{"Dynamic", "[", "a", "]"}]]], " by the value of ", Cell[BoxData["a"]], "." }], "Text", CellChangeTimes->{{3.395677689077441*^9, 3.395677992844208*^9}, { 3.395678033193942*^9, 3.39567806037766*^9}, {3.3956781065789576`*^9, 3.395678127590478*^9}, 3.400334620516114*^9, {3.463334264375*^9, 3.463334266125*^9}, {3.463334333859375*^9, 3.463334364953125*^9}, 3.4856910854581347`*^9}], Cell[CellGroupData[{ Cell["Exercise", "Exercise", CellChangeTimes->{{3.395678263868223*^9, 3.3956782641686583`*^9}, { 3.395678728180501*^9, 3.3956787298028502`*^9}}], Cell[TextData[{ StyleBox["Consider the ", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" expression, ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{"a", " ", "=", " ", RowBox[{"1", " ", "+", " ", RowBox[{"Dynamic", "[", "a", "]"}]}]}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[". ", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["After saving your work first", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], StyleBox[", ask ", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" to evaluate this expression. What happened? To help understand \ what is going on, look at ", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["Mathematica's", FontSlant->"Italic", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" value for this expression in ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["FullForm"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[". Note that nothing crazy happens when you view the answer in ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["FullForm"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[". Try to explain at how ", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" arrived at its first answer in terms of the front-end's method \ for handling ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Dynamic"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[".", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3956782702674885`*^9, 3.3956785142807956`*^9}, { 3.395678573035867*^9, 3.3956786220368156`*^9}, 3.4003346338286996`*^9}], Cell[TextData[{ "The previous explanation of how ", Cell[BoxData["Dynamic"]], " works was ", StyleBox["almost", FontSlant->"Italic"], " entirely truthful. ", StyleBox["Mathematica", FontSlant->"Italic"], " makes one modification to the behavior of ", Cell[BoxData[ RowBox[{"Dynamic", "[", "exp", "]"}]]], " to avoid excessive re-evaluation of ", Cell[BoxData["exp"]], " by the kernel. To avoid continually asking the kernel to re-evaluate ", Cell[BoxData["exp"]], ", the front-end keeps track of those variables in the expression ", Cell[BoxData["exp"]], " that have been modified since the last redraw. If no variables used in ", Cell[BoxData["exp"]], " have been modified, the front-end doesn't bother asking the kernel to \ re-evaluate ", Cell[BoxData["exp"]], ", but simply uses its most recent value. (Remember that the expression is \ being redrawn 30 to 60 times a second when it is visible, so this is an \ important savings in computation.)" }], "Text", CellChangeTimes->{{3.395678739597031*^9, 3.395679184030527*^9}, { 3.3956792309985313`*^9, 3.3956792944003315`*^9}, {3.3956817227162914`*^9, 3.3956817389497957`*^9}, {3.463334527421875*^9, 3.46333453528125*^9}, { 3.4633346581875*^9, 3.46333469478125*^9}, {3.485691145644864*^9, 3.4856911459417353`*^9}}], Cell[TextData[{ "This observation raises the follow idea. What if we insert an expression \ into ", Cell[BoxData["Dynamic"]], " that self-modifies its values? Let's try this idea and see what happens." }], "Text", CellChangeTimes->{{3.395679304204527*^9, 3.3956793831688595`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"a", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{"Dynamic", "[", RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}], "]"}]}], "Input", CellChangeTimes->{{3.395679387995848*^9, 3.395679421093771*^9}}], Cell[TextData[{ "Note what happens! The output of the ", Cell[BoxData["Dynamic"]], " expression is continually increasing. How does this work in ", StyleBox["Mathematica", FontSlant->"Italic"], "? First, the kernel evaluates ", Cell[BoxData[ RowBox[{"a", "=", "1"}]]], " and assigns the value ", Cell[BoxData["1"]], " to ", Cell[BoxData["a"]], ". Next, the kernel evaluate the second expressions and returns it value ", Cell[BoxData[ RowBox[{"Dynamic", "[", RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}], "]"}]]], ". Note that the expression inside ", Cell[BoxData["Dynamic"]], " was not evaluated. The kernel passes this value back to the front-end \ and, finally, the front-end tries to display this expression. To display \ this expression, the front-end asks the kernel to then evaluate ", Cell[BoxData[ RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}]]], ". The kernel, in turn, computes ", Cell[BoxData[ RowBox[{"1", "+", "1"}]]], ", assigns the results to ", Cell[BoxData["a"]], ", and returns the value ", Cell[BoxData["2"]], " to the front end. The front-end then displays the value ", Cell[BoxData["2"]], ". However, the front-end then detects that variable ", Cell[BoxData["a"]], " has been updated and then asks the kernel to re-evaluate ", Cell[BoxData[ RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}]]], ", and so on." }], "Text", CellChangeTimes->{{3.3956794069733257`*^9, 3.3956795195363054`*^9}, { 3.3956803489672394`*^9, 3.3956806318067627`*^9}, {3.3956807339446483`*^9, 3.3956807415356393`*^9}, {3.46333477653125*^9, 3.463334790265625*^9}}], Cell[TextData[{ "Note that the continual re-evaluation is being triggered by the front-end's \ attempts to render the expression inside ", Cell[BoxData["Dynamic"]], ". From our first example, we noted that we could suppress this rendering \ by printing out the expression in ", Cell[BoxData["FullForm"]], ". For example, wrapping the ", Cell[BoxData["Dynamic"]], " in ", Cell[BoxData["FullForm"]], " suppressed the counting because the front-end is no longer asking the \ kernel to evaluate ", Cell[BoxData[ RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}]]], "." }], "Text", CellChangeTimes->{{3.3956807491967316`*^9, 3.3956809116419363`*^9}, { 3.463334831640625*^9, 3.463334842*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"a", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{"FullForm", "[", RowBox[{"Dynamic", "[", RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}], "]"}], "]"}]}], "Input", CellChangeTimes->{{3.395679387995848*^9, 3.395679421093771*^9}, { 3.3956808554605913`*^9, 3.395680860167406*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Exercise", "Exercise", CellChangeTimes->{{3.395678263868223*^9, 3.3956782641686583`*^9}, { 3.395678728180501*^9, 3.3956787298028502`*^9}}], Cell[TextData[{ StyleBox["Reconsider the ", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" expression, ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{"a", " ", "=", " ", RowBox[{"1", " ", "+", " ", RowBox[{"Dynamic", "[", "a", "]"}]}]}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[". Why didn't the self-modification in this expression trigger a \ continual update of ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["a"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["?", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3956782702674885`*^9, 3.3956785142807956`*^9}, { 3.395678573035867*^9, 3.3956786220368156`*^9}, {3.3956806810580735`*^9, 3.395680726614034*^9}, {3.46333489990625*^9, 3.463334903828125*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Using ", Cell[BoxData["Dynamic"]], " to generate evolving graphics" }], "Section", CellChangeTimes->{{3.395678641885555*^9, 3.3956786904158216`*^9}, { 3.3956812609076385`*^9, 3.395681261889059*^9}}], Cell[TextData[{ "Given a better understanding of ", Cell[BoxData["Dynamic"]], ", we can now move to graphical examples. Below is a previous example in \ which we used a slider to control the radius of the gray disk." }], "Text", CellChangeTimes->{{3.3956719228485155`*^9, 3.395671958339903*^9}, { 3.3956809624655237`*^9, 3.3956809828149877`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DynamicModule", "[", RowBox[{ RowBox[{"{", RowBox[{"r", "=", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}]}], "]"}], ",", "Gray", ",", RowBox[{"Disk", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"Dynamic", "[", "r", "]"}]}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Slider", "[", RowBox[{"Dynamic", "[", "r", "]"}], "]"}]}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.3943869193502135`*^9, 3.3943869507159405`*^9}, { 3.39438702183963*^9, 3.394387062849417*^9}, {3.3943870958775682`*^9, 3.3943871326912374`*^9}, {3.3943871685735493`*^9, 3.394387279945916*^9}, { 3.394387321206068*^9, 3.394387337900406*^9}, {3.3943875539754157`*^9, 3.3943875753165283`*^9}, 3.39446059198545*^9, {3.394475865228941*^9, 3.3944758673219924`*^9}, {3.3945588467269716`*^9, 3.3945589809826994`*^9}, {3.3945590137905293`*^9, 3.3945590530577755`*^9}, {3.394559091934453*^9, 3.394559098293724*^9}, { 3.395671913715291*^9, 3.3956719145665236`*^9}}], Cell[BoxData[ DynamicModuleBox[{$CellContext`r$$ = 1}, RowBox[{"{", RowBox[{ GraphicsBox[{RectangleBox[{-1, -1}, {1, 1}], {GrayLevel[0.5], DiskBox[{0, 0}]}}], ",", SliderBox[Dynamic[$CellContext`r$$]]}], "}"}], DynamicModuleValues:>{}]], "Output", CellChangeTimes->{3.394565102199812*^9, 3.394565711407959*^9, 3.3945658186543107`*^9, 3.394808103645993*^9, 3.3948090386998587`*^9, 3.395512848752263*^9, 3.3956719170901775`*^9, 3.3956810060185843`*^9, 3.39568253210821*^9}] }, Closed]], Cell[TextData[{ "Let's try to change this example so that the radius of the disk \ continuously decreases towards zero via the relation ", Cell[BoxData[ RowBox[{"r", "=", RowBox[{".99", "r"}]}]]], " if the slider is left unchanged." }], "Text", CellChangeTimes->{{3.3956719725604935`*^9, 3.395672016524148*^9}, { 3.395681015322055*^9, 3.395681015882867*^9}, {3.395681063391655*^9, 3.3956810825994654`*^9}, {3.463335049203125*^9, 3.4633350495625*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DynamicModule", "[", RowBox[{ RowBox[{"{", RowBox[{"r", "=", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}]}], "]"}], ",", "Gray", ",", RowBox[{"Disk", "[", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"Dynamic", "[", RowBox[{"r", "=", RowBox[{".99", "r"}]}], "]"}]}], "]"}]}], "}"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Slider", "[", RowBox[{"Dynamic", "[", "r", "]"}], "]"}]}], "}"}]}], "]"}]], "Input", CellChangeTimes->{{3.3943869193502135`*^9, 3.3943869507159405`*^9}, { 3.39438702183963*^9, 3.394387062849417*^9}, {3.3943870958775682`*^9, 3.3943871326912374`*^9}, {3.3943871685735493`*^9, 3.394387279945916*^9}, { 3.394387321206068*^9, 3.394387337900406*^9}, {3.3943875539754157`*^9, 3.3943875753165283`*^9}, 3.39446059198545*^9, {3.394475865228941*^9, 3.3944758673219924`*^9}, {3.3945588467269716`*^9, 3.3945589809826994`*^9}, {3.3945590137905293`*^9, 3.3945590530577755`*^9}, {3.394559091934453*^9, 3.394559098293724*^9}, { 3.395671913715291*^9, 3.3956719145665236`*^9}, {3.3956809928595314`*^9, 3.3956809945019093`*^9}}], Cell[BoxData[ DynamicModuleBox[{$CellContext`r$$ = 0.20230002712877712`}, RowBox[{"{", RowBox[{ GraphicsBox[{RectangleBox[{-1, -1}, {1, 1}], {GrayLevel[0.5], DiskBox[{0, 0}, Dynamic[$CellContext`r$$ = 0.99 $CellContext`r$$]]}}], ",", SliderBox[Dynamic[$CellContext`r$$]]}], "}"}], DynamicModuleValues:>{}]], "Output", CellChangeTimes->{3.395681165209076*^9, 3.3956825370653877`*^9}] }, Closed]], Cell[TextData[{ StyleBox["Note, do not try ", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData[ RowBox[{"r", "=", RowBox[{".99", RowBox[{"Dynamic", "[", "r", "]"}]}]}]], FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], StyleBox[" inside of ", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], Cell[BoxData["Disk"], FontColor->RGBColor[1, 0, 0]], StyleBox[" ", FontColor->RGBColor[1, 0, 0]], StyleBox["instead. It causes ", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]], StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic", FontColor->RGBColor[1, 0, 0]], StyleBox[" to crash! Behavior likes this is the reason that we strongly \ encourage frequent saves.", FontWeight->"Bold", FontColor->RGBColor[1, 0, 0]] }], "Text", CellChangeTimes->{{3.395681019968783*^9, 3.395681126653251*^9}, { 3.3956812265579033`*^9, 3.395681230383442*^9}, {3.46333506490625*^9, 3.46333506925*^9}}], Cell[TextData[{ "We are now ready to use ", Cell[BoxData["Dynamic"]], " to improve our version of ", StyleBox["Disasteroids", FontSlant->"Italic"], " substantially. We begin by moving to a version in the which the position \ of the ship controlled by forward and backward thrust using the triggers." }], "Text", CellChangeTimes->{{3.3956016175802402`*^9, 3.395601637469037*^9}, { 3.3956811821736393`*^9, 3.395681215822359*^9}, {3.3956817847160606`*^9, 3.3956818818066382`*^9}, 3.395684685436015*^9}], Cell[CellGroupData[{ Cell[" Exercises", "Exercise", CellChangeTimes->{{3.3956818396055355`*^9, 3.395681843391016*^9}}], Cell[TextData[{ StyleBox["1. Modify the version of ", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["Disasteroids", FontSlant->"Italic", FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" given above to use the left and right triggers to change the \ relative position of the ship. In particular, pressing the right trigger \ should move the ship in the forward direction and pressing the left trigger \ should move the ship backwards. You may retain the absolute position control \ for the orientation of the ship. (Note that the velocity of the ship should \ be modified inside ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Dynamic"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" with an update of the form ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{"v", "+=", "\[Ellipsis]"}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" .)", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3956818915407324`*^9, 3.3956820629789577`*^9}}], Cell[TextData[{ StyleBox["2. In your previous solution, the ship was allowed to fly outside \ the range ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{"-", "1"}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" to ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["1"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[". Write a help function ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["wrap"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" that takes an arbitrary position and uses modular arithmetic to \ position the ship so that flying of the left of the background causes it to \ appear on the right and similarly for the top and bottom. You may notice \ that when the ship gets near the boundary of the background, the plot still \ is distorted. Use the ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["PlotRange"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" option to fix this problem.", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3956818915407324`*^9, 3.395682322044058*^9}, { 3.395682725878771*^9, 3.395682727090525*^9}}] }, Open ]] }, Open ]] }, WindowToolbars->{}, WindowSize->{1016, 906}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrintingOptions->{"PrintCellBrackets"->False, "PrintMultipleHorizontalPages"->False, "PrintRegistrationMarks"->True, "PrintingMargins"->{{54, 54}, {72, 72}}}, ShowSelection->True, Magnification->1.5, FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (November 10, 2008)", StyleDefinitions->"Classroom.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[545, 20, 613, 11, 83, "Title"], Cell[1161, 33, 498, 9, 93, "Subtitle"], Cell[1662, 44, 959, 18, 86, "Text"], Cell[CellGroupData[{ Cell[2646, 66, 451, 9, 81, "Section"], Cell[3100, 77, 495, 11, 85, "Text"], Cell[3598, 90, 1872, 54, 263, "Input"], Cell[5473, 146, 312, 8, 60, "Text"], Cell[CellGroupData[{ Cell[5810, 158, 4168, 81, 367, "Input"], Cell[9981, 241, 3437, 95, 442, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[13467, 342, 646, 8, 81, "Section"], Cell[14116, 352, 943, 21, 134, "Text"], Cell[15062, 375, 1438, 31, 182, "Text"], Cell[16503, 408, 991, 33, 111, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[17531, 446, 383, 7, 82, "Section"], Cell[17917, 455, 800, 18, 110, "Text"], Cell[18720, 475, 1086, 28, 137, "Text"], Cell[CellGroupData[{ Cell[19831, 507, 227, 5, 97, "Input"], Cell[20061, 514, 91, 1, 68, "Output"], Cell[20155, 517, 201, 4, 68, "Output"] }, Open ]], Cell[20371, 524, 616, 19, 62, "Text"], Cell[CellGroupData[{ Cell[21012, 547, 131, 2, 69, "Input"], Cell[21146, 551, 285, 10, 68, "Output"] }, Open ]], Cell[21446, 564, 1692, 55, 138, "Text"], Cell[CellGroupData[{ Cell[23163, 623, 147, 2, 56, "Exercise"], Cell[23313, 627, 1808, 51, 112, "ExerciseText"], Cell[25124, 680, 1305, 31, 162, "Text"], Cell[26432, 713, 286, 6, 61, "Text"], Cell[26721, 721, 243, 6, 97, "Input"], Cell[26967, 729, 1620, 45, 188, "Text"], Cell[28590, 776, 702, 19, 113, "Text"], Cell[29295, 797, 331, 8, 97, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[29663, 810, 147, 2, 56, "Exercise"], Cell[29813, 814, 873, 23, 62, "ExerciseText"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[30735, 843, 221, 6, 82, "Section"], Cell[30959, 851, 353, 7, 61, "Text"], Cell[CellGroupData[{ Cell[31337, 862, 1449, 34, 124, "Input"], Cell[32789, 898, 507, 11, 1729, "Output"] }, Closed]], Cell[33311, 912, 465, 10, 57, "Text"], Cell[CellGroupData[{ Cell[33801, 926, 1565, 37, 151, "Input"], Cell[35369, 965, 422, 10, 1729, "Output"] }, Closed]], Cell[35806, 978, 964, 31, 57, "Text"], Cell[36773, 1011, 515, 11, 61, "Text"], Cell[CellGroupData[{ Cell[37313, 1026, 98, 1, 56, "Exercise"], Cell[37414, 1029, 1000, 23, 110, "ExerciseText"], Cell[38417, 1054, 1121, 27, 111, "ExerciseText"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)