(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 4.2' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. 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[ 14566, 429]*) (*NotebookOutlinePosition[ 15196, 451]*) (* CellTagsIndexPosition[ 15152, 447]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Graphs in Mathematica", "Subtitle"], Cell[TextData[{ "The goals of this lab:\n - To bring to your attention issues related to \ graphing in 2 and 3 dimensions.\n - To teach you how to use ", StyleBox["Mathematica", FontSlant->"Italic"], " to draw various graphs.\n - To have some fun with ", StyleBox["Mathematica", FontSlant->"Italic"], "'s graphing capabilities." }], "Text", FontSize->14], Cell[TextData[{ "Most of us have used a grapher before (other than ", StyleBox["Mathematica", FontSlant->"Italic"], "), most likely a graphing calculator. Using it, one has little difficulty \ graphing a specified function of one variable. For the graph of ", Cell[BoxData[ \(TraditionalForm\`f(x)\ = \ x\^2\)]], " for instance, one simply enters x^2 into the calculator and graphs it. \ ", StyleBox["Mathematica", FontSlant->"Italic"], " can produce the graph fairly easily with the Plot[ ] command:" }], "Text", FontSize->14], Cell[BoxData[ \(Plot[x^2, \ {x, \ \(-1\), \ 1}]\)], "Input"], Cell[TextData[{ "Most of us have come naturally to think of the horizontal axis as the ", StyleBox["x", FontSlant->"Italic"], "-axis and the vertical as the ", StyleBox["y", FontSlant->"Italic"], "-axis. This is in line with thinking of ", StyleBox["x", FontSlant->"Italic"], " as the input and ", StyleBox["y", FontSlant->"Italic"], " as the output., i.e.\n ", StyleBox["y = f(x)", FontSlant->"Italic"], "." }], "Text", FontSize->14], Cell[TextData[{ "At various stages along the way in your mathematical development, you \ probably encountered relationships between ", StyleBox["x", FontSlant->"Italic"], " and ", StyleBox["y", FontSlant->"Italic"], " which were not solved for ", StyleBox["y:\n\t", FontSlant->"Italic"], Cell[BoxData[ \(TraditionalForm\`x\^2\ + \ \((y\ - \ 1)\)\^2\ = \ 9\)]], " (a circle of radius 3 centered at (0, 1))\n\t", Cell[BoxData[ \(TraditionalForm\`3 x\^2\ + \ y\^\(\(2\)\(\ \)\) = \ 15\)]], " (an ellipse)\n\t", Cell[BoxData[ \(TraditionalForm\`3 x\^2\ - \ y\^\(\(2\)\(\ \)\) = \ 15\)]], " (an hyperbola)\nWhile none of these are functions (that is, \ none of them have precisely one output for each possible input, not even if \ we reverse the roles of ", StyleBox["x", FontSlant->"Italic"], " and ", StyleBox["y", FontSlant->"Italic"], " so as to view ", StyleBox["y", FontSlant->"Italic"], " as the independent variable), we know these equations have graphs. \ Generally speaking, a grapher usually needs us to pre-process the equation to \ produce the graph. For instance, for the circle, we could solve for ", StyleBox["y", FontSlant->"Italic"], " getting two functions and them graph them both to produce the full \ circle:\n\t", Cell[BoxData[ \(TraditionalForm\`x\^2\ + \ \((y - 1)\)\^2\ = \ 9\)]], "\t\[DoubleLongRightArrow]\t", Cell[BoxData[ \(TraditionalForm\`\((y\ - \ 1)\)\^2\ = \ 9\ - \ x\^2\)]], "\n\t\t\t\t\[DoubleLongRightArrow]\t", Cell[BoxData[ \(TraditionalForm\`y\ - \ 1\ = \ \(\[PlusMinus]\@\(9\ - \ x\^2\)\)\)]], "\n\t\t\t\t\[DoubleLongRightArrow]\t", Cell[BoxData[ \(TraditionalForm\`y\ \ = \ 1 \[PlusMinus] \@\(9\ - \ x\^2\)\)]] }], "Text", FontSize->14], Cell[TextData[{ StyleBox["Exercise 1", FontWeight->"Bold"], ":\nUse ", StyleBox["Mathematica", FontSlant->"Italic"], " to graph these two functions individually and then together. (Recall \ that for Lab 3 you also had to put together two graphs on the same coordinate \ axes.) If the graph does not look circular, you may need to add the option\n\ \tAspectRatio -> Automatic\nto your Plot[ ] command." }], "Text", FontSize->14], Cell[BoxData[ \(\[IndentingNewLine]\)], "Input"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " actually has an add-on command, ImplicitPlot[ ], which saves the user \ from the preprocessing that was done above. It is not a native command, and \ must be imported from the Graphics package (which explains the first line \ below). It requires the equation (the double-equals is used), the ", StyleBox["x", FontSlant->"Italic"], "-range and the ", StyleBox["y", FontSlant->"Italic"], "-range (both enclosed in curly brackets). Here we use the ImplicitPlot \ command to graph the hyperbola listed above:" }], "Text", FontSize->14], Cell[BoxData[{ \(<< Graphics`ImplicitPlot`\), "\[IndentingNewLine]", \(ImplicitPlot[ 3*x^2 - y^2 \[Equal] 15, {x, \(-4\), 4}, {y, \(-5\), 5}]\)}], "Input"], Cell[CellGroupData[{ Cell["Vector functions in 2 dimensions", "Subsection"], Cell[TextData[{ "When we discussed vector functions in the plane, we indicated that we were \ essentially talking about parametric equations. Suppose one wishes to plot \ the graph of\n\t", Cell[BoxData[ \(TraditionalForm\`\(r\&\[RightVector]\)( t)\ = \ \((3\ \(sin( 2\ t)\))\)\ i\&^\ - \ \((cos\ t)\)\ \(\(j\)\(.\)\)\&^\)]], "\nOne may use ", StyleBox["Mathematica", FontSlant->"Italic"], "'s built-in ParametricPlot command. ", StyleBox["Mathematica", FontSlant->"Italic"], "'s help menu says that one correct syntax for this command is\n\t", StyleBox["ParametricPlot[", "MR"], Cell[BoxData[ \(TraditionalForm\`{\)]], Cell[BoxData[ FormBox[ SubscriptBox[ StyleBox["\<\"f\"\>", "TI"], "x"], TraditionalForm]]], StyleBox[",", "MR"], " ", Cell[BoxData[ FormBox[ SubscriptBox[ StyleBox["\<\"f\"\>", "TI"], "y"], TraditionalForm]]], Cell[BoxData[ \(TraditionalForm\`}\)]], StyleBox[",", "MR"], " ", Cell[BoxData[ \(TraditionalForm\`{\)]], StyleBox["t", "TI"], StyleBox[",", "MR"], " ", StyleBox["tmin", "TI"], StyleBox[",", "MR"], " ", StyleBox["tmax", "TI"], Cell[BoxData[ \(TraditionalForm\`}\)]], StyleBox["]", "MR"], "\nWe use the command to plot the graph of ", Cell[BoxData[ \(TraditionalForm\`\(r\&\[RightVector]\)(t)\)]], " below for 0 \[LessEqual] ", StyleBox["t", FontSlant->"Italic"], " \[LessEqual] 3\[Pi]/2." }], "Text", FontSize->14], Cell[BoxData[ \(ParametricPlot[{3*Sin[2*t], \ Cos[t]}, {t, 0, 3*Pi/2}, AspectRatio \[Rule] Automatic]\)], "Input"], Cell[TextData[{ "In discussing vector functions in the plane, we have used the mental image \ of a particle moving around in the plane. The graph produced above shows the \ path such a particle traces out (dictated by this vector function), but it \ does not depict the particle actually in motion. Such motion would require \ something like a movie, where a particular frame displayed the path traced \ during the time interval 0 \[LessEqual] ", StyleBox["t", FontSlant->"Italic"], " \[LessEqual] T, and we produced a number of different frames, each \ corresponding to a different value of T. The basic idea, then, would be to \ run the command\n\tParametricPlot[{3*Sin[2*t], Cos[t]},{t,0,T}]\na bunch of \ times, each time using a different value of T. If you have had any \ experience in writing computer programs, you will be thinking that such a \ repetitive operation is best conducted within the context of a \"loop\". We \ will use ", StyleBox["Mathematica", FontSlant->"Italic"], "'s Do[ ] command (one of several which allow for looping). Take a look at \ ", StyleBox["Mathematica", FontSlant->"Italic"], "'s help screen for Do[ ]. You will see that there are several valid \ syntax options, one of which is the following, which repeats the command \ above (notice I also added the PlotRange option, so that all of the slides \ have the same viewing rectangle) once for each value of T between 0 and 10 in \ increments of 0.2." }], "Text", FontSize->14], Cell[BoxData[ \(Do[\[IndentingNewLine]ParametricPlot[{3*Sin[2*t], Cos[t]}, {t, 0, T}, PlotRange \[Rule] {{\(-3\), 3}, {\(-1\), 1}}], \[IndentingNewLine]{T, 0, 10, 0.2}]\)], "Input"], Cell[TextData[{ "\"That's all fine and good, but it's no movie --- just a lot of clutter on \ my screen\", I hear you saying. Now place your mouse cursor on any one of \ the frames above and double-click. What you will (should) see is ", StyleBox["Mathematica", FontSlant->"Italic"], " playing all of the frames together like a movie. (By default, I believe \ it starts the movie over immediately after all frames have been played.) One \ can dress up this movie further, but there's a limit to how much ", StyleBox["Mathematica", FontSlant->"Italic"], " we can absorb. If you're curious, execute the next cell. (I definitely \ do not advocate your trying to understand the blend of commands that goes \ into it.) Feel free to delete the graphs (the clutter) after you've had your \ fill of them." }], "Text", FontSize->14], Cell[BoxData[{ \(<< Graphics`Graphics`\), "\[IndentingNewLine]", \(Do[\[IndentingNewLine]DisplayTogether[ Graphics[\[IndentingNewLine]{{RGBColor[1, 0, 0], PointSize[0.03], Point[{3*Sin[2*T], Cos[T]}]}}], ParametricPlot[{3*Sin[2*t], Cos[t]}, {t, 0, T}], PlotRange \[Rule] {{\(-3\), 3}, {\(-1\), 1}}\[IndentingNewLine]], \[IndentingNewLine]{T, 0, 10, 0.2}]\)}], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Equations in 3 variables", "Subsection"], Cell[TextData[{ "So, how does one graph an equation in 3 variables? First off, the graph \ will require an ", StyleBox["xyz", FontSlant->"Italic"], "-frame (not just the ", StyleBox["xy", FontSlant->"Italic"], "-plane). None of the commands we've seen for graphing in ", StyleBox["Mathematica", FontSlant->"Italic"], " will work, but there are corresponding commands (similar names, followed \ by 3D) which do work." }], "Text", FontSize->14], Cell[TextData[{ "One's experience with a grapher that requires equations like the circle\n\t\ ", Cell[BoxData[ \(TraditionalForm\`x\^2\ + \ \((y\ - \ 1)\)\^2\ = \ 9\)]], "\nto be preprocessed (solved for ", StyleBox["y", FontSlant->"Italic"], ") in order to yield the graph is good preparation for what is necessary in \ 3 dimensions. For an equation in 3 variables, generally a grapher requires \ the equation be preprocessed --- in particular, solved for ", StyleBox["z", FontSlant->"Italic"], ", as in ", StyleBox["z = f(x,y)", FontSlant->"Italic"], " --- before it can be graphed. Even ", StyleBox["Mathematica", FontSlant->"Italic"], " does not have (to my knowledge) a convenient workaround for this (i.e., \ there is no ImplicitPlot3D command)." }], "Text", FontSize->14], Cell[TextData[{ StyleBox["Exercise 2", FontWeight->"Bold"], ":\nInvestigate the Plot3D[ ] command in ", StyleBox["Mathematica", FontSlant->"Italic"], " (using ", StyleBox["Mathematica", FontSlant->"Italic"], "'s help screens as necessary; you may be able to guess how to use the \ command without even looking at the online help), and use it to plot the \ graph of the plane\n\t", Cell[BoxData[ \(TraditionalForm\`3 x\ - \ 2 y\ - \ 2 z\ = \ 1. \)]], "\nThere are planes which you would be unable to graph in this fashion. \ Give examples of some." }], "Text", FontSize->14], Cell[BoxData[""], "Input"], Cell[TextData[{ StyleBox["Exercise 3", FontWeight->"Bold"], ":\nGraph the upper hemisphere centered at the origin with radius 1." }], "Text", FontSize->14] }, Open ]], Cell[CellGroupData[{ Cell["Vector functions in 3 dimensions", "Subsection"], Cell["\<\ In 3 dimensions, vector functions are the same as those in 2 \ dimensions but for the fact that they have one additional coordinate.\ \>", \ "Text", FontSize->14], Cell[TextData[{ StyleBox["Exercise 4", FontWeight->"Bold"], ":\nConsider the vector function\n\t", Cell[BoxData[ \(TraditionalForm\`\(r\&\[RightVector]\)( t)\ = \ \((sin\ t)\)\ i\&^\ - \ \((cos\ t)\)\ \(j\&^\)\ + \ \((t/ 2)\)\ \(\(k\&^\)\(.\)\)\)]], "\nTake a guess as to the path traced out by a particle whose position \ function is ", Cell[BoxData[ \(TraditionalForm\`\(\(\(r\& \[RightVector] \)(t)\)\(.\)\)\)]], " Then do the following:\n(a) Use the command ParametricPlot3D[ ] \ (investigate this command as necessary) to draw this trajectory for the \ interval 0 \[LessEqual] t \[LessEqual] 20.\n(b) Now make a movie (in like \ manner as was done above) showing the path as it gets traced out." }], "Text", FontSize->14] }, Open ]] }, Open ]] }, FrontEndVersion->"4.2 for X", ScreenRectangle->{{0, 1024}, {0, 768}}, WindowSize->{520, 600}, WindowMargins->{{172, Automatic}, {47, Automatic}} ] (******************************************************************* 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[1776, 53, 41, 0, 64, "Subtitle"], Cell[1820, 55, 383, 10, 90, "Text"], Cell[2206, 67, 563, 14, 109, "Text"], Cell[2772, 83, 64, 1, 27, "Input"], Cell[2839, 86, 479, 18, 90, "Text"], Cell[3321, 106, 1868, 50, 292, "Text"], Cell[5192, 158, 447, 11, 128, "Text"], Cell[5642, 171, 52, 1, 43, "Input"], Cell[5697, 174, 624, 15, 128, "Text"], Cell[6324, 191, 170, 3, 43, "Input"], Cell[CellGroupData[{ Cell[6519, 198, 54, 0, 45, "Subsection"], Cell[6576, 200, 1560, 54, 170, "Text"], Cell[8139, 256, 125, 2, 43, "Input"], Cell[8267, 260, 1499, 28, 356, "Text"], Cell[9769, 290, 203, 3, 75, "Input"], Cell[9975, 295, 850, 16, 185, "Text"], Cell[10828, 313, 442, 8, 155, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[11307, 326, 46, 0, 45, "Subsection"], Cell[11356, 328, 472, 14, 90, "Text"], Cell[11831, 344, 829, 22, 166, "Text"], Cell[12663, 368, 616, 17, 147, "Text"], Cell[13282, 387, 26, 0, 27, "Input"], Cell[13311, 389, 165, 5, 52, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[13513, 399, 54, 0, 45, "Subsection"], Cell[13570, 401, 174, 5, 52, "Text"], Cell[13747, 408, 791, 17, 186, "Text"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)