(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of 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[ 5484, 184]*) (*NotebookOutlinePosition[ 6122, 207]*) (* CellTagsIndexPosition[ 6078, 203]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Assignment Expressions", "Section"], Cell[TextData[{ "This notebook is designed to accompany Chapter 3 of \"Introduction to \ Scientific Programming: Computational Problem Solving Using ", StyleBox["Mathematica", FontSlant->"Italic"], " and C\" by Joseph L. Zachary. In it, we will use ", StyleBox["Mathematica", FontSlant->"Italic"], " to explore assignment expressions. (31Jul197)" }], "Text"], Cell[CellGroupData[{ Cell["Assignment", "Subsection"], Cell["\<\ When a number is used several times in a notebook, it is better to \ assign a name to that number, rather than retyping it on every occasion. \ This eliminates errors and speeds up your workrate. For example, suppose we are doing computations that involve the population of \ the earth like we did in Chapter 2. Rather than typing the number 5.761*^9 \ every time it is used, we can assign its value to a variable, say p:\ \>", "Text"], Cell[BoxData[ \(p = \ 5.761*^9\)], "Input"], Cell["Similarly, we can assign the land area to a variable, say a:", "Text"], Cell[BoxData[ \(a = \ 57.8*^6\)], "Input"], Cell["\<\ The variables a and p will now retain these values for further \ computations. For example, we can compute the number of persons per square \ mile as \ \>", "Text"], Cell[BoxData[ \(p/a\)], "Input"], Cell["\<\ Or we could compute the side length of the square (in feet) that \ each of us get by\ \>", "Text"], Cell[BoxData[ \(5280\ *\ Sqrt[a/p]\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Choosing Variable Names", "Subsection"], Cell["\<\ It is a good strategy to pick descriptive names that you can \ quickly recall. For example, suppose we need to solve the population \ density problem of Chapter 2 for the planets Mars and Venus (assuming a means \ of sustaining the entire population of the earth on these planets has been \ found.) Then it will be good to name these variables as follows:\ \>", "Text"], Cell[BoxData[{ \(aEarth\ = \ 57.8*^6\), \(aMars\ = \ 56.0*^6\), \(aVenus\ = \ 177.7*^6\)}], "Input"], Cell["\<\ Now return to the expressions p/a and 5280*Sqrt[a/p] above. \ Re-execute them, with the appropriate variable inserted in place of a, to \ solve the population density problem for Mars and Venus.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Special Symbols", "Subsection"], Cell[TextData[{ " There are a few symbols that have a pre-defined meaning in ", StyleBox["Mathematica", FontSlant->"Italic"], " that you may not use as variable names. ", StyleBox["Mathematica", FontSlant->"Italic"], " will warn you should you transgress. For example" }], "Text"], Cell[BoxData[ \(Pi\ = \ 3\)], "Input"], Cell["\<\ The problem is that the symbol Pi is reserved for the mathematical \ constant 3.14159... If you evaluate this,\ \>", "Text"], Cell[BoxData[ \(N[Pi]\)], "Input"], Cell["\<\ You will see the first six digits of Pi. On the other hand, you can assign to pi\ \>", "Text"], Cell[BoxData[ \(pi\ = \ 3\)], "Input"], Cell[TextData[{ "This illustrates that ", StyleBox["Mathematica", FontSlant->"Italic"], " differentiates between upper-case and lower-case letters. All of ", StyleBox["Mathematica", FontSlant->"Italic"], "'s built-in symbols begin with an upper-case letter, so it is a good idea \ to arrange for all of the variables that you use to begin with a lower-case \ letter." }], "Text"], Cell[BoxData[ \(HTMLSave::"fileexists" \( : \ \) "The destination file \!\(\"/a/home/handin/hamlet/.public\" \ \\[Ellipsis] \"/notebooks/assign/assign.html\"\) already exists. In this \ implementation, it will be overwritten."\)], "Message"] }, Closed]] }, Open ]] }, FrontEndVersion->"X 3.0", ScreenRectangle->{{0, 1280}, {0, 1024}}, WindowSize->{520, 600}, WindowMargins->{{238, Automatic}, {Automatic, 152}} ] (*********************************************************************** 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[1731, 51, 41, 0, 54, "Section"], Cell[1775, 53, 378, 9, 68, "Text"], Cell[CellGroupData[{ Cell[2178, 66, 32, 0, 45, "Subsection"], Cell[2213, 68, 452, 9, 140, "Text"], Cell[2668, 79, 47, 1, 27, "Input"], Cell[2718, 82, 76, 0, 32, "Text"], Cell[2797, 84, 46, 1, 27, "Input"], Cell[2846, 87, 177, 4, 50, "Text"], Cell[3026, 93, 36, 1, 27, "Input"], Cell[3065, 96, 108, 3, 32, "Text"], Cell[3176, 101, 51, 1, 27, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[3264, 107, 45, 0, 29, "Subsection"], Cell[3312, 109, 388, 7, 86, "Text"], Cell[3703, 118, 117, 3, 59, "Input"], Cell[3823, 123, 220, 4, 68, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4080, 132, 37, 0, 29, "Subsection"], Cell[4120, 134, 300, 8, 50, "Text"], Cell[4423, 144, 43, 1, 27, "Input"], Cell[4469, 147, 135, 3, 50, "Text"], Cell[4607, 152, 38, 1, 27, "Input"], Cell[4648, 155, 105, 4, 68, "Text"], Cell[4756, 161, 43, 1, 27, "Input"], Cell[4802, 164, 398, 10, 68, "Text"], Cell[5203, 176, 253, 4, 71, "Message"] }, Closed]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)