(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.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[ 17259, 557]*) (*NotebookOutlinePosition[ 17941, 580]*) (* CellTagsIndexPosition[ 17897, 576]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Graphing, Part 1", "Title"], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " has a variety of commands for graphing functions:\nPlot \[LongDash] graph \ a function of one variable, or graph several functions of one variable \ together.\nPlot3D \[LongDash] graph a function of two variables\nListPlot \ \[LongDash] create a 2D scatter plot of a data set\nListPlot3D \[LongDash] \ create a 3D scatter plot of a data set\nParametricPlot \[LongDash] graph a \ parametrically defined curve in a plane\nParametricPlot3D \[LongDash] graph a \ parametrically defined curve or surface in 3D\nContourPlot \[LongDash] \ display a contour plot of a function of two variables\nDensityPlot \ \[LongDash] similar to a contour plot\nListDensityPlot \[LongDash] density \ plot of a data set\nLogPlot, LogLogPlot, LogListPlot, LogLogListPlot, \ PolarPlot, ErrorListPlot, TextListPlot, BarChart, PieChart, PlotVectorField, \ ListPlotVectorField, SphericalPlot3D \[LongDash] and many more in ", StyleBox["Mathematica", FontSlant->"Italic"], "'s add-on packages." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Graphing functions of one variable", "Section"], Cell["\<\ In most basic version of a plot, the first argument is the function \ and the second argument is a list of three items representating the domain.\ \ \>", "Text"], Cell[BoxData[ \(\(Plot[ArcTan[x], {x, \(-6\), 6}];\)\)], "Input"], Cell[TextData[{ "Click on the graph that you created above. ", StyleBox["Mathematica", FontSlant->"Italic"], " will draw a box around the graph with small black squares at the corners \ and edges. You can drag these black squares to change the size of the graph \ on your screen. Once you have selected the graph, by clicking on it, you can \ read coordinates on the graph by holding down the \[ControlKey] key and \ moving the mouse over the graph. The coordinates appear in the bottom left \ corner of the notebook's window." }], "Text"], Cell[TextData[{ "You can add annotations to the graph using the ", StyleBox["AxesLabel", FontFamily->"Courier"], " and the ", StyleBox["PlotLabel", FontFamily->"Courier"], " options. " }], "Text"], Cell[BoxData[ \(\(Plot[Log[1 - x], {x, \(-3\), 1}, AxesLabel \[Rule] {"\", "\"}, PlotLabel \[Rule] "\"];\)\)], "Input"], Cell[CellGroupData[{ Cell["Plot options", "Subsection"], Cell[TextData[{ "Options, such as ", StyleBox["AxesLabel", FontFamily->"Courier"], " and the ", StyleBox["PlotLabel", FontFamily->"Courier"], ", appear after the last command argument and they are separated by commas. \ The syntax for an option is the option name followed by the minus and \ greater than characters, (which ", StyleBox["Mathematica", FontSlant->"Italic"], " automatically turns into the \[Rule] arrow character), followed by the \ value of the option. Each option has a default value, which is used when the \ option is not specified. The ", StyleBox["Plot", FontFamily->"Courier"], " command has many options. You can see all of ", StyleBox["Plot", FontFamily->"Courier"], "'s options and their default settings." }], "Text"], Cell[BoxData[ \(Options[Plot]\)], "Input"], Cell[TextData[{ "We already saw how to use ", StyleBox["AxesLabel", FontFamily->"Courier"], " and the ", StyleBox["PlotLabel", FontFamily->"Courier"], " as options for ", StyleBox["Plot", FontFamily->"Courier"], ". Let's look at some of its other most commonly used options. You can \ look these up in the Help Browser, just as you can look up any built in ", StyleBox["Mathematica", FontSlant->"Italic"], " command." }], "Text"], Cell[CellGroupData[{ Cell["AspectRatio", "Subsubsection"], Cell[TextData[{ StyleBox["AspectRatio", FontFamily->"Courier"], " specifies the ratio of the height to the width of the graph. The default \ value is 1/", StyleBox["GoldenRatio", FontFamily->"Courier"], ". The value, ", StyleBox["Automatic", FontFamily->"Courier"], ", will determine the height and width so that one unit on the horizontal \ axis is the same length as one unit on the vertical axis. Try plotting ", StyleBox["f", FontSlant->"Italic"], "(", StyleBox["x", FontSlant->"Italic"], ") = ", Cell[BoxData[ \(TraditionalForm\`x\^2\)]], " for -3 < ", StyleBox["x", FontSlant->"Italic"], " < 3 using both the default value for ", StyleBox["AspectRatio", FontFamily->"Courier"], " and using ", StyleBox["Automatic", FontFamily->"Courier"], " for the value of ", StyleBox["AspectRatio", FontFamily->"Courier"], ". You can also give a specific numerical value to ", StyleBox["AspectRatio", FontFamily->"Courier"], ", such as ", StyleBox["AspectRatio", FontFamily->"Courier"], "\[Rule]2.5." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["AxesOrigin", "Subsubsection"], Cell[TextData[{ StyleBox["AxesOrigin", FontFamily->"Courier"], " specifies the (", StyleBox["x", FontSlant->"Italic"], ", ", StyleBox["y", FontSlant->"Italic"], ") coordinates of the intersection of the horizontal and vertical axes. If \ you want to place them in the traditional location, use ", StyleBox["AxesOrigin", FontFamily->"Courier"], "\[Rule]{0,0}." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["PlotRange", "Subsubsection"], Cell[TextData[{ StyleBox["PlotRange", FontFamily->"Courier"], " allows you to specify the interval for the vertical axis in your plot. \ The default value is ", StyleBox["Automatic", FontFamily->"Courier"], ", which allows ", StyleBox["Mathematica", FontSlant->"Italic"], " to choose the interval for you. In the example below, we allow ", StyleBox["Mathematica", FontSlant->"Italic"], " to choose the interval and then we specify the interval to be -5 < ", StyleBox["y", FontSlant->"Italic"], " < 5." }], "Text"], Cell[BoxData[ \(\(Plot[Tan[x], {x, \(-2\) \[Pi], 2 \[Pi]}];\)\)], "Input"], Cell[BoxData[ \(\(Plot[Tan[x], {x, \(-2\) \[Pi], 2 \[Pi]}, PlotRange \[Rule] {\(-5\), 5}];\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["PlotStyle", "Subsubsection"], Cell[TextData[{ StyleBox["PlotStyle", FontFamily->"Courier"], " allows you to specify the appearance of the graph of the function. You \ can specify the thickness of the curve, the color of the curve, and the type \ of line (such as dashed or solid). We will have more to say about ", StyleBox["PlotStyle", FontFamily->"Courier"], " in the next section." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Ticks", "Subsubsection"], Cell[TextData[{ "You can specify the locations of the tick marks on the horizontal and \ vertical axes using the ", StyleBox["Ticks", FontFamily->"Courier"], " option. The default is ", StyleBox["Automatic", FontFamily->"Courier"], ", which allows ", StyleBox["Mathematica", FontSlant->"Italic"], " to automatically specify the tick marks. The value of ", StyleBox["Ticks", FontFamily->"Courier"], " is a list containing two lists. The first list is the numerical values \ of the ticks on the horizontal axis and the second list is the numerical \ values of the ticks on the vertical axis. The example below specifies the \ horizontal ticks, but allows ", StyleBox["Mathematica", FontSlant->"Italic"], " to specify the vertical ones." }], "Text"], Cell[BoxData[ \(\(Plot[Sin[x], {x, 0, 2\ \[Pi]}, Ticks \[Rule] {{0, \[Pi]\/2, \[Pi], \(3\ \[Pi]\)\/2, 2\ \[Pi]}, Automatic}];\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Exercise", "Subsubsection"], Cell[TextData[{ StyleBox["Exercise 4.1:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Find the critical points and inflection points of ", StyleBox["f", FontSlant->"Italic"], "(", StyleBox["x", FontSlant->"Italic"], ") = ", Cell[BoxData[ \(TraditionalForm\`\(4 x\^7 - 4 x\^5 - 3 x\^4 + 4 x\^3 + 12 x\^2 - \ 12\)\/x\^7\)]], ", and graph the function on an appropriate interval or intervals to show \ the graph's behavior at these points. You may need more than one graph." }], "Text", Background->GrayLevel[0.750011]] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Graphing two functions together", "Subsection"], Cell[TextData[{ "You can plot several functions together by making the first argument a \ list of functions. In ", StyleBox["Mathematica", FontSlant->"Italic"], ", lists are enclosed in curly braces, { }." }], "Text"], Cell[BoxData[ \(\(Plot[{Cos[x], 1 - x\^2/2}, {x, \(-2\) \[Pi], 2 \[Pi]}];\)\)], "Input"], Cell["\<\ And you can change the style of the graph. We have to load the \ Graphics`Colors` package if we want to use ordinary names for colors.\ \>", \ "Text"], Cell[BoxData[{ \(Needs["\"]\), "\[IndentingNewLine]", \(\(Plot[\[ExponentialE]\^\(-x\^2\), {x, \(-3\), 3}, PlotStyle \[Rule] {{Thickness[0.02], CadmiumYellow, Dashing[{0.05, 0.05}]}}, Background \[Rule] Azure, GridLines \[Rule] Automatic];\)\)}], "Input"], Cell["\<\ The individual functions in a plot can each have their own style. \ The PlotStyle option requires a list of lists. Each list is a collection of \ options for one function in the list of functions. In the example below, the \ first function is graphed in SeaGreen with the default solid line and the \ default thickness. The second function is graphed in Peacock with a dashed \ line of the default thickness.\ \>", "Text"], Cell[BoxData[ \(\(Plot[{\[ExponentialE]\^x, 1 + x}, {x, \(-2\), 2}, PlotStyle \[Rule] {{SeaGreen}, {Peacock, Dashing[{0.05, 0.05}]}}];\)\)], "Input"], Cell[TextData[{ StyleBox["Exercise 4.2:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Plot the sine and cosine functions using different colors and line \ thicknesses. If you want to experiment with new colors, all available color \ names are listed in the Help Browser under Add-ons\[Rule]Standard Packages\ \[Rule]Graphics\[Rule]Colors." }], "Text", Background->GrayLevel[0.750011]], Cell[TextData[{ "You can create several graphs without plotting them, and then display the \ graphs later. This will come in handy later when we want to combine graphs \ that are created with different ", StyleBox["Mathematica", FontSlant->"Italic"], " commands. You need to assign each graph to a variable so that you can \ refer to them later. You can specify how the plot is to be displayed using \ the ", StyleBox["DisplayFunction", FontFamily->"Courier"], " option. If you assign ", StyleBox["DisplayFunction", FontFamily->"Courier"], " the value ", StyleBox["Identity", FontFamily->"Courier"], ", then ", StyleBox["Mathematica", FontSlant->"Italic"], " will not display the graph." }], "Text"], Cell[BoxData[ \(\(topHalf = Plot[1 - \@Abs[x], {x, \(-1\), 1}, DisplayFunction \[Rule] Identity];\)\)], "Input"], Cell[BoxData[ \(\(bottomHalf = Plot[\@Abs[x] - 1, {x, \(-1\), 1}, DisplayFunction \[Rule] Identity];\)\)], "Input"], Cell[TextData[{ "The ", StyleBox["Show", FontFamily->"Courier"], " command displays graphics objects, such as ", StyleBox["topHalf", FontFamily->"Courier"], " and ", StyleBox["bottomHalf", FontFamily->"Courier"], ". ", StyleBox["Show", FontFamily->"Courier"], " can have any number of arguments. Each argument must be a graphics \ object. ", StyleBox["Show", FontFamily->"Courier"], " has the same options as ", StyleBox["Plot", FontFamily->"Courier"], ". We have to set ", StyleBox["DisplayFunction", FontFamily->"Courier"], " back to its default value, ", StyleBox["$DisplayFunction", FontFamily->"Courier"], ", which will make the graph display on the computer screen." }], "Text"], Cell[BoxData[ \(\(Show[topHalf, bottomHalf, DisplayFunction \[Rule] $DisplayFunction];\)\)], "Input"], Cell[TextData[{ "In the ", StyleBox["Show", FontFamily->"Courier"], " command, you can override options that were set in ", StyleBox["topHalf", FontFamily->"Courier"], " and ", StyleBox["bottomHalf", FontFamily->"Courier"], ", and you can set new options." }], "Text"], Cell[BoxData[ \(\(Show[topHalf, bottomHalf, DisplayFunction \[Rule] $DisplayFunction, PlotLabel \[Rule] "\"];\)\)], "Input"], Cell[TextData[{ StyleBox["Exercise 4.3:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " A capacitor in an electric circuit is charged for three seconds and then \ discharges for 3 more seconds. During the first three seconds, beginning \ with ", StyleBox["t", FontSlant->"Italic"], " = 0, the charge on the capacitor is ", Cell[BoxData[ \(TraditionalForm\`2.60 \[ExponentialE]\^\(0.2 t\)\)]], ". For the next three seconds, the charge is ", Cell[BoxData[ \(TraditionalForm\`15.73 \[ExponentialE]\^\(\(-0.4\) t\)\)]], ". Sketch the graph of the charge on the capacitor for the first 6 \ seconds." }], "Text", Background->GrayLevel[0.750011]] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Animations", "Section"], Cell[TextData[{ "You can create animations by displaying a sequence of individual graphs. \ In the following example, the ", StyleBox["Table", FontFamily->"Courier New"], " command, which is used to create lists, creates a list of graphs showing \ the Taylor polynomial approximations to Sin[x]. We use the ", StyleBox["PlotRange", FontFamily->"Courier New"], " option in order to guarantee that the range of ", StyleBox["y", FontSlant->"Italic"], " values for all of the graphs will be the same. Double-click on any of \ the graphs to start the animation. Controls will appear at the bottom of the \ window that allow you to adjust the speed of the animation." }], "Text"], Cell[BoxData[{ \(Needs["\"]\), "\[IndentingNewLine]", \(\(Table[ Plot[{Sin[ x], \[Sum]\+\(k = 0\)\%n\(\(\((\(-1\))\)\^k\) x\^\(2 k + 1\)\)\ \/\(\((2 k + 1)\)!\)}, {x, \(-4\) \[Pi], 4 \[Pi]}, PlotRange \[Rule] {\(-1.5\), 1.5}, PlotStyle \[Rule] {{EnglishRed}, {BlueViolet}}], {n, 0, 9}];\)\)}], "Input"], Cell["\<\ If you want to change the size of the plot, click on the first \ graph to select it, drag its corner to enlarge it, and then re-evaluation the \ command that created the list of graphs. This will re-create all of the \ graphs at the size of the first graph.\ \>", "Text"], Cell[TextData[{ StyleBox["Exercise 4.4:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Create an animation showing how different choices for ", StyleBox["a", FontSlant->"Italic"], " effect the graph of ", StyleBox["y", FontSlant->"Italic"], " = ", Cell[BoxData[ \(TraditionalForm\`x\^3 + \ a\ x\)]], ". Include both negative and positive values for ", StyleBox["a", FontSlant->"Italic"], ". Explain your findings." }], "Text", Background->GrayLevel[0.750011]] }, Closed]] }, Open ]] }, FrontEndVersion->"5.2 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 951}}, WindowSize->{1007, 924}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, StyleDefinitions -> "PastelColor.nb" ] (******************************************************************* 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, 33, 0, 98, "Title"], Cell[CellGroupData[{ Cell[1834, 57, 31, 0, 51, "Section"], Cell[1868, 59, 1057, 18, 260, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[2962, 82, 53, 0, 35, "Section"], Cell[3018, 84, 171, 4, 29, "Text"], Cell[3192, 90, 69, 1, 38, "Input"], Cell[3264, 93, 553, 10, 71, "Text"], Cell[3820, 105, 215, 8, 29, "Text"], Cell[4038, 115, 165, 3, 38, "Input"], Cell[CellGroupData[{ Cell[4228, 122, 34, 0, 39, "Subsection"], Cell[4265, 124, 789, 21, 71, "Text"], Cell[5057, 147, 46, 1, 38, "Input"], Cell[5106, 150, 466, 15, 50, "Text"], Cell[CellGroupData[{ Cell[5597, 169, 36, 0, 31, "Subsubsection"], Cell[5636, 171, 1107, 39, 71, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[6780, 215, 35, 0, 23, "Subsubsection"], Cell[6818, 217, 404, 14, 29, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[7259, 236, 34, 0, 23, "Subsubsection"], Cell[7296, 238, 555, 17, 50, "Text"], Cell[7854, 257, 79, 1, 38, "Input"], Cell[7936, 260, 119, 2, 38, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[8092, 267, 34, 0, 23, "Subsubsection"], Cell[8129, 269, 384, 9, 50, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[8550, 283, 30, 0, 23, "Subsubsection"], Cell[8583, 285, 794, 21, 71, "Text"], Cell[9380, 308, 166, 3, 50, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[9583, 316, 33, 0, 23, "Subsubsection"], Cell[9619, 318, 586, 17, 60, "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[10254, 341, 53, 0, 25, "Subsection"], Cell[10310, 343, 228, 6, 29, "Text"], Cell[10541, 351, 93, 1, 39, "Input"], Cell[10637, 354, 161, 4, 29, "Text"], Cell[10801, 360, 316, 5, 84, "Input"], Cell[11120, 367, 436, 7, 71, "Text"], Cell[11559, 376, 177, 3, 38, "Input"], Cell[11739, 381, 422, 9, 56, "Text"], Cell[12164, 392, 745, 21, 71, "Text"], Cell[12912, 415, 136, 3, 41, "Input"], Cell[13051, 420, 139, 3, 41, "Input"], Cell[13193, 425, 754, 27, 50, "Text"], Cell[13950, 454, 114, 2, 38, "Input"], Cell[14067, 458, 294, 11, 29, "Text"], Cell[14364, 471, 160, 2, 38, "Input"], Cell[14527, 475, 709, 18, 56, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[15285, 499, 29, 0, 35, "Section"], Cell[15317, 501, 703, 15, 71, "Text"], Cell[16023, 518, 388, 8, 90, "Input"], Cell[16414, 528, 282, 5, 50, "Text"], Cell[16699, 535, 532, 18, 35, "Text"] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)