(* 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[ 23500, 701] NotebookOptionsPosition[ 20926, 613] NotebookOutlinePosition[ 21528, 636] CellTagsIndexPosition[ 21485, 633] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[TextData[{ "Interactive graphics 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}}], Cell["\<\ Comp160 Course Module 4 \ \>", "Subtitle", CellChangeTimes->{{3.390745838950158*^9, 3.3907458395911055`*^9}, 3.3907469187659235`*^9, {3.394991909622219*^9, 3.394991911955411*^9}, 3.3949920154269733`*^9, {3.4271298247281547`*^9, 3.427129829605362*^9}, 3.45925811859375*^9}], Cell[TextData[{ "The previous module introduced the function ", Cell[BoxData["Manipulate"]], " and illustrated how to use it to create dynamically changing graphical \ plots. In this module, we will dig deeper into ", StyleBox["Mathematica", FontSlant->"Italic"], " and learn to use the fundamental technology behind ", Cell[BoxData["Manipulate"]], " to greater better interactive graphics." }], "Text", CellChangeTimes->{{3.394992012613124*^9, 3.3949921192690425`*^9}, { 3.45925812875*^9, 3.459258130953125*^9}}], Cell[CellGroupData[{ Cell[TextData[{ "Interactive graphics using ", Cell[BoxData["Dynamic"]] }], "Section", CellChangeTimes->{{3.394304801130623*^9, 3.3943048133285275`*^9}, 3.394460354238846*^9, {3.394462761989036*^9, 3.3944627632308464`*^9}}], Cell[TextData[{ "Much of the material that follows is derived from the ", StyleBox["Mathematica", FontSlant->"Italic"], " tutorial ", StyleBox[ButtonBox["Introduction to Dynamic.", BaseStyle->"Link", ButtonData->"paclet:tutorial/IntroductionToDynamic"], FontColor->RGBColor[0, 0, 1]], " I suggest that you browse through the tutorial and refer back to it if \ you need more help." }], "Text", CellChangeTimes->{{3.394992141108922*^9, 3.3949921811236672`*^9}, { 3.3949922292995777`*^9, 3.3949922325139756`*^9}, {3.3949922958774414`*^9, 3.3949922986651974`*^9}, {3.394993799427251*^9, 3.3949938049254866`*^9}}], Cell[TextData[{ "Using ", Cell[BoxData["Manipulate"]], ", we were able to construct graphical expressions that reacted to changes \ in sliders, buttons, etc. The core ", StyleBox["Mathematica", FontSlant->"Italic"], " function used in ", Cell[BoxData["Manipulate"]], " is the function ", Cell[BoxData["Dynamic"]], ". ", Cell[BoxData[ RowBox[{"Dynamic", "[", "exp", "]"}]]], " takes the unevaluated expression ", Cell[BoxData["exp"]], ", places a wrapper around ", Cell[BoxData["exp"]], ", insert the result into the ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook (hidden from view) and finally displays the current value of ", Cell[BoxData["exp"]], ". Why does ", StyleBox["Mathematica", FontSlant->"Italic"], " bother to place a wrapper around the unevaluated expression ", Cell[BoxData["exp"]], " and store it in the notebook hidden from view? This wrapper asks ", StyleBox["Mathematica", FontSlant->"Italic"], "'s front-end to keeps track of the variables used in ", Cell[BoxData["exp"]], ". If the front-end detects that one of the variables in ", Cell[BoxData["exp"]], " is modified, the front-end asks ", StyleBox["Mathematica", FontSlant->"Italic"], "'s kernel to revaluate ", Cell[BoxData["exp"]], " and display the result. Thus, the effect of ", Cell[BoxData["Dynamic"]], " is to update (in place) the result of a previous computation whenever one \ of the variables that makes up the expression changes." }], "Text", CellChangeTimes->{{3.394992240004223*^9, 3.3949927514216623`*^9}}], Cell["\<\ To illustrate this concept, we'll start with a simple example. Evaluating\ \>", "Text", CellChangeTimes->{{3.3949927546478767`*^9, 3.394992773514219*^9}, { 3.3949928036923504`*^9, 3.394992806648044*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{"r", "=", "1"}], "\n", RowBox[{"Dynamic", "[", "r", "]"}]}], "Input", CellChangeTimes->{{3.394992778193232*^9, 3.3949928012776995`*^9}, { 3.3949929274106665`*^9, 3.3949929302260904`*^9}}], Cell[BoxData["1"], "Output", CellChangeTimes->{ 3.394992792480754*^9, {3.394992936267728*^9, 3.3949929528797274`*^9}, 3.394993092328345*^9, 3.3951666893362055`*^9, 3.398519081796928*^9}], Cell[BoxData[ DynamicBox[ToBoxes[$CellContext`r, StandardForm], ImageSizeCache->{22., {0., 11.}}]], "Output", CellChangeTimes->{ 3.394992792480754*^9, {3.394992936267728*^9, 3.3949929528797274`*^9}, 3.394993092328345*^9, 3.3951666893362055`*^9, 3.3985190818970733`*^9}] }, Open ]], Cell[TextData[{ "yields a result of ", Cell[BoxData["1"]], ". Now, evaluating" }], "Text", CellChangeTimes->{{3.3949928105856285`*^9, 3.394992821396454*^9}, { 3.3951666924807587`*^9, 3.3951666939328613`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"r", "=", FractionBox["1", "2"]}]], "Input", CellChangeTimes->{{3.3949928237710276`*^9, 3.394992824482398*^9}, { 3.3949929387725534`*^9, 3.3949929446739206`*^9}}], Cell[BoxData[ FractionBox["1", "2"]], "Output", CellChangeTimes->{ 3.394992825103595*^9, {3.3949929452049437`*^9, 3.3949929552242436`*^9}, 3.395166696196138*^9}] }, Open ]], Cell[TextData[{ "yields a result of ", Cell[BoxData[ FractionBox["1", "2"]]], ". However, notice that something else happened. The old answer of ", Cell[BoxData["1"]], " (from ", Cell[BoxData[Cell["Dynamic"]]], ") has been updated to ", Cell[BoxData[ FractionBox["1", "2"]]], ". We modified this example slightly to construct a graphical version with \ a varying radius gray disk." }], "Text", CellChangeTimes->{{3.394992827628458*^9, 3.394992923813738*^9}, { 3.394992966676304*^9, 3.3949929676782336`*^9}, {3.3949930138571873`*^9, 3.3949930219728203`*^9}, {3.395166700462315*^9, 3.39516670487871*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"r", "=", "1"}], ";"}], "\[IndentingNewLine]", 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", "]"}]}], "]"}]}], "}"}], "]"}]}], "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.3943875652218113`*^9, 3.394387567084527*^9}, {3.3949929876767564`*^9, 3.3949929930571203`*^9}}], Cell[BoxData[ GraphicsBox[{RectangleBox[{-1, -1}, {1, 1}], {GrayLevel[0.5], DiskBox[{0, 0}]}}, ImageSize->{151.99999999999991`, Automatic}]], "Output", CellChangeTimes->{3.3949929940891085`*^9, 3.394993095594637*^9, 3.3951667167859497`*^9}] }, Open ]], Cell["\<\ Note that the gray disk touches the black square. Now, evaluating\ \>", "Text", CellChangeTimes->{{3.3949930323027186`*^9, 3.3949930471513214`*^9}, 3.3985190021115513`*^9}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"r", "=", FractionBox["1", "2"]}]], "Input", CellChangeTimes->{{3.3949930251890154`*^9, 3.394993026301158*^9}}], Cell[BoxData[ FractionBox["1", "2"]], "Output", CellChangeTimes->{3.3949930275235124`*^9, 3.395166723145158*^9}] }, Open ]], Cell[TextData[{ "causes the radius of the gray disk to decrease. Since continually \ reassigning various values to ", Cell[BoxData["r"]], " is awkward, we can instead using a ", Cell[BoxData["Slider"]], " to control the value of ", Cell[BoxData["r"]], "." }], "Text", CellChangeTimes->{{3.394993051209138*^9, 3.3949930832007627`*^9}, { 3.3949931188594513`*^9, 3.3949931545982943`*^9}}], Cell["Here, we have", "Text", CellChangeTimes->{{3.394993002886054*^9, 3.3949930062325*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ 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.3943875652218113`*^9, 3.394387567084527*^9}}], Cell[BoxData[ RowBox[{"{", RowBox[{ GraphicsBox[{RectangleBox[{-1, -1}, {1, 1}], {GrayLevel[0.5], DiskBox[{0, 0}]}}], ",", SliderBox[Dynamic[$CellContext`r]]}], "}"}]], "Output", CellChangeTimes->{3.394565080197736*^9, 3.3945656917292705`*^9, 3.3945657987753296`*^9, 3.3948134047114086`*^9, 3.394993161371341*^9, 3.3951667317976856`*^9}] }, Open ]], Cell["\<\ Moving the slider controls the radius of the disk. Observe that this \ expression combines control and graphics, the core components of a game.\ \>", "Text", CellChangeTimes->{{3.394993169136299*^9, 3.394993193803815*^9}, { 3.3949932770574546`*^9, 3.3949933197027636`*^9}, {3.394993379616172*^9, 3.3949933882852182`*^9}, {3.3951667505848875`*^9, 3.3951667581358204`*^9}}], Cell[TextData[{ "In this example, we used a ", StyleBox["global", FontSlant->"Italic"], " variable ", Cell[BoxData["r"]], " to control the radius of the disk. If we create another copy of the \ graphics object, the slider for ", Cell[BoxData["r"]], " controls both objects." }], "Text", CellChangeTimes->{{3.394993169136299*^9, 3.394993193803815*^9}, { 3.3949932770574546`*^9, 3.3949933197027636`*^9}, {3.394993379616172*^9, 3.3949933882852182`*^9}, 3.3951667505848875`*^9}], Cell[CellGroupData[{ Cell[BoxData[ 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", "]"}]}], "]"}]}], "}"}], "]"}]], "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.394460506000094*^9, { 3.39499324469184*^9, 3.3949932635889363`*^9}}], Cell[BoxData[ GraphicsBox[{RectangleBox[{-1, -1}, {1, 1}], {GrayLevel[0.5], DiskBox[{0, 0}, Dynamic[$CellContext`r]]}}, ImageSize->{197.33333333333306`, Automatic}]], "Output", CellChangeTimes->{3.394565080367984*^9, 3.3945656918995185`*^9, 3.394565798895505*^9, 3.3948134048415976`*^9, 3.3949932643288546`*^9}] }, Open ]], Cell[CellGroupData[{ Cell["Exercises", "Exercise", CellChangeTimes->{{3.3949937414904766`*^9, 3.3949937443447514`*^9}}], Cell[TextData[{ StyleBox["1. Create a graphical object that consists of two red disks of \ radius ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["1"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" on a black background of size ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{"20", "\[Times]", "20"}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[". Use ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Dynamic"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" to recreate a list of sliders that control the position and \ radius of each disk in this graphics object. Modify your code to change the \ color of the disks to be green if they overlap.", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3949937599781666`*^9, 3.3949937638239264`*^9}, { 3.394993913277771*^9, 3.394994003843416*^9}, {3.3949942090607815`*^9, 3.394994222821391*^9}, {3.394994262340581*^9, 3.3949942658558464`*^9}}], Cell[TextData[{ StyleBox["2. Create a 3D graphics object that consists of three ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Sphere"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox["s of radii, ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["1"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["2"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", and ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["3"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", nested within each other. Use the ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{"Document", " ", "Center"}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" to determine the options that control the color and opacity \ (transparency) of these spheres. Create buttons that control the color of \ the spheres (say ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Red"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Green"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", or ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Blue"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[") and sliders that control the opacity of the spheres.", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3949937599781666`*^9, 3.3949937638239264`*^9}, { 3.394993913277771*^9, 3.394994003843416*^9}, {3.3949942090607815`*^9, 3.394994222821391*^9}, {3.3949942747091064`*^9, 3.394994274859331*^9}, { 3.3949944877138424`*^9, 3.3949945202166896`*^9}, {3.394994552629418*^9, 3.3949947091626024`*^9}, 3.460132982671875*^9}], Cell[TextData[{ StyleBox["3. Create a 2D sliders that controls position of a point ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" as it ranges over the square ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData[ RowBox[{ RowBox[{"0", "\[LessEqual]", "x", "\[LessEqual]", "1"}], ",", RowBox[{"0", "\[LessEqual]", "y", "\[LessEqual]", "1"}]}]], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[". Note that the slider partitions the square into 4 rectangles. \ Use the areas of these rectangles as weights in the function ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Blend"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[" to dynamically control the color of a test object. I suggest \ blending the colors ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Red"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Green"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["Blue"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[", and ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["White"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[".", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3949937599781666`*^9, 3.3949937638239264`*^9}, { 3.394993913277771*^9, 3.394994003843416*^9}, {3.3949942090607815`*^9, 3.394994222821391*^9}, {3.3949942747091064`*^9, 3.394994274859331*^9}, { 3.3949944877138424`*^9, 3.3949945202166896`*^9}, {3.394994552629418*^9, 3.3949947091626024`*^9}, {3.394995194064362*^9, 3.3949951972490363`*^9}, { 3.394995476256771*^9, 3.394995700396639*^9}, {3.3949957825872817`*^9, 3.3949958078042965`*^9}, 3.3985190203980284`*^9, 3.460133007484375*^9}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Slider2D", "[", RowBox[{"Dynamic", "[", RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}], "]"}], "]"}]], "Input", CellChangeTimes->{{3.394995591287589*^9, 3.394995601391715*^9}}], Cell[BoxData[ Slider2DBox[Dynamic[{$CellContext`x, $CellContext`y}]]], "Output", CellChangeTimes->{3.3949956019224567`*^9}] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "Creating local, dynamic variables using ", Cell[BoxData["DynamicModule"]] }], "Section", CellChangeTimes->{{3.394993415872183*^9, 3.394993435400035*^9}}], Cell[TextData[{ "In the last example, two separate graphical objects shared a global, \ dynamic variable ", Cell[BoxData["r"]], ". Good programming practice suggests that we avoid the use of global \ variables as much as possible (so one doesn't accidentally modify a crucial \ variable). ", StyleBox["Mathematica", FontSlant->"Italic"], " supports a functions that allows the user to create local, \ dynamically-changing variables, ", Cell[BoxData["DynamicModule"]], ". ", Cell[BoxData["DynamicModule"]], " takes a list of local variables that may change dynamically and \ expression. For example, we can turn the variable ", Cell[BoxData["r"]], " in our previous example into a local variable via" }], "Text", CellChangeTimes->{{3.394387456373124*^9, 3.3943874842237267`*^9}, { 3.3944605789364257`*^9, 3.3944605841440177`*^9}, {3.394993442009308*^9, 3.3949936218012114`*^9}, 3.398519022801509*^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}], 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.3945650804280715`*^9, 3.394565691959606*^9, 3.394565798955592*^9, 3.3948134049217134`*^9, 3.3949936267386065`*^9}] }, Open ]], Cell[TextData[{ "Now, observe setting ", Cell[BoxData[ RowBox[{"r", "=", FractionBox["1", "2"]}]]], " does not change the radius of the gray disk." }], "Text", CellChangeTimes->{{3.394993630864786*^9, 3.3949936585462465`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"r", "=", FractionBox["1", "2"]}]], "Input", CellChangeTimes->{{3.394993661690956*^9, 3.3949936629328165`*^9}}], Cell[BoxData[ FractionBox["1", "2"]], "Output", CellChangeTimes->{3.3949936638742266`*^9}] }, Open ]], Cell[CellGroupData[{ Cell["Exercises", "Exercise", CellChangeTimes->{{3.3949937414904766`*^9, 3.3949937443447514`*^9}}], Cell[TextData[{ StyleBox["Modify your solutions to each of the three previous exercises to \ use only local variables using ", FontColor->RGBColor[0.5, 0, 0.5]], Cell[BoxData["DynamicModule"], FontColor->RGBColor[0.5, 0, 0.5]], StyleBox[".", FontColor->RGBColor[0.5, 0, 0.5]] }], "ExerciseText", CellChangeTimes->{{3.3949937599781666`*^9, 3.3949937638239264`*^9}, { 3.394995707156561*^9, 3.394995745242465*^9}, {3.459258313078125*^9, 3.45925834040625*^9}}] }, Open ]] }, Open ]] }, WindowToolbars->{}, WindowSize->{1016, 1042}, WindowMargins->{{154, Automatic}, {Automatic, 4}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrintingOptions->{"PrintCellBrackets"->False, "PrintMultipleHorizontalPages"->False, "PrintRegistrationMarks"->True, "PrintingMargins"->{{54, 54}, {72, 72}}}, 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, 300, 6, 83, "Title"], Cell[848, 28, 295, 7, 93, "Subtitle"], Cell[1146, 37, 526, 12, 86, "Text"], Cell[CellGroupData[{ Cell[1697, 53, 230, 5, 82, "Section"], Cell[1930, 60, 628, 14, 60, "Text"], Cell[2561, 76, 1560, 45, 214, "Text"], Cell[4124, 123, 217, 4, 35, "Text"], Cell[CellGroupData[{ Cell[4366, 131, 216, 4, 97, "Input"], Cell[4585, 137, 193, 3, 68, "Output"], Cell[4781, 142, 279, 5, 68, "Output"] }, Open ]], Cell[5075, 150, 215, 6, 36, "Text"], Cell[CellGroupData[{ Cell[5315, 160, 191, 4, 96, "Input"], Cell[5509, 166, 169, 4, 88, "Output"] }, Open ]], Cell[5693, 173, 625, 16, 82, "Text"], Cell[CellGroupData[{ Cell[6343, 193, 888, 23, 97, "Input"], Cell[7234, 218, 251, 5, 276, "Output"] }, Open ]], Cell[7500, 226, 188, 4, 35, "Text"], Cell[CellGroupData[{ Cell[7713, 234, 138, 3, 96, "Input"], Cell[7854, 239, 114, 2, 88, "Output"] }, Open ]], Cell[7983, 244, 396, 11, 62, "Text"], Cell[8382, 257, 93, 1, 35, "Text"], Cell[CellGroupData[{ Cell[8500, 262, 1009, 27, 124, "Input"], Cell[9512, 291, 361, 8, 320, "Output"] }, Open ]], Cell[9888, 302, 388, 6, 60, "Text"], Cell[10279, 310, 492, 13, 62, "Text"], Cell[CellGroupData[{ Cell[10796, 327, 839, 21, 69, "Input"], Cell[11638, 350, 322, 5, 344, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[11997, 360, 99, 1, 56, "Exercise"], Cell[12099, 363, 964, 22, 86, "ExerciseText"], Cell[13066, 387, 1675, 43, 112, "ExerciseText"], Cell[14744, 432, 1875, 45, 112, "ExerciseText"], Cell[CellGroupData[{ Cell[16644, 481, 210, 5, 69, "Input"], Cell[16857, 488, 125, 2, 170, "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[17043, 497, 173, 4, 82, "Section"], Cell[17219, 503, 923, 21, 136, "Text"], Cell[CellGroupData[{ Cell[18167, 528, 1196, 30, 124, "Input"], Cell[19366, 560, 413, 9, 320, "Output"] }, Open ]], Cell[19794, 572, 236, 7, 46, "Text"], Cell[CellGroupData[{ Cell[20055, 583, 138, 3, 96, "Input"], Cell[20196, 588, 92, 2, 88, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[20325, 595, 99, 1, 56, "Exercise"], Cell[20427, 598, 471, 11, 36, "ExerciseText"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)