(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 9456, 267]*) (*NotebookOutlinePosition[ 10165, 292]*) (* CellTagsIndexPosition[ 10121, 288]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Animated Water Waves", "Title", TextAlignment->Center, Background->RGBColor[0, 1, 0]], Cell["\<\ This notebook is by Steven Amgott. Please send any questions or comments to \ samgott1@swarthmore.edu. Feel free to use and distribute this notebook, but \ keep this author information in any copy you use or distribute.\ \>", "SmallText"], Cell["\<\ A problem in a multivariable book I have used asks us to describe the motion \ of the water surface in a small pool where the height of the water above the \ bottom of the pool is given by the function of three variables\ \>", "Text"], Cell["h(x,y,t) = 20 + sin(x+y-t).", "Text", TextAlignment->Center, TextJustification->0], Cell[TextData[{ "We can get ", StyleBox["Mathematica", FontSlant->"Italic"], " to do this for us, using its ability to animate a group of cells. We can \ create the cells manually, or use a special ", StyleBox["Mathematica", FontSlant->"Italic"], " command ", StyleBox["Animate", FontColor->RGBColor[1, 0, 0]], " to do so. This command is in the add-on package ", StyleBox["Graphics`Animation`", FontColor->RGBColor[1, 0, 0]], ", which is loaded into memory by the ", StyleBox["Needs", FontColor->RGBColor[1, 0, 0]], " command in the next cell. I have made it an initialization cell, so it \ will be evaluated automatically the first time any other cell in this \ notebook is evaluated, provided you answer \"", StyleBox["Yes", FontColor->RGBColor[0, 0, 1]], "\" to the initialization request." }], "Text"], Cell[BoxData[ \(\(Needs["\"]; \)\)], "Input", PageWidth->Infinity, InitializationCell->True, AnimationCycleOffset->1, AnimationCycleRepetitions->Infinity], Cell[TextData[{ "The syntax for ", StyleBox["Animate", FontColor->RGBColor[1, 0, 0]], " consists of the ", StyleBox["Mathematica", FontSlant->"Italic"], " syntax needed to draw the graphs, together with a t-iteration. See the ", StyleBox["Help", FontColor->RGBColor[0, 0, 1]], " menu for more details, looking in ", StyleBox["Add-ons", FontColor->RGBColor[0, 0, 1]], " under ", StyleBox["Standard Packages...Graphics...Animation", FontColor->RGBColor[0, 0, 1]], ". In the sections below I provide the necessary syntax." }], "Text"], Cell[TextData[{ "Once you have created the graphs, you can animate them as follows:\n\n1) \ Click on the outer bracket that groups all the cells that you wish to \ animate. The bracket should turn bold and black.\n\n2) Either use ", StyleBox["Animate Selected Graphics", FontColor->RGBColor[0, 0, 1]], " from the ", StyleBox["Cell", FontColor->RGBColor[0, 0, 1]], " menu, or use ", StyleBox["Ctrl-Y", FontColor->RGBColor[0, 0, 1]], " (", StyleBox["Apple-Y", FontColor->RGBColor[0, 0, 1]], " on a Macintosh) from the keyboard (hold the ", StyleBox["Ctrl", FontColor->RGBColor[0, 0, 1]], " key and press the ", StyleBox["Y", FontColor->RGBColor[0, 0, 1]], " key) to run the animation.\n\n3) You can use the \"VCR-like\" controls \ at the bottom of the window to control the animation once it is running.\n\n\ 4) To (possibly) get a smoother animation, you need to create more graphs. \ This can be done by changing the step size (in blue in the cells) to a \ smaller value, and re-evaluating the cell. It will take longer to produce \ the graphs as the step size gets smaller." }], "Text"], Cell[CellGroupData[{ Cell["Surfaces", "Section"], Cell["\<\ The two variable function f(x,y,t) with t fixed has a graph which is a \ surface. We can create such surfaces for many values of t, and then animate \ them. The cell below creates the surfaces, set up to be animated.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Animate", "[", RowBox[{ \(Plot3D[20 + Sin[x + y - t], {x, \(-10\), 10}, {y, \(-10\), 10}, PlotPoints \[Rule] 30, PlotRange \[Rule] {19, 21}]\), ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", \(2\ \[Pi]\), ",", StyleBox[\(\[Pi]\/4\), FontColor->RGBColor[0, 0, 1]]}], "}"}]}], "]"}], ";"}]], "Input", PageWidth->WindowWidth, CellMargins->{{Inherited, 0}, {Inherited, Inherited}}, AnimationCycleOffset->1, AnimationCycleRepetitions->Infinity], Cell["\<\ For fixed t, the surface is that of a snapshot of waves in the pool. At a \ particular point (x,y), as t changes, the height varies up and down \ sinusoidally between 19 and 21 meters. It is perhaps a little more \ interesting to see what happens to the whole surface as t increases, which is \ shown in the animation. We see waves traveling toward the north-east.\ \>", "Text"], Cell["\<\ We can, of course, view the surfaces from a different viewpoint. You may \ wish to experiment with different viewpoints.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Animate", "[", RowBox[{ \(Plot3D[20 + Sin[x + y - t], {x, \(-10\), 10}, {y, \(-10\), 10}, PlotPoints \[Rule] 30, PlotRange \[Rule] {19, 21}, ViewPoint -> {2.358, \ \(-2.250\), \ 0.910}]\), ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", \(2\ \[Pi]\), ",", StyleBox[\(\[Pi]\/4\), FontColor->RGBColor[0, 0, 1]]}], "}"}]}], "]"}], ";"}]], "Input", PageWidth->WindowWidth, CellMargins->{{Inherited, 0}, {Inherited, Inherited}}, AnimationCycleOffset->1, AnimationCycleRepetitions->Infinity] }, Closed]], Cell[CellGroupData[{ Cell["Contour plots", "Section"], Cell[TextData[{ "We can also animate contour plots instead of surface plots in the same \ fashion. (The next cell may take a little while to evaluate as ", StyleBox["PlotPoints", FontColor->RGBColor[1, 0, 0]], " is set to 50.)" }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Animate", "[", RowBox[{ \(ContourPlot[ 20 + Sin[x + y - t], {x, \(-10\), 10}, {y, \(-10\), 10}, PlotPoints \[Rule] 50, PlotRange \[Rule] {19, 21}]\), ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", \(2\ \[Pi]\), ",", StyleBox[\(\[Pi]\/4\), FontColor->RGBColor[0, 0, 1]]}], "}"}]}], "]"}], ";"}]], "Input", PageWidth->WindowWidth, CellMargins->{{Inherited, 0}, {Inherited, Inherited}}, AnimationCycleOffset->1, AnimationCycleRepetitions->Infinity], Cell[TextData[ "For fixed values of t, the contours of the surface given by 20+sin(x+y-t) \ are sets of parallel lines. We can see this by noting that the contours \ exist for heights between 19 and 21. Given any such height, the contour \ consists of all points (x,y) such that 20 + sin(x+y) is that height. We need \ to find the points where sin(x+y) is the height minus 20. There are an \ infinite number of angles \[Theta] such that sin(\[Theta]) is a particular \ number between -1 and 1, so the contour consists of the lines x+y = \[Theta] \ for those values of \[Theta] (a set of parallel lines with slopes -1). As t \ increases, these contours \"move\" to the north-east."], "Text"], Cell[TextData[{ "(A note: ", StyleBox["Mathematica", FontSlant->"Italic"], " is doing things numerically, which can lead to features in the displayed \ graphs that aren't actually there. The first graphs I drew had contours \ which did not look like straight lines. I had to increase ", StyleBox["PlotPoints", FontColor->RGBColor[1, 0, 0]], " to minimize such features. You can redraw the graphs with smaller values \ of ", StyleBox["PlotPoints", FontColor->RGBColor[1, 0, 0]], " to see what I mean.)" }], "Text"] }, Closed]] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 720}}, AutoGeneratedPackage->None, WindowToolbars->"EditBar", WindowSize->{519, 540}, WindowMargins->{{19, Automatic}, {Automatic, 5}} ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1739, 51, 95, 2, 121, "Title"], Cell[1837, 55, 250, 4, 60, "SmallText"], Cell[2090, 61, 244, 4, 71, "Text"], Cell[2337, 67, 92, 2, 33, "Text"], Cell[2432, 71, 859, 23, 128, "Text"], Cell[3294, 96, 188, 5, 30, "Input", InitializationCell->True], Cell[3485, 103, 578, 18, 90, "Text"], Cell[4066, 123, 1144, 27, 280, "Text"], Cell[CellGroupData[{ Cell[5235, 154, 27, 0, 53, "Section"], Cell[5265, 156, 242, 4, 71, "Text"], Cell[5510, 162, 576, 14, 62, "Input"], Cell[6089, 178, 391, 6, 90, "Text"], Cell[6483, 186, 145, 3, 52, "Text"], Cell[6631, 191, 634, 15, 82, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[7302, 211, 32, 0, 33, "Section"], Cell[7337, 213, 250, 6, 52, "Text"], Cell[7590, 221, 594, 15, 82, "Input"], Cell[8187, 238, 695, 9, 147, "Text"], Cell[8885, 249, 543, 14, 90, "Text"] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)