(*********************************************************************** 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[ 73062, 2585]*) (*NotebookOutlinePosition[ 73830, 2612]*) (* CellTagsIndexPosition[ 73786, 2608]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "An Overview of ", StyleBox["Mathematica", FontSlant->"Italic"] }], "Title", PageWidth->PaperWidth], Cell[CellGroupData[{ Cell["General Information", "Section", PageWidth->PaperWidth], Cell[TextData[{ "OBJECTIVE: Learn the basic features, characteristics, and language \ structure of ", StyleBox["Mathematica", FontSlant->"Italic"], ".\n\nThe working environment for ", StyleBox["Mathematica", FontSlant->"Italic"], " is called a notebook. This Overview is an example of a ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook. Each notebook is divided into cells as indicated by the blue \ brackets on the right margin of the page. A cell that contains executable \ commands is called an input cell and has a small triangle at the upper end of \ the cell bracket. If you start to type in a ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook, by default the program understands the typing as an executable \ command and so will open a new input cell. To type other kinds of cells, like \ the titles above or the text in this cell, for example, pull down the ", "Format", " menu at the top of the page and select Style.\n\nYou can type several \ commands in a single cell by separating the commands with semicolons and/or \ by pressing the return key (i.e., Enter on the QWERTY keypad). If a semicolon \ follows a command, its output is suppressed. If you wish to type a command in \ a new cell, you can press the down arrow key or mouse click a new cell. A new \ cell will start where a horizontal line appears across the notebook page.\n\n\ To execute a ", StyleBox["Mathematica", FontSlant->"Italic"], " command or group of commands in a cell, place the cursor anywhere in the \ cell containing the command(s) to be executed and click the left mouse \ button. Typing Shift-Enter on the QWERTY keyboard or pressing Enter on the \ numeric keypad executes the command(s) in the cell. All of the commands in a \ cell are executed in sequence from the first to the last.\n\nIn mathematical \ formulas, use of the times symbol (*) for multiplication is optional. \ However, if two or more symbol names are to be multiplied they must be \ separated by spaces so that ", StyleBox["Mathematica", FontSlant->"Italic"], " does not interpret the symbols together as a different symbol name. If a \ symbol pre-multiplies a constant, it must also be separated from the constant \ by a space for the same reason. \n\nThere are several palettes available for \ typing standard mathematical forms in commands and in text cells. These are \ found in the File (Palettes) pull-down menu. The BasicInput palette is one of \ the most useful.\n\nThe Help pull-down menu is extremely useful when using ", StyleBox["Mathematica", FontSlant->"Italic"], ". Formats for ", StyleBox["Mathematica", FontSlant->"Italic"], " commands are usually given with several examples that can be executed \ right in the Help window.\n\nIn the Introduction section of each module, \ there is a set of ", StyleBox["Technology Guidelines", FontWeight->"Bold"], " contained in a cell that is normally closed. Until you get used to ", StyleBox["Mathematica", FontSlant->"Italic"], ",", " you should open the cell and read the guidelines before continuing with \ the rest of the module. The following shows what the guidelines say." }], "Text", PageWidth->PaperWidth], Cell[CellGroupData[{ Cell["Technology Guidelines", "Subsection", PageWidth->PaperWidth, CellDingbat->"\[LightBulb]"], Cell[TextData[{ StyleBox["NOTE: If you have just finished a module, restart ", CellFrame->True, Background->None], StyleBox["Mathematica", CellFrame->True, FontSlant->"Italic", Background->None], StyleBox[" before executing a new module.\nTO OPEN CELLS, put your cursor \ on the right cell bracket and double click.", CellFrame->True, Background->None], "\nINITIALIZATION CELLS\n\tWhen asked if you want to \". . . automatically \ evaluate all the initialization cells in the \tnotebook . . . ,\" respond by \ pressing the \"Yes\" button.\nTO STOP AN EXECUTION\n\tSelect the ", StyleBox["Kernel", FontSlant->"Italic"], " pull-down menu and click on ", StyleBox["Abort Evaluation.\n", FontSlant->"Italic"], "ORDER OF EXECUTION\n\tExecute cells in the order given. Do not skip any \ Input cells within a given notebook.\nSAVING NOTEBOOKS\n\tYou can save \ anytime to any directory you choose, and it is wise to save often.\n\t \ However, before you do your final save, delete all your output by selecting \ the \n\t ", StyleBox["Delete All Output", FontSlant->"Italic"], " selection under the ", StyleBox["Kernel", FontSlant->"Italic"], " pull-down menu.\nEXPERIENCING MAJOR PROBLEMS\n\tSave if appropriate, and \ then shut down ", StyleBox["Mathematica", FontSlant->"Italic"], " and start it up again." }], "Text", PageWidth->PaperWidth] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Built-In Commands", "Section", PageWidth->PaperWidth], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " commands consist of a word or a string of words followed immediately \ (i.e., no spaces) by a series of arguments enclosed in a pair of square \ brackets ", StyleBox["[ ]", FontWeight->"Bold"], ". The following are examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Sin[Pi/4]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(Sqrt[16]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(Abs[x]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(ExpandNumerator[\((a - b)\)^2/\((c + d)\)^3]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(Solve[x^2 == 2, \ x]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Note that the symbol ", Cell[BoxData[ FormBox[ StyleBox["==", FontWeight->"Bold"], TraditionalForm]]], " (pronounced \"double equals\") is used to represent mathematical \ equality. This is necessary because the symbol ", Cell[BoxData[ FormBox[ StyleBox["=", FontWeight->"Bold"], TraditionalForm]]], " is reserved for making assignments to symbol names. (See the ", StyleBox["Assignment Commands", FontFamily->"Arial", FontWeight->"Bold"], " section later in this Overview.)" }], "Text", PageWidth->PaperWidth], Cell["\<\ Words in the command string typically begin with a single capital letter that \ is followed by lowercase letters. The command in the fourth example consists \ of two words. In most multiple-word commands, each word begins with a capital \ letter, and there are no spaces between the words. Also, there is no space \ between the word in the command string and the opening square bracket that \ begins the argument list.\ \>", "Text", PageWidth->PaperWidth], Cell[TextData[{ "In the first four preceding commands, the list of arguments contains only \ one item, whereas, in the ", StyleBox["Solve[ ] ", FontWeight->"Bold"], "command, the list of arguments contains two items, the equation to solve \ and the symbol that is to be isolated in the solution. When a command has \ more than one argument, they are separated by commas." }], "Text", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Lists ", "Section", PageWidth->PaperWidth], Cell[TextData[{ "Another important structure in ", StyleBox["Mathematica", FontSlant->"Italic"], " is the list. A list is any ordered array of things. In ", StyleBox["Mathematica", FontSlant->"Italic"], ", lists are enclosed in a pair of curly brackets ", StyleBox["{ }", FontWeight->"Bold"], ", ", "and the items in the list are separated by commas. The following are \ examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \({a, b, c, d}\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \({a, a^2, a^3, a^4}\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \({{1, 2}, {2, 3}, {3, 4}}\)], "Input", PageWidth->PaperWidth], Cell["\<\ The last list consists of three items, and each of these items is a list of \ two items.\ \>", "Text", PageWidth->PaperWidth], Cell[TextData[{ "A list of lists can also be thought of as a matrix or an array. The ", StyleBox["MatrixForm[ ]", FontWeight->"Bold"], " command shows a list of lists in more standard matrix form." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(MatrixForm[{{1, 2}, {2, 3}, {3, 4}}]\)], "Input", PageWidth->PaperWidth], Cell["\<\ Each list inside the list is a row of the matrix. Note that while the MatrixForm of a list makes it more readable, this form \ won't work in calculations. For use in calculations, a list must be in the \ curly bracket { } form.\ \>", "Text", PageWidth->PaperWidth], Cell[TextData[{ "Another useful way to display and view the information in a list is with \ the ", StyleBox["TableForm[ ]", FontWeight->"Bold"], " command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(TableForm[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Row and column labels can be added with a ", StyleBox["TableHeadings", FontWeight->"Bold"], " specification inside the ", StyleBox["TableForm[ ]", FontWeight->"Bold"], " command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(TableForm[{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}}, TableHeadings \[Rule] {{"\", "\"}, {"\", "\", "\", "\", \ "\"}}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Like the ", StyleBox["MatrixForm", FontWeight->"Bold"], " of a list, the ", StyleBox["TableForm", FontWeight->"Bold"], " cannot be used in calculations. For use in calculations, a list must be \ in curly bracket { } form." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "Sometimes one or more of the arguments of a ", StyleBox["Mathematica", FontSlant->"Italic"], " command is a list. For example, the following ", StyleBox["Plot[ ]", FontWeight->"Bold"], " command has two arguments, the first is the function to plot, and the \ second is a list that specifies the domain for the graph." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Plot[x^2, {x, \(-2\), 2}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The ", StyleBox["Table[ ] ", FontWeight->"Bold"], "command is very useful for generating a list when you know a formula for \ the elements in the list, as in the following examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Table[2*i, {i, 1, 5}]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(Table[2, {i, 1, 10}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "In the ", StyleBox["Table[ ] ", FontWeight->"Bold"], "command, the first argument is a function of the index variable. This \ function generates the elements in the list for the corresponding values of \ the index variable; the second argument is called an iterator. An iterator is \ a list that contains the symbol for the index variable, the beginning value, \ the ending value, and an optional increment or step size. If no value is \ specified for the increment, the default value is 1. Iterators are used in \ many other ", StyleBox["Mathematica", FontSlant->"Italic"], " commands." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "In the second example above, the index ", StyleBox["i", FontWeight->"Bold"], " is not used in the formula. You can use an alternate form for this second \ case, as shown in the next example. For the iterator, you simply specify the \ number of elements in the list." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Table[2, {10}]\)], "Input", PageWidth->PaperWidth], Cell["\<\ You can generate lists of lists in a variety of ways. For example, the \ formula for the elements in the list can be a function of two indices.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Table[i*j, {i, 1, 5}, {j, \(-2\), 2}]\)], "Input", PageWidth->PaperWidth], Cell["Or you can generate the same list like this.", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Table[{\(-2\)*i, \(-i\), 0, i, 2*i}, {i, 1, 5}]\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["2-D Plots", "Section", PageWidth->PaperWidth], Cell[TextData[{ "There are numerous two-dimensional plot commands in ", StyleBox["Mathematica", FontSlant->"Italic"], " that we use to generate graphical displays of functions and data. \n\nThe \ ", StyleBox["Plot[ ]", FontWeight->"Bold"], " command is used to graph functions of the form ", Cell[BoxData[ \(TraditionalForm\`y = f(x)\)]], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Plot[x*Sin[x], {x, \(-4\)*Pi, 4*Pi}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The first argument of the ", StyleBox["Plot[ ] ", FontWeight->"Bold"], "command is the function to graph, and the second is a list that contains \ the independent variable, plus the left and right ends of the domain over \ which you wish to graph the function. These first two arguments are required, \ but, as you will see, you can add other specifications.\n\nNote that a \ semicolon (;) at the end of a ", StyleBox["Mathematica", FontSlant->"Italic"], " command normally suppresses display of the output from the command. In \ the first of the two commands that follow we omit the semicolon and in the \ second one we do not." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\@4\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(\@4;\)\)], "Input", PageWidth->PaperWidth], Cell["\<\ After a graphics command, however, a semicolon does not suppress printing of \ the graphics. It is usually best to include the semicolon after graphics \ commands to save memory. We do so in the remainder of this part.\ \>", "Text", PageWidth->PaperWidth], Cell[TextData[{ "By default, ", StyleBox["Mathematica", FontSlant->"Italic"], " selects the range (vertical limits) for the graph. However, you can \ override this by specifying your own ", StyleBox["PlotRange", FontWeight->"Bold"], " as follows." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(Plot[x*Sin[x], {x, \(-4\)*Pi, 4*Pi}, PlotRange \[Rule] {\(-2\), 10}];\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "You can format a graph by specifying a wide variety of options after the \ first two required arguments in the ", StyleBox["Plot[ ]", FontWeight->"Bold"], " command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(Plot[x*Sin[x], {x, \(-4\)*Pi, 4*Pi}, AxesLabel \[Rule] {"\", "\"}, PlotStyle \[Rule] {RGBColor[0, 0, 1], Thickness[0.01]}];\)\)], "Input",\ PageWidth->PaperWidth], Cell[TextData[{ "The ", StyleBox["PlotStyle", FontWeight->"Bold"], " option is used to change the attributes of a graph, such as the color and \ line thickness, as shown in the preceding cell. If you want help in selecting \ a color, place the cursor where you want the ", StyleBox["RGBColor[ ]", FontWeight->"Bold"], " indicator, or highlight an existing indicator (like the one in the \ command above), and then pull down the Input menu and select Color-Selector. \ When you choose a color from the palette, the corresponding ", StyleBox["RGBColor[ ]", FontWeight->"Bold"], " indicator is inserted where you placed the cursor. The arguments of ", StyleBox["RGBColor[ ] ", FontWeight->"Bold"], "are three numbers that can each range from 0 to 1. The first number \ specifies the amount of red in the color, the second number the amount of \ green, and the third number the amount of blue. For example, ", StyleBox["RGBColor[1, 0, 0] ", FontWeight->"Bold"], "gives full red and no green or blue." }], "Text", PageWidth->PaperWidth], Cell["\<\ The following command plots three functions on the same graph; each curve is \ a different color, and the third one is thicker.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(Plot[{Sin[x], Sin[2*x], Sin[3*x]}, {x, \(-Pi\), Pi}, PlotStyle \[Rule] {{RGBColor[1, 0, 0]}, {RGBColor[0, 1, 0]}, {RGBColor[0, 0, 1], Thickness[0.01]}}];\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Note that inside the ", StyleBox["PlotStyle", FontWeight->"Bold"], " list, the attributes for each of the three graphs are specified in \ separate lists." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "The ", StyleBox["ListPlot[ ] ", FontWeight->"Bold"], "command is used to plot a list of values." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(plotvalues = Table[i^2, {i, 0, 5}]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(ListPlot[plotvalues, AxesLabel \[Rule] {"\", \*"\"\<\!\(i\^2\)\>\""}, PlotStyle \[Rule] {RGBColor[0, 0, 1], PointSize[0.02]}];\)\)], "Input",\ PageWidth->PaperWidth], Cell[TextData[{ "In the preceding example, the ", StyleBox["x", FontSlant->"Italic"], "-coordinate values of the plot points are taken to be 1, 2, . . . by \ default." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "You can also use the ", StyleBox["ListPlot[ ] ", FontWeight->"Bold"], "command to plot lists of values where both coordinates are specified." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(plotvalues = Table[{i, Sin[200. *i]}, {i, 0, 150}]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(ListPlot[plotvalues, AxesLabel \[Rule] {"\", "\"}, PlotStyle \[Rule] {RGBColor[0, 0, 1], PointSize[0.025]}];\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Just as you can in the ", StyleBox["Plot[ ] ", FontWeight->"Bold"], "command, you can specify formatting options in the ", StyleBox["ListPlot[ ]", FontWeight->"Bold"], " command, as shown in the preceding cell." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "There is one more two-dimensional plot command that you may find useful. \ It is ", StyleBox["ParametricPlot[ ]", FontWeight->"Bold"], ". You can use this command to plot curves that are specified in parametric \ form. For example, if the ", StyleBox["x", FontSlant->"Italic"], "-coordinates of the points on a curve are given by ", Cell[BoxData[ FormBox[ RowBox[{"x", "=", RowBox[{"t", " ", "cos", " ", StyleBox["t", FontSlant->"Italic"]}]}], TraditionalForm]]], " and the ", StyleBox["y", FontSlant->"Italic"], "-coordinates by ", Cell[BoxData[ \(TraditionalForm\`y = t\ sin\ t\)]], ", then the curve can be graphed like this." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(ParametricPlot[{t*Cos[t], t*Sin[t]}, {t, 0, 8*Pi}, AxesLabel \[Rule] {"\", "\"}, PlotStyle \[Rule] {RGBColor[1, 0, 0], Thickness[0.010]}, AspectRatio \[Rule] 1];\)\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["3-D Plots", "Section", PageWidth->PaperWidth], Cell[TextData[{ "There are numerous ", StyleBox["Mathematica", FontSlant->"Italic"], " commands for plotting three-dimensional functions and data. In this \ section, we introduce two of them and in later modules we will introduce \ more.\n\nThe ", StyleBox["Plot3D[ ] ", FontWeight->"Bold"], "command is used to plot functions of two independent variables, that is, \ functions of the form ", Cell[BoxData[ \(TraditionalForm\`z = f(x, y)\)]], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Plot3D[Sin[x]*Cos[y], {x, \(-Pi\), Pi}, {y, \(-Pi\), Pi}, AxesLabel \[Rule] {"\", "\", "\"}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The first three arguments of the ", StyleBox["Plot3D[ ] ", FontWeight->"Bold"], "command are required They are: 1) the function to graph, 2) a list that \ specifies the first independent variable and its limits for the graph, and 3) \ a second list that specifies the second independent variable and its limits. \ As is the case with two-dimensional graphics, you can specify a number of \ formatting options after the first three arguments in the command.\n\nTo \ change the viewpoint for the graph, you can include a ", StyleBox["ViewPoint ", FontWeight->"Bold"], "indicator as an option in the ", StyleBox["Plot3D[ ]", FontWeight->"Bold"], " command. " }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Plot3D[Sin[x]*Cos[y], {x, \(-Pi\), Pi}, {y, \(-Pi\), Pi}, AxesLabel \[Rule] {"\", "\", "\"}, ViewPoint -> {2.354, \ 2.427, \ 0.127}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "If you want help in selecting a viewpoint, place the cursor where you want \ the ", StyleBox["ViewPoint \[Rule] { }", FontWeight->"Bold"], " indicator, or highlight an existing indicator (like the one in the \ command above), and then pull down the Input menu and select 3D ViewPoint \ Selector. When you select a viewpoint and press the \"Paste\" button, the \ corresponding ", StyleBox["ViewPoint \[Rule] { } ", FontWeight->"Bold"], "indicator", StyleBox[" ", FontWeight->"Bold"], "is inserted where you placed the cursor. If you highlight an existing ", StyleBox["ViewPoint \[Rule] { }", FontWeight->"Bold"], " indicator, be sure that you highlight all of it, including the part in \ curly brackets." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "The second three-dimensional plot command is ", StyleBox["ParametricPlot3D[ ]", FontWeight->"Bold"], ". You can use this command to plot three-dimensional curves and surfaces \ that are specified in parametric form. For example, if the ", StyleBox["x", FontSlant->"Italic"], "-coordinates of the points on a curve are given by ", Cell[BoxData[ FormBox[ RowBox[{"x", "=", RowBox[{"t", " ", "cos", " ", StyleBox["t", FontSlant->"Italic"]}]}], TraditionalForm]]], ", the ", StyleBox["y", FontSlant->"Italic"], "-coordinates by ", Cell[BoxData[ \(TraditionalForm\`y = t\ sin\ t\)]], ", and the ", StyleBox["z", FontSlant->"Italic"], "-coordinates by ", Cell[BoxData[ \(TraditionalForm\`z = t\)]], ", then the curve can be graphed as follows." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(ParametricPlot3D[{t*Cos[t], t*Sin[t], t}, {t, \(-4\)*Pi, 4*Pi}, AxesLabel \[Rule] {"\", "\", "\"}];\)\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Assignment Commands ", "Section", PageWidth->PaperWidth], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " has two assignment commands that are used to assign items (values, lists, \ commands, graphs, etc) to symbols for later use or reference. The first \ assignment command is the \"equals\" (", Cell[BoxData[ FormBox[ StyleBox["=", FontWeight->"Bold"], TraditionalForm]]], ") and the other is the \"colon-equals\" (", Cell[BoxData[ FormBox[ StyleBox[":=", FontWeight->"Bold"], TraditionalForm]]], "). \n\nThe equals assignment evaluates the expression on the right side of \ the ", Cell[BoxData[ FormBox[ StyleBox["=", FontWeight->"Bold"], TraditionalForm]]], " sign and then assigns the result of the evaluation to the symbol on the \ left side of the ", Cell[BoxData[ FormBox[ StyleBox["=", FontWeight->"Bold"], TraditionalForm]]], " sign. The following are examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(x = 2\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(y = x + 2\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(z = y^3\)], "Input", PageWidth->PaperWidth], Cell["\<\ You can check to see what has been assigned to a symbol by typing a question \ mark (?) followed by the symbol name.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?x\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?y\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?z\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The colon-equals does not evaluate the expression on the right side of the \ ", Cell[BoxData[ FormBox[ StyleBox[":=", FontWeight->"Bold"], TraditionalForm]]], ". It simply assigns the unevaluated expression to the symbol name on the \ left side of the ", Cell[BoxData[ FormBox[ StyleBox[":=", FontWeight->"Bold"], TraditionalForm]]], ". Whenever the symbol name is referred to later on in the session, ", StyleBox["Mathematica", FontSlant->"Italic"], " then evaluates the expression that was assigned to the symbol name. For \ this reason, the colon-equals is called a ", StyleBox["delayed assignment", FontSlant->"Italic"], ". The following are some examples. " }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(a := 2\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(b := a + 2\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(c := b^3\)], "Input", PageWidth->PaperWidth], Cell["\<\ Note that no output is displayed when you use the colon-equals assignment. If \ you check to see what has been assigned to these symbols, you see that the \ expressions are saved rather than the results of their evaluations.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?a\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?b\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?c\)\)], "Input", PageWidth->PaperWidth], Cell["\<\ Now, if you use any of these symbols, the expression is evaluated and the \ result of the evaluation is used in place of the symbol. Here are some \ examples.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(a\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(3*b^2\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(c\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(w = a + b + c\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The ", StyleBox["Clear[ ] ", FontWeight->"Bold"], "command removes assignments that you have made to symbols. " }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Clear[x]\)], "Input", PageWidth->PaperWidth], Cell["\<\ If you check the symbol name, you see that after it is cleared it is treated \ as a symbol with no assignments.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?x\)\)], "Input", PageWidth->PaperWidth], Cell["\<\ If you use the symbol in an expression it will be treated simply as a symbol \ with its name.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(x + 2\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Note, however, that ", StyleBox["y", FontWeight->"Bold"], " is still ", StyleBox["4", FontWeight->"Bold"], ". This is because the ", Cell[BoxData[ FormBox[ StyleBox["=", FontWeight->"Bold"], TraditionalForm]]], " assignment was used to define ", StyleBox["y,", FontWeight->"Bold"], " and as a result the expression ", StyleBox["x+2", FontWeight->"Bold"], " was evaluated giving ", StyleBox["4", FontWeight->"Bold"], ", and this value was stored instead of the expression ", StyleBox["x+2", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(y\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "If you want to clear ", StyleBox["a", FontWeight->"Bold"], ", ", StyleBox["b", FontWeight->"Bold"], ", and ", StyleBox["c", FontWeight->"Bold"], ", ", "type the following command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Clear[a, b, c]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?a\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?b\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?c\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "It is extremely important to keep close track of the symbol names that you \ use in a ", StyleBox["Mathematica", FontSlant->"Italic"], " session. If you use a new symbol name in an expression or a command, and \ you are not absolutely sure that no assignments have been previously made to \ the symbol, you should first use the ", StyleBox["Clear[ ]", FontWeight->"Bold"], " command to erase all previous assignments to the new symbol name. Failure \ to do this can produce misleading and confusing results. There is more \ information about this in the ", StyleBox["Symbol Definitions and Pattern Matching ", FontWeight->"Bold"], "section later in this Overview.\n\nThere is another item that is related \ to the issue of symbol-name management. If you finish a ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook or one of our modules and you wish to start another one, it is \ best to save your work and then shut down ", StyleBox["Mathematica", FontSlant->"Italic"], " and restart it before beginning the new module or notebook. This is \ because ", StyleBox["Mathematica", FontSlant->"Italic"], " retains any assignments that you have made to symbol names, even after \ you close a notebook or module, and carries these over to the new one with \ the potential for conflicts. Shutting down ", StyleBox["Mathematica", FontSlant->"Italic"], " before starting a new notebook or module ensures that all symbol names \ are free and clear." }], "Text", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Special Packages", "Section", PageWidth->PaperWidth], Cell[TextData[{ "While there are many ", "built-in", StyleBox[" ", FontSlant->"Italic"], "commands that are available for use as soon as you open a ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook, there are many more specialized commands that are contained in \ packages. These packages are not automatically available in a ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook, and in order to use the specialized commands that they contain, \ you have to read them into computer memory. You do this in an input cell by \ typing ", "<<", " followed by the package name and then executing the command. Here is an \ example." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(<< Graphics`Arrow`\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Note that the ` is a backward blip. The ", StyleBox["Graphics`Arrow`", FontWeight->"Bold"], " package contains commands for drawing arrows in graphics cells. Here is \ an example that illustrates the use of the ", StyleBox["Arrow[ ] ", FontWeight->"Bold"], "command (highlighted in red) that is available in the ", StyleBox["Graphics`Arrow`", FontWeight->"Bold"], " package." }], "Text", PageWidth->PaperWidth], Cell[BoxData[{ RowBox[{"p1", ":=", RowBox[{"Plot", "[", RowBox[{\(Sin[x]\), ",", \({x, \(-0.01\), a}\), ",", \(PlotRange \[Rule] {{0, 2 \[Pi]}, {\(-1\), 1}}\), ",", RowBox[{"Epilog", "\[Rule]", RowBox[{"{", RowBox[{\(RGBColor[1, 0, 0]\), ",", StyleBox[\(Arrow[{a, 0}, {a, Sin[a]}]\), FontColor->RGBColor[1, 0, 0]]}], StyleBox["}", FontColor->RGBColor[1, 0, 0]]}]}]}], StyleBox["]", FontColor->RGBColor[1, 0, 0]]}]}], "\[IndentingNewLine]", \(Do[ p1, {a, 0, 2 \[Pi], \[Pi]\/4}];\)}], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The first command in the cell above uses a delayed assignment of the ", StyleBox["Plot[ ] ", FontWeight->"Bold"], "command to the symbol name ", StyleBox["p1", FontWeight->"Bold"], ". Inside the ", StyleBox["Plot[ ] ", FontWeight->"Bold"], "command, the ", StyleBox["Epilog\[Rule]", FontWeight->"Bold"], Cell[BoxData[ \(TraditionalForm\`{\ }\)], FontWeight->"Bold"], " option allows us to add things, like arrows, to the graph of the ", Cell[BoxData[ \(TraditionalForm\`sin\ x\)]], ". The ", StyleBox["RGBColor[1, 0, 0]", FontWeight->"Bold"], " specification will make the arrows red. The second command in the cell is \ the built-in ", StyleBox["Do[ ]", FontWeight->"Bold"], " command. It causes the ", StyleBox["Plot[ ] ", FontWeight->"Bold"], "command that was assigned to ", StyleBox["p1", FontWeight->"Bold"], " to execute repeatedly as the value for ", StyleBox["a", FontWeight->"Bold"], " varies from 0 to ", Cell[BoxData[ \(TraditionalForm\`2 \[Pi]\)]], ", incremented by steps of ", Cell[BoxData[ \(TraditionalForm\`\[Pi]\/4\)]], ". \n\nTo find out what packages are available to read into memory, pull \ down the Help menu, click the Add-On button, and select Standard Packages. \n\ \nBefore you use any of the specialized commands available in a package, be \ sure to read in the package first. A package needs to be read in only once \ during a ", StyleBox["Mathematica", FontSlant->"Italic"], " session. If you try to execute a package command before you have read in \ the package, the command won't work. Reading in the package after you have \ tried to execute one of its commands will result in error messages. To fix \ this problem, you must do one of two things: 1) save your work, close ", StyleBox["Mathematica", FontSlant->"Italic"], " and restart it; or 2) use the ", StyleBox["Remove[ ] ", FontWeight->"Bold"], "command to remove the commands that you tried to execute before loading \ the package. If you choose to restart ", StyleBox["Mathematica", FontSlant->"Italic"], ", be sure to re-execute all the commands in the package that preceded the \ one that gave you problems. The commands in the following cells illustrate \ how to use ", StyleBox["Remove[ ]", FontWeight->"Bold"], ". First we try to execute a command from the ", StyleBox["Graphics`FilledPlot`", FontWeight->"Bold"], " package before we load the package. Nothing happens because ", StyleBox["Mathematica", FontSlant->"Italic"], " does not recognize the command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(FilledPlot[Sin[x], {x, 0, 2 \[Pi]}];\)\)], "Input", PageWidth->PaperWidth], Cell["\<\ Next, we load the package and try to re-execute the command, but now we get \ error messages. \ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(<< Graphics`FilledPlot`\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "If we then try to re-execute ", StyleBox["FilledPlot[ ]", FontWeight->"Bold"], ", it will not work." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(FilledPlot[Sin[x], {x, 0, 2 \[Pi]}];\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Finally, after we ", StyleBox["Remove[ ]", FontWeight->"Bold"], " our previous use of ", StyleBox["FilledPlot[ ]", FontWeight->"Bold"], ", the ", StyleBox["PlotFilled[ ] ", FontWeight->"Bold"], "command should work." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(Remove[FilledPlot];\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(FilledPlot[Sin[x], {x, 0, 2 \[Pi]}];\)\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Making Your Own Commands", "Section", PageWidth->PaperWidth], Cell[TextData[{ "As a ", StyleBox["Mathematica", FontSlant->"Italic"], " user and programmer, you can design and construct your own commands. \n\n\ To avoid conflicts with built-in ", StyleBox["Mathematica", FontSlant->"Italic"], " commands, you should consistently begin the names of your commands with \ lowercase letters." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "To create a command, use an assignment statement (usually with the \ colon-equals, ", Cell[BoxData[ FormBox[ StyleBox[":=", FontWeight->"Bold"], TraditionalForm]]], "). On the left of the ", Cell[BoxData[ FormBox[ StyleBox[":=", FontWeight->"Bold"], TraditionalForm]]], ", place the name you want to use for your command, followed by a set of \ single square brackets ", StyleBox["[ ] ", FontWeight->"Bold"], "that enclose the list of arguments for the command. On the right of the ", Cell[BoxData[ \(TraditionalForm\` := \)], FontWeight->"Bold"], ", state the operations that your command is to perform on inputs that will \ be supplied for the arguments whenever the command is used. Suppose, for \ example, that you are going to use the function ", Cell[BoxData[ FormBox[ RowBox[{ RowBox[{ StyleBox["x", FontWeight->"Bold", FontSlant->"Plain"], StyleBox["^", FontWeight->"Bold"], StyleBox["2", FontWeight->"Bold"]}], StyleBox["*", FontWeight->"Bold"], RowBox[{ StyleBox["Sin", FontWeight->"Bold"], StyleBox["[", FontWeight->"Bold"], StyleBox["x", FontWeight->"Bold", FontSlant->"Plain"], StyleBox["]", FontWeight->"Bold"]}]}], TraditionalForm]]], " over and over again in a program. You may wish to create a new function \ and make it a user-defined ", StyleBox["Mathematica", FontSlant->"Italic"], " command, as illustrated by the following definition." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(myfunction[x_] := x^2*Sin[x]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The underscore _ after the ", StyleBox["x", FontWeight->"Bold"], " tells ", StyleBox["Mathematica", FontSlant->"Italic"], " that this is the definition of a new function rather than a call of an \ existing function. The underscore _ after the ", StyleBox["x", FontWeight->"Bold"], " also tells ", StyleBox["Mathematica", FontSlant->"Italic"], " that, in the expression on the right of the ", Cell[BoxData[ FormBox[ StyleBox[":=", FontWeight->"Bold"], TraditionalForm]]], ", ", StyleBox["x", FontWeight->"Bold"], " is a dummy, stand-in variable that will be replaced by real input in the \ argument list, whenever ", StyleBox["myfunction[ ] ", FontWeight->"Bold"], "is called. The following examples illustrate what ", StyleBox["Mathematica", FontSlant->"Italic"], " does with ", StyleBox["myfunction[ ]", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(myfunction[2]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(myfunction[2.0]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(myfunction[r]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(myfunction[a + b]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(myfunction[{2, 4}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The last example illustrates an important feature of most ", StyleBox["Mathematica", FontSlant->"Italic"], " commands: they are \"listable.\" This means that if you put in a list as \ an input to a command, ", StyleBox["Mathematica", FontSlant->"Italic"], " performs the command operation(s) on each of the elements in the list and \ returns a list of the results. This even works for simple operations like \ addition, multiplication, or raising a number to a power." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \({1, 2, 3} + {4, 5, 6}\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \({1, 2, 3, 4}*{\(-2\), 2, 3, 5}\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \({\(-2\), 3, 5, 9}^2\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "You can design commands that perform more than one operation, typically \ using the ", StyleBox["Block[ ] ", FontWeight->"Bold"], "command to set them up. The ", StyleBox["Block[ ]", FontWeight->"Bold"], " command requires a minimum of two arguments. The first argument is a list \ of local symbols (sometimes it is empty), and the second is a series of \ commands that you want your command to execute whenever it is called or used. \ The following example generates a list of decaying numbers, plots the list, \ and returns the sequence as an output of the module. The input is the length \ of the sequence, ", StyleBox["n", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(buildplot[n_] := Block[{plotlist}, \n\t\tplotlist = Table[0.8^\((i - 1)\), {i, 1, n}]; \n\t\tListPlot[plotlist, PlotStyle -> {PointSize[0.02]}]; \n\t\tReturn[ plotlist];]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "In ", StyleBox["buildplot[ ]", FontWeight->"Bold"], ", the list of local symbols contains the symbol ", StyleBox["plotlist", FontWeight->"Bold"], ". Making a symbol local to a command means that any assignments you make \ to the symbol inside the block will not be available outside the block. If \ you type ", StyleBox["?plotlist", FontWeight->"Bold"], " after you execute the command, you will find that nothing has been \ assigned to this symbol. We will check it out below, after we execute the ", StyleBox["buildplot[ ]", FontWeight->"Bold"], " command." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "The series of commands forms the second argument of the ", StyleBox["Block[ ]", FontWeight->"Bold"], " command. Semicolons are used to separate the individual commands in the \ series of commands inside the block. " }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "You can execute the ", StyleBox["buildplot[ ]", FontWeight->"Bold"], " command by using its name and providing an input value for the argument." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(buildplot[25]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Now we check the symbol name ", StyleBox["plotlist", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?plotlist\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The list that was assigned to ", StyleBox["plotlist", FontWeight->"Bold"], " inside the block is not available in the global environment outside the \ block." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "The ", StyleBox["Return[ plotlist ] ", FontWeight->"Bold"], "command inside the block returns the values stored in the local ", StyleBox["plotlist", FontWeight->"Bold"], " symbol. ", "If you want to save the output list of values for later use, you can \ assign it to a symbol name." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(decay = buildplot[25]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "If you use the symbol name ", StyleBox["decay", FontWeight->"Bold"], ",", " you will get the list of numbers that the ", StyleBox["buildplot[ ]", FontWeight->"Bold"], " command returned as output." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(decay\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Note what happens when you use the colon-equals assignment to the symbol \ ", StyleBox["delaydecay", FontWeight->"Bold"], " and then use the symbol ", StyleBox["delaydecay", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(delaydecay := buildplot[25]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "There is no output when you execute this command because of the delayed \ evaluation; output is generated only when an expression is evaluated. With \ the delayed assignment, ", StyleBox["buildplot[ 25 ]", FontWeight->"Bold"], " is assigned to ", StyleBox["delaydecay", FontWeight->"Bold"], ", unevaluated, hence no output is displayed. However, if you type ", StyleBox["delaydecay", FontWeight->"Bold"], ", the ", StyleBox["buildplot[ 25 ]", FontWeight->"Bold"], " command that was assigned to ", StyleBox["delaydecay", FontWeight->"Bold"], " is evaluated, and output is displayed." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(delaydecay\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Instead of evaluating ", StyleBox["buildplot[ 25 ]", FontWeight->"Bold"], " and storing the output in ", StyleBox["delaydecay", FontWeight->"Bold"], ", the colon-equal assignment stores the unevaluated ", StyleBox["buildplot[25]", FontWeight->"Bold"], " command in ", StyleBox["delaydecay", FontWeight->"Bold"], " and executes it whenever ", StyleBox["delaydecay", FontWeight->"Bold"], " is used." }], "Text", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Parts of Lists ", "Section", PageWidth->PaperWidth], Cell[TextData[{ "Curly brackets ", Cell[BoxData[ FormBox[ StyleBox[\({\ }\), FontWeight->"Bold"], TraditionalForm]]], " enclose the elements of a list, square brackets ", Cell[BoxData[ FormBox[ StyleBox[\([\ ]\), FontWeight->"Bold"], TraditionalForm]]], " enclose the series of arguments in a ", StyleBox["Mathematica", FontSlant->"Italic"], " command, and regular parentheses ", Cell[BoxData[ FormBox[ StyleBox[\((\ \ )\), FontWeight->"Bold"], TraditionalForm]]], " are the symbols of inclusion for algebraic operations. \n\nA pair of \ double square brackets ", Cell[BoxData[ FormBox[ StyleBox[\([\([\ ]\)]\), FontWeight->"Bold"], TraditionalForm]]], " is used to specify a part or element of a list. Consider the following \ examples. " }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(odds = {1, 3, 5, 7, 9, 11, 13, 15}\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "To retrieve the third element of ", StyleBox["odds", FontWeight->"Bold"], ", use a part specification after the name of the list." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(odds[\([3]\)]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "For nested lists, that is, a list of lists, use multiple part \ specifications like ", Cell[BoxData[ FormBox[ StyleBox[\([\([\ 3, \ 2\ ]\)]\), FontWeight->"Bold"], TraditionalForm]]], " to retrieve elements. The first part number points to an individual \ element in the outermost list, which may itself be a list. The second part \ number points to an element inside the inner list. The following examples \ illustrate this." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(oddeven = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}}\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The following command retrieves the fourth list from ", StyleBox["oddeven", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(oddeven[\([4]\)]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "To retrieve the second element of the third list in ", StyleBox["oddeven", FontWeight->"Bold"], ",", StyleBox[" ", FontWeight->"Bold"], "type:" }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(oddeven[\([3, 2]\)]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "In ", StyleBox["Mathematica", FontSlant->"Italic"], ", you can attach a part specification to just about anything. The reason \ for this is that almost every ", StyleBox["Mathematica", FontSlant->"Italic"], " entity (symbol, command, graphic, etc.) in its basic form consists of a \ list with a ", StyleBox["Head", FontWeight->"Bold"], " in front of it. To see the ", StyleBox["Head[ ", FontWeight->"Bold"], StyleBox["list ", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["]", FontWeight->"Bold"], " form of a ", StyleBox["Mathematica", FontSlant->"Italic"], " expression, use the ", StyleBox["FullForm[ ] ", FontWeight->"Bold"], "command. For example, consider the basic operation of addition. " }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(FullForm[a + b]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "This shows that the basic form for addition in ", StyleBox["Mathematica", FontSlant->"Italic"], " is a list of arguments (the addends) with the head ", StyleBox["Plus", FontWeight->"Bold"], ". The head specifies the operation that is to be performed on the \ arguments. " }], "Text", PageWidth->PaperWidth], Cell["Even lists have this form.", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(FullForm[odds]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "In this case the head is the command, ", StyleBox["List", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "The ", StyleBox["Head[", FontWeight->"Bold"], StyleBox["list", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["]", FontWeight->"Bold"], " format is the standard form for just about every expression or command in \ ", StyleBox["Mathematica.", FontSlant->"Italic"], " Sometimes, as in the case of addition, the ", StyleBox["Head[", FontWeight->"Bold"], StyleBox["list", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["]", FontWeight->"Bold"], " form is hidden from the user. When you type the more conventional form of \ a command, like ", Cell[BoxData[ FormBox[ RowBox[{ StyleBox["a", FontWeight->"Bold", FontSlant->"Plain"], StyleBox["+", FontWeight->"Bold"], StyleBox["b", FontWeight->"Bold", FontSlant->"Plain"]}], TraditionalForm]]], ", ", StyleBox["Mathematica", FontSlant->"Italic"], " translates it to ", StyleBox["Plus[a, b]", FontWeight->"Bold"], ". You can type any ", StyleBox["Mathematica", FontSlant->"Italic"], " command in ", StyleBox["Head[", FontWeight->"Bold"], StyleBox["list", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["]", FontWeight->"Bold"], " form if you wish, but conventional math notation is often times more \ natural.\n\nBecause nearly all expressions and commands are in ", StyleBox["Head[", FontWeight->"Bold"], StyleBox["list", FontWeight->"Bold", FontSlant->"Italic"], StyleBox["]", FontWeight->"Bold"], " form, you can attach part specifications to just about any ", StyleBox["Mathematica ", FontSlant->"Italic"], "entity. Consider the following examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\((a + b)\)[\([1]\)]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\((3*a + 2*b)\)[\([2]\)]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\((3*a + 2*b)\)[\([2, 2]\)]\)], "Input", PageWidth->PaperWidth], Cell["The subscript 0 retrieves the head of a command.", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\((3*a + 2*b)\)[\([0]\)]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\((3*a + 2*b)\)[\([2, 0]\)]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(odds[\([0]\)]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "If you are not sure how an element is embedded in a command, you can use \ ", StyleBox["FullForm[ ]", FontWeight->"Bold"], " to find out." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(FullForm[\((3*a + 2*b)\)]\)], "Input", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Rules and the Slash-Dot Command", "Section", PageWidth->PaperWidth], Cell[TextData[{ "Sometimes it is desirable to evaluate an expression in ", StyleBox["Mathematica", FontSlant->"Italic"], " by temporarily replacing the symbols in the expression with values or \ other symbols without permanently assigning the replacement values/symbols to \ the symbol names. This can be accomplished with the ", StyleBox["/.", FontWeight->"Bold"], " (pronounced slash-dot) command followed by a list of replacement rules. \ Note that the slash is a forward slash. The ", StyleBox["/. ", FontWeight->"Bold"], " is also called the ", StyleBox["ReplaceAll", FontWeight->"Bold"], " command. The following are examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[{ \(\(Clear[x, y, f];\)\), "\[IndentingNewLine]", \(f = x^2 + y^2\)}], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(f /. {x \[Rule] 1, y \[Rule] 2}\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(f /. {x \[Rule] Sin[\[Theta]], y \[Rule] Cos[\[Theta]]}\)], "Input", PageWidth->PaperWidth], Cell["\<\ You can accomplish the same thing with the following command.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(ReplaceAll[ f, {x \[Rule] Sin[\[Theta]], y \[Rule] Cos[\[Theta]]}]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The expressions ", StyleBox["x \[Rule]1", FontWeight->"Bold"], " and", StyleBox[" y\[Rule]2", FontWeight->"Bold"], " are rules. (You can find the arrow on the BasicInput palette or you can \ type a minus sign followed by a greater than sign.) Rules are different from \ assignments (", Cell[BoxData[ \(TraditionalForm\` = \)]], ") in that they do not become definitions associated with the symbols ", StyleBox["x", FontWeight->"Bold"], " and ", StyleBox["y", FontWeight->"Bold"], ", as is the case with assignments. You can verify this by checking out the \ definitions that are associated with ", StyleBox["x", FontWeight->"Bold"], " and ", StyleBox["y", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?x\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?y\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The symbols ", StyleBox["x", FontWeight->"Bold"], " and ", StyleBox["y", FontWeight->"Bold"], " are clear. The symbol ", StyleBox["x", FontWeight->"Bold"], " was replaced with the number ", StyleBox["1,", FontWeight->"Bold"], " and ", StyleBox["y", FontWeight->"Bold"], " with ", StyleBox["2,", FontWeight->"Bold"], " in the evaluation of ", StyleBox["f", FontWeight->"Bold"], ", but the numbers were not permanently assigned to ", StyleBox["x", FontWeight->"Bold"], " and ", StyleBox["y", FontWeight->"Bold"], ". ", "In addition, the symbol definition of ", StyleBox["f", FontWeight->"Bold"], " is left unchanged." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?f\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "This is in contrast to evaluation of ", StyleBox["f ", FontWeight->"Bold"], "after", " values are assigned to the variables ", StyleBox["x ", FontWeight->"Bold"], "and ", StyleBox["y", FontWeight->"Bold"], ",", " as shown by the following commands." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(x = 2;\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(y = 2;\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(f\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?x\)\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?y\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "In this case, ", StyleBox["x", FontWeight->"Bold"], " is permanently assigned the value ", StyleBox["1", FontWeight->"Bold"], " and ", StyleBox["y", FontWeight->"Bold"], " the value ", StyleBox["2", FontWeight->"Bold"], ",", " that is, until we ", StyleBox["Clear[ x, y ]", FontWeight->"Bold"], ". The definition of ", StyleBox["f", FontWeight->"Bold"], " is still unchanged, however." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?f\)\)], "Input", PageWidth->PaperWidth], Cell["Here is another example.", "Text", PageWidth->PaperWidth], Cell[BoxData[{ \(\(Clear[x, y];\)\), "\[IndentingNewLine]", \(equations = {x + 2*y \[Equal] 3, 3*x + 4*y \[Equal] 2}\)}], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Note that ", Cell[BoxData[ FormBox[ StyleBox["==", FontWeight->"Bold"], TraditionalForm]]], " is used in ", StyleBox["Mathematica", FontSlant->"Italic"], " to represent mathematical equality. This is necessary because the ", Cell[BoxData[ FormBox[ StyleBox["=", FontWeight->"Bold"], TraditionalForm]]], " symbol is reserved for assignments to symbol names (See the ", StyleBox["Assignment Commands", FontWeight->"Bold"], " section)." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(solution = Solve[equations, {x, y}]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(equations /. solution\)], "Input", PageWidth->PaperWidth], Cell["\<\ The last command verifies that the solutions found satisfy the two equations.\ \ \>", "Text", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Retrieving Output from Commands", "Section", PageWidth->PaperWidth], Cell[TextData[{ "If you type a ", StyleBox["Mathematica", FontSlant->"Italic"], " command, the output is usually displayed directly after the command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Solve[x^2 == 1, x]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Note that ", Cell[BoxData[ FormBox[ StyleBox["==", FontWeight->"Bold"], TraditionalForm]]], " is used in ", StyleBox["Mathematica", FontSlant->"Italic"], " to represent mathematical equality. This is necessary because the ", Cell[BoxData[ FormBox[ StyleBox["=", FontWeight->"Bold"], TraditionalForm]]], " symbol is reserved for assignments to symbol names (See the ", StyleBox["Assignment Commands", FontWeight->"Bold"], " section).\n\nTyping a semicolon ( ; ) after the command will suppress \ printing the output." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(Solve[x^2 == 1, x];\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "The semicolon is used for two purposes. One is to separate individual \ commands in a ", StyleBox["Block[ ]", FontWeight->"Bold"], " that includes a series of ", StyleBox["Mathematica", FontSlant->"Italic"], " commands, and the other is to suppress printing the output of any single \ command." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "To see the standard ", StyleBox["Mathematica", FontSlant->"Italic"], " format for the output of the ", StyleBox["Solve[ ]", FontWeight->"Bold"], ", you can assign the output to a new symbol name and use the ", StyleBox["FullForm[ ]", FontWeight->"Bold"], " command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(soln = Solve[x^2 == 1, \ x]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(FullForm[soln]\)], "Input", PageWidth->PaperWidth], Cell["\<\ The solution is a list of two lists. In each of the inner lists, there is a \ rule, which is itself a list with two elements. The second element of each \ rule is a solution. Therefore, to retrieve the two solutions, you could type \ the following:\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(soln[\([1, 1, 2]\)]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(soln[\([2, 1, 2]\)]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Once you know the ", StyleBox["FullForm", FontWeight->"Bold"], " of the output, you can subscript the command directly, as illustrated by \ the following examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(firstsoln = \(Solve[x^2 == 1, x]\)[\([1, 1, 2]\)]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(secondsoln = \(Solve[x^2 == 1, x]\)[\([2, 1, 2]\)]\)], "Input", PageWidth->PaperWidth], Cell["\<\ This latter approach is not as efficient as the one preceding it because it \ requires solving the equation twice whereas the first approach only solves it \ once.\ \>", "Text", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell["Symbol Definitions and Pattern Matching", "Section", PageWidth->PaperWidth], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " evaluates and simplifies expressions through a process of pattern \ matching. To understand how this works, suppose that you want to construct a \ ", StyleBox["Mathematica", FontSlant->"Italic"], " function called ", StyleBox["crazy[ ]", FontWeight->"Bold"], " that subtracts two numbers and then divides the result by their sum. You \ can do this with the following command." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(crazy[x_, y_] := \((x - y)\)/\((x + y)\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Once you define this new function, ", StyleBox["Mathematica", FontSlant->"Italic"], " will match it with any command of the form ", StyleBox["crazy[item1, item2]", FontWeight->"Bold"], " and perform the designated operation on the two items. For example," }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(crazy[house, garage]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Now suppose that when both arguments are zero, you want the function ", StyleBox["crazy[ ]", FontWeight->"Bold"], " to return the value 1. You can do this by adding a new pattern definition \ to the description of ", StyleBox["crazy[ ]", FontWeight->"Bold"], " as follows:" }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(crazy[0, 0] = 1\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "If you ask ", StyleBox["Mathematica", FontSlant->"Italic"], " what it knows about ", StyleBox["crazy[ ]", FontWeight->"Bold"], ",", " it will tell you that it has recorded both of your definitions." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?crazy\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "From now on, whenever you use the symbol ", StyleBox["crazy", FontWeight->"Bold"], ", ", StyleBox["Mathematica", FontSlant->"Italic"], " will check all of the forms that have been assigned to the symbol ", StyleBox["crazy", FontWeight->"Bold"], ", starting with the more specific forms and proceeding to the more \ generic, until it finds a match. If it finds a match, it performs the \ operation that corresponds to the matched form of ", StyleBox["crazy", FontWeight->"Bold"], ". Note in the list above that ", StyleBox["crazy[0,0]", FontWeight->"Bold"], " is more specific than ", StyleBox["crazy[x_,y_]", FontWeight->"Bold"], "; it is therefore placed first in the list of forms associated with the \ symbol ", StyleBox["crazy", FontWeight->"Bold"], ". ", StyleBox["Mathematica", FontSlant->"Italic"], " simply begins at the top of its list of definitions for the symbol ", StyleBox["crazy", FontWeight->"Bold"], " and searches down the list until it finds the first match. If it does not \ find a match, then it treats the unrecognized form as a new symbol. The new \ symbol is not associated with an operation and, therefore, is left \ unevaluated. These features are illustrated by the following examples." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(crazy[0, 0]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(crazy[r, s]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(crazy[x, y, z]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ StyleBox["Mathematica", FontWeight->"Bold", FontSlant->"Italic"], StyleBox[" doesn't forget!", FontWeight->"Bold"], " To understand this, consider the following scenario. You assign values to \ ", StyleBox["p[1]", FontWeight->"Bold"], ", ", StyleBox["p[2]", FontWeight->"Bold"], ", etc. as follows:" }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(Do[p[i] = i^2, {i, 1, 5}]\)], "Input", PageWidth->PaperWidth], Cell["You check the assignments by typing,", "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?p\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Later you decide to build a new function that takes an input value and \ cubes it. However, you forget that you already used the symbol ", StyleBox["p", FontWeight->"Bold"], " for other things and inadvertently call your new function ", StyleBox["p", FontWeight->"Bold"], ", which you define as follows:" }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(p[x_] := x^3\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Now you use your new function, ", StyleBox["p[x]", FontWeight->"Bold"], ", to calculate ", Cell[BoxData[ \(TraditionalForm\`2\^3\)]], "." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(p[2]\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "This is obviously not the output you expected. The problem is that ", StyleBox["Mathematica", FontSlant->"Italic"], " has remembered what you told it before. The form ", StyleBox["p[2]=4", FontWeight->"Bold"], " is a more specific definition than ", StyleBox["p[x_]=x^3", FontWeight->"Bold"], ", and so when you ask for ", StyleBox["p[2]", FontWeight->"Bold"], " the first match it finds is ", StyleBox["p[2] = 4", FontWeight->"Bold"], ". If you ask ", StyleBox["Mathematica", FontSlant->"Italic"], " what it knows about the symbol ", StyleBox["p", FontWeight->"Bold"], ", you will see the problem." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(\(?p\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "If you were to open a new notebook or module without entirely closing down \ ", StyleBox["Mathematica", FontSlant->"Italic"], ", it would still retain all of the previous definitions of ", StyleBox["p", FontWeight->"Bold"], "." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "Sometimes this can be very perplexing when you are working in ", StyleBox["Mathematica. ", FontSlant->"Italic"], "Consequently, it is extremely important to keep close track of the symbols \ you use, and when you are done with a symbol you should use the ", StyleBox["Clear[ ]", FontWeight->"Bold"], " command to erase its definitions. If you define a new function and it \ gives you unexpected or erroneous results, it is sometimes helpful to clear \ the function name, and then try to redefine it." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "It is good practice to clear the name of the new function before you \ define it. Put the ", StyleBox["Clear[ ] ", FontWeight->"Bold"], "command in the same cell as the function definition. For example," }], "Text", PageWidth->PaperWidth], Cell[BoxData[{ \(\(Clear[p];\)\ \), "\n", \(p[x_] := x^3\)}], "Input", PageWidth->PaperWidth], Cell[TextData[{ "Now the function ", StyleBox["p", FontWeight->"Bold"], " should work correctly." }], "Text", PageWidth->PaperWidth], Cell[BoxData[ \(p[2]\)], "Input", PageWidth->PaperWidth], Cell["\<\ Another thing that can cause problems is defining a function using a symbol \ name with an argument and then later redefining the symbol without an \ argument before clearing the original definition. The following commands \ illustrate what can happen.\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[{ \(\(Clear[g, x];\)\), "\[IndentingNewLine]", \(g[x_] = x\^2\)}], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(g = Sin[2 x]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(g[2]\)], "Input", PageWidth->PaperWidth], Cell[BoxData[ \(\(?g\)\)], "Input", PageWidth->PaperWidth], Cell[TextData[{ "For the symbol ", StyleBox["g[2]", FontWeight->"Bold"], ", the first match that is found is for ", StyleBox["g", FontWeight->"Bold"], " and this symbol is replaced with ", StyleBox["Sin[2x]", FontWeight->"Bold"], " giving the output, Sin[2x][2]." }], "Text", PageWidth->PaperWidth], Cell[TextData[{ "Once you understand how ", StyleBox["Mathematica", FontSlant->"Italic"], " evaluates expressions by pattern matching, you will find that this can be \ a very powerful tool. It is the basic process that ", StyleBox["Mathematica", FontSlant->"Italic"], " uses when it evaluates expressions." }], "Text", PageWidth->PaperWidth] }, Closed]], Cell[CellGroupData[{ Cell[TextData[{ StyleBox["\[MathematicaIcon] ", FontSize->18, FontWeight->"Bold", FontColor->RGBColor[0.792981, 0.777356, 0.144533], FontVariations->{"CompatibilityType"->0}], StyleBox["About ", FontColor->RGBColor[0.500008, 0, 0.500008]], StyleBox["Mathematica", FontSlant->"Italic", FontColor->RGBColor[0.500008, 0, 0.500008]], " " }], "Section", PageWidth->PaperWidth, CellDingbat->None], Cell["\<\ Throughout the modules you will see hyperlink buttons that look like this:\ \>", "Text", PageWidth->PaperWidth], Cell[BoxData[ ButtonBox[ RowBox[{ StyleBox["\[MathematicaIcon]", FontSize->18, FontWeight->"Bold", FontColor->RGBColor[0.792981, 0.777356, 0.144533], FontVariations->{"CompatibilityType"->0}], StyleBox[" ", FontSize->14, FontWeight->"Bold", FontSlant->"Italic"], StyleBox["About", FontSize->14, FontWeight->"Bold", FontColor->RGBColor[0.500008, 0, 0.500008]], StyleBox[" ", FontSize->14, FontWeight->"Bold", FontSlant->"Italic"], StyleBox["Mathematica", FontSize->14, FontWeight->"Bold", FontSlant->"Italic", FontColor->RGBColor[0.500008, 0, 0.500008]]}], ButtonStyle->"Hyperlink"]], "Input", PageWidth->PaperWidth, Evaluatable->False], Cell[TextData[{ "Each of these buttons links to a text cell containing information about \ the ", StyleBox["Mathematica", FontSlant->"Italic"], " commands and formats that are being used nearby in the module. If you are \ interested in learning more about ", StyleBox["Mathematica", FontSlant->"Italic"], ", you can click the button to read the information in the text cell, or \ you can elect to skip over it so as not to interrupt the flow of the module. \ Each text cell has a Go Back link that takes you back to the location in the \ module where you clicked the button." }], "Text", PageWidth->PaperWidth] }, Closed]] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, ScreenStyleEnvironment->"Working", WindowSize->{852, 502}, WindowMargins->{{2, Automatic}, {Automatic, 5}}, PrintingCopies->1, PrintingPageRange->{6, 6}, StyleDefinitions -> "Default.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[1739, 51, 125, 5, 105, "Title"], Cell[CellGroupData[{ Cell[1889, 60, 63, 1, 53, "Section"], Cell[1955, 63, 3241, 63, 736, "Text"], Cell[CellGroupData[{ Cell[5221, 130, 99, 2, 47, "Subsection"], Cell[5323, 134, 1415, 36, 299, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[6787, 176, 61, 1, 33, "Section"], Cell[6851, 179, 342, 10, 71, "Text"], Cell[7196, 191, 67, 2, 30, "Input"], Cell[7266, 195, 66, 2, 30, "Input"], Cell[7335, 199, 64, 2, 30, "Input"], Cell[7402, 203, 102, 2, 30, "Input"], Cell[7507, 207, 78, 2, 30, "Input"], Cell[7588, 211, 600, 18, 71, "Text"], Cell[8191, 231, 467, 8, 109, "Text"], Cell[8661, 241, 418, 9, 90, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[9116, 255, 50, 1, 33, "Section"], Cell[9169, 258, 446, 14, 71, "Text"], Cell[9618, 274, 70, 2, 30, "Input"], Cell[9691, 278, 76, 2, 30, "Input"], Cell[9770, 282, 82, 2, 30, "Input"], Cell[9855, 286, 137, 4, 33, "Text"], Cell[9995, 292, 244, 6, 52, "Text"], Cell[10242, 300, 94, 2, 30, "Input"], Cell[10339, 304, 278, 7, 90, "Text"], Cell[10620, 313, 203, 7, 52, "Text"], Cell[10826, 322, 104, 2, 30, "Input"], Cell[10933, 326, 251, 9, 52, "Text"], Cell[11187, 337, 234, 4, 70, "Input"], Cell[11424, 343, 294, 10, 52, "Text"], Cell[11721, 355, 389, 10, 71, "Text"], Cell[12113, 367, 83, 2, 30, "Input"], Cell[12199, 371, 246, 7, 52, "Text"], Cell[12448, 380, 79, 2, 30, "Input"], Cell[12530, 384, 78, 2, 30, "Input"], Cell[12611, 388, 659, 15, 109, "Text"], Cell[13273, 405, 330, 8, 71, "Text"], Cell[13606, 415, 72, 2, 30, "Input"], Cell[13681, 419, 192, 4, 52, "Text"], Cell[13876, 425, 95, 2, 30, "Input"], Cell[13974, 429, 85, 1, 33, "Text"], Cell[14062, 432, 105, 2, 30, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[14204, 439, 53, 1, 33, "Section"], Cell[14260, 442, 407, 13, 90, "Text"], Cell[14670, 457, 94, 2, 30, "Input"], Cell[14767, 461, 701, 15, 166, "Text"], Cell[15471, 478, 61, 2, 32, "Input"], Cell[15535, 482, 66, 2, 32, "Input"], Cell[15604, 486, 267, 5, 71, "Text"], Cell[15874, 493, 302, 10, 52, "Text"], Cell[16179, 505, 140, 3, 30, "Input"], Cell[16322, 510, 230, 7, 52, "Text"], Cell[16555, 519, 213, 5, 50, "Input"], Cell[16771, 526, 1075, 24, 166, "Text"], Cell[17849, 552, 176, 4, 52, "Text"], Cell[18028, 558, 241, 4, 70, "Input"], Cell[18272, 564, 218, 7, 52, "Text"], Cell[18493, 573, 160, 6, 33, "Text"], Cell[18656, 581, 92, 2, 30, "Input"], Cell[18751, 585, 212, 5, 52, "Input"], Cell[18966, 592, 214, 7, 52, "Text"], Cell[19183, 601, 205, 6, 52, "Text"], Cell[19391, 609, 108, 2, 30, "Input"], Cell[19502, 613, 208, 4, 50, "Input"], Cell[19713, 619, 283, 9, 52, "Text"], Cell[19999, 630, 775, 24, 90, "Text"], Cell[20777, 656, 258, 5, 90, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[21072, 666, 53, 1, 33, "Section"], Cell[21128, 669, 511, 15, 109, "Text"], Cell[21642, 686, 169, 3, 50, "Input"], Cell[21814, 691, 735, 17, 166, "Text"], Cell[22552, 710, 216, 4, 50, "Input"], Cell[22771, 716, 791, 20, 128, "Text"], Cell[23565, 738, 902, 29, 90, "Text"], Cell[24470, 769, 182, 3, 50, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[24689, 777, 64, 1, 33, "Section"], Cell[24756, 780, 987, 29, 128, "Text"], Cell[25746, 811, 63, 2, 30, "Input"], Cell[25812, 815, 67, 2, 30, "Input"], Cell[25882, 819, 65, 2, 30, "Input"], Cell[25950, 823, 165, 4, 52, "Text"], Cell[26118, 829, 64, 2, 30, "Input"], Cell[26185, 833, 64, 2, 30, "Input"], Cell[26252, 837, 64, 2, 30, "Input"], Cell[26319, 841, 790, 22, 109, "Text"], Cell[27112, 865, 64, 2, 30, "Input"], Cell[27179, 869, 68, 2, 30, "Input"], Cell[27250, 873, 66, 2, 30, "Input"], Cell[27319, 877, 273, 5, 71, "Text"], Cell[27595, 884, 64, 2, 30, "Input"], Cell[27662, 888, 64, 2, 30, "Input"], Cell[27729, 892, 64, 2, 30, "Input"], Cell[27796, 896, 207, 5, 52, "Text"], Cell[28006, 903, 59, 2, 30, "Input"], Cell[28068, 907, 63, 2, 30, "Input"], Cell[28134, 911, 59, 2, 30, "Input"], Cell[28196, 915, 71, 2, 30, "Input"], Cell[28270, 919, 175, 6, 33, "Text"], Cell[28448, 927, 66, 2, 30, "Input"], Cell[28517, 931, 160, 4, 52, "Text"], Cell[28680, 937, 64, 2, 30, "Input"], Cell[28747, 941, 142, 4, 33, "Text"], Cell[28892, 947, 63, 2, 30, "Input"], Cell[28958, 951, 646, 26, 71, "Text"], Cell[29607, 979, 59, 2, 30, "Input"], Cell[29669, 983, 262, 13, 33, "Text"], Cell[29934, 998, 72, 2, 30, "Input"], Cell[30009, 1002, 64, 2, 30, "Input"], Cell[30076, 1006, 64, 2, 30, "Input"], Cell[30143, 1010, 64, 2, 30, "Input"], Cell[30210, 1014, 1559, 35, 280, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[31806, 1054, 60, 1, 33, "Section"], Cell[31869, 1057, 711, 19, 128, "Text"], Cell[32583, 1078, 76, 2, 30, "Input"], Cell[32662, 1082, 455, 13, 71, "Text"], Cell[33120, 1097, 681, 15, 81, "Input"], Cell[33804, 1114, 2683, 74, 416, "Text"], Cell[36490, 1190, 99, 2, 30, "Input"], Cell[36592, 1194, 143, 4, 33, "Text"], Cell[36738, 1200, 81, 2, 30, "Input"], Cell[36822, 1204, 164, 6, 33, "Text"], Cell[36989, 1212, 99, 2, 30, "Input"], Cell[37091, 1216, 296, 12, 52, "Text"], Cell[37390, 1230, 81, 2, 30, "Input"], Cell[37474, 1234, 99, 2, 30, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[37610, 1241, 68, 1, 33, "Section"], Cell[37681, 1244, 380, 11, 90, "Text"], Cell[38064, 1257, 1777, 52, 147, "Text"], Cell[39844, 1311, 86, 2, 30, "Input"], Cell[39933, 1315, 977, 34, 109, "Text"], Cell[40913, 1351, 71, 2, 30, "Input"], Cell[40987, 1355, 73, 2, 30, "Input"], Cell[41063, 1359, 71, 2, 30, "Input"], Cell[41137, 1363, 75, 2, 30, "Input"], Cell[41215, 1367, 76, 2, 30, "Input"], Cell[41294, 1371, 540, 12, 90, "Text"], Cell[41837, 1385, 79, 2, 30, "Input"], Cell[41919, 1389, 88, 2, 30, "Input"], Cell[42010, 1393, 77, 2, 30, "Input"], Cell[42090, 1397, 731, 18, 128, "Text"], Cell[42824, 1417, 267, 6, 90, "Input"], Cell[43094, 1425, 647, 18, 109, "Text"], Cell[43744, 1445, 279, 7, 52, "Text"], Cell[44026, 1454, 208, 6, 52, "Text"], Cell[44237, 1462, 71, 2, 30, "Input"], Cell[44311, 1466, 141, 6, 33, "Text"], Cell[44455, 1474, 71, 2, 30, "Input"], Cell[44529, 1478, 222, 7, 52, "Text"], Cell[44754, 1487, 357, 11, 71, "Text"], Cell[45114, 1500, 79, 2, 30, "Input"], Cell[45196, 1504, 271, 10, 52, "Text"], Cell[45470, 1516, 63, 2, 30, "Input"], Cell[45536, 1520, 270, 10, 52, "Text"], Cell[45809, 1532, 85, 2, 30, "Input"], Cell[45897, 1536, 680, 20, 109, "Text"], Cell[46580, 1558, 68, 2, 30, "Input"], Cell[46651, 1562, 493, 18, 71, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[47181, 1585, 59, 1, 33, "Section"], Cell[47243, 1588, 898, 28, 128, "Text"], Cell[48144, 1618, 92, 2, 30, "Input"], Cell[48239, 1622, 194, 6, 33, "Text"], Cell[48436, 1630, 71, 2, 30, "Input"], Cell[48510, 1634, 510, 12, 90, "Text"], Cell[49023, 1648, 109, 2, 30, "Input"], Cell[49135, 1652, 164, 6, 33, "Text"], Cell[49302, 1660, 74, 2, 30, "Input"], Cell[49379, 1664, 215, 9, 33, "Text"], Cell[49597, 1675, 77, 2, 30, "Input"], Cell[49677, 1679, 821, 28, 90, "Text"], Cell[50501, 1709, 73, 2, 30, "Input"], Cell[50577, 1713, 343, 10, 52, "Text"], Cell[50923, 1725, 67, 1, 33, "Text"], Cell[50993, 1728, 72, 2, 30, "Input"], Cell[51068, 1732, 146, 6, 33, "Text"], Cell[51217, 1740, 1808, 65, 166, "Text"], Cell[53028, 1807, 78, 2, 30, "Input"], Cell[53109, 1811, 82, 2, 30, "Input"], Cell[53194, 1815, 85, 2, 30, "Input"], Cell[53282, 1819, 89, 1, 33, "Text"], Cell[53374, 1822, 82, 2, 30, "Input"], Cell[53459, 1826, 85, 2, 30, "Input"], Cell[53547, 1830, 71, 2, 30, "Input"], Cell[53621, 1834, 202, 7, 52, "Text"], Cell[53826, 1843, 83, 2, 30, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[53946, 1850, 75, 1, 33, "Section"], Cell[54024, 1853, 704, 18, 109, "Text"], Cell[54731, 1873, 126, 3, 50, "Input"], Cell[54860, 1878, 89, 2, 30, "Input"], Cell[54952, 1882, 113, 2, 30, "Input"], Cell[55068, 1886, 110, 3, 33, "Text"], Cell[55181, 1891, 130, 3, 30, "Input"], Cell[55314, 1896, 794, 27, 90, "Text"], Cell[56111, 1925, 64, 2, 30, "Input"], Cell[56178, 1929, 64, 2, 30, "Input"], Cell[56245, 1933, 753, 34, 71, "Text"], Cell[57001, 1969, 64, 2, 30, "Input"], Cell[57068, 1973, 333, 14, 52, "Text"], Cell[57404, 1989, 68, 2, 30, "Input"], Cell[57475, 1993, 68, 2, 30, "Input"], Cell[57546, 1997, 59, 2, 30, "Input"], Cell[57608, 2001, 64, 2, 30, "Input"], Cell[57675, 2005, 64, 2, 30, "Input"], Cell[57742, 2009, 491, 22, 52, "Text"], Cell[58236, 2033, 64, 2, 30, "Input"], Cell[58303, 2037, 65, 1, 33, "Text"], Cell[58371, 2040, 164, 3, 50, "Input"], Cell[58538, 2045, 561, 19, 71, "Text"], Cell[59102, 2066, 93, 2, 30, "Input"], Cell[59198, 2070, 79, 2, 30, "Input"], Cell[59280, 2074, 128, 4, 33, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[59445, 2083, 75, 1, 33, "Section"], Cell[59523, 2086, 198, 6, 33, "Text"], Cell[59724, 2094, 76, 2, 30, "Input"], Cell[59803, 2098, 644, 20, 109, "Text"], Cell[60450, 2120, 81, 2, 30, "Input"], Cell[60534, 2124, 366, 11, 71, "Text"], Cell[60903, 2137, 346, 12, 52, "Text"], Cell[61252, 2151, 85, 2, 30, "Input"], Cell[61340, 2155, 72, 2, 30, "Input"], Cell[61415, 2159, 297, 6, 71, "Text"], Cell[61715, 2167, 77, 2, 30, "Input"], Cell[61795, 2171, 77, 2, 30, "Input"], Cell[61875, 2175, 228, 7, 52, "Text"], Cell[62106, 2184, 107, 2, 30, "Input"], Cell[62216, 2188, 108, 2, 30, "Input"], Cell[62327, 2192, 212, 5, 52, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[62576, 2202, 83, 1, 33, "Section"], Cell[62662, 2205, 501, 14, 90, "Text"], Cell[63166, 2221, 98, 2, 30, "Input"], Cell[63267, 2225, 327, 9, 52, "Text"], Cell[63597, 2236, 78, 2, 30, "Input"], Cell[63678, 2240, 345, 10, 52, "Text"], Cell[64026, 2252, 73, 2, 30, "Input"], Cell[64102, 2256, 272, 10, 52, "Text"], Cell[64377, 2268, 68, 2, 30, "Input"], Cell[64448, 2272, 1341, 36, 185, "Text"], Cell[65792, 2310, 69, 2, 30, "Input"], Cell[65864, 2314, 69, 2, 30, "Input"], Cell[65936, 2318, 72, 2, 30, "Input"], Cell[66011, 2322, 386, 15, 52, "Text"], Cell[66400, 2339, 83, 2, 30, "Input"], Cell[66486, 2343, 77, 1, 33, "Text"], Cell[66566, 2346, 64, 2, 30, "Input"], Cell[66633, 2350, 376, 10, 71, "Text"], Cell[67012, 2362, 70, 2, 30, "Input"], Cell[67085, 2366, 211, 9, 33, "Text"], Cell[67299, 2377, 62, 2, 30, "Input"], Cell[67364, 2381, 711, 24, 90, "Text"], Cell[68078, 2407, 64, 2, 30, "Input"], Cell[68145, 2411, 299, 10, 52, "Text"], Cell[68447, 2423, 572, 12, 109, "Text"], Cell[69022, 2437, 267, 7, 52, "Text"], Cell[69292, 2446, 104, 3, 50, "Input"], Cell[69399, 2451, 144, 6, 33, "Text"], Cell[69546, 2459, 62, 2, 30, "Input"], Cell[69611, 2463, 301, 6, 71, "Text"], Cell[69915, 2471, 122, 3, 50, "Input"], Cell[70040, 2476, 71, 2, 30, "Input"], Cell[70114, 2480, 62, 2, 30, "Input"], Cell[70179, 2484, 64, 2, 30, "Input"], Cell[70246, 2488, 326, 12, 52, "Text"], Cell[70575, 2502, 361, 10, 71, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[70973, 2517, 430, 14, 35, "Section"], Cell[71406, 2533, 123, 3, 33, "Text"], Cell[71532, 2538, 869, 27, 36, "Input", Evaluatable->False], Cell[72404, 2567, 630, 14, 109, "Text"] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)