(************** Content-type: application/mathematica ************** 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[ 14467, 468]*) (*NotebookOutlinePosition[ 15326, 499]*) (* CellTagsIndexPosition[ 15282, 495]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{Cell[TextData[{ "Example 01\n", StyleBox["Mathematica", FontSlant->"Italic"], StyleBox[" ", FontSize->18], "as a Simple Calculator" }], "Title", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Copyright ", StyleBox["\[Copyright]", FontSlant->"Plain"], " 1993 by Bill Titus, Carleton College, \nDepartment of Physics and \ Astronomy, Northfield, MN 55057-4025\nSeptember 6, 1993" }], "Subsubtitle", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Topics and Skills", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 1. Launching MMA. 2. Opening a MMA notebook from within MMA. 3. Brief definition of the kernel and the notebook front end. 4. MMA as a calculator. 5. Simple arithmetic operators. 6. Basic information on input and output cells. 7. Editing contents of cells. 8. Special MMA objects (atomic types). 9. Saving a MMA notebook. 10. Opening a MMA notebook from a file name or icon.\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Problem", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ A ball is thrown vertically upward at 20 m/s from the top of the Olin Hall \ of Science. What's the ball's velocity and position at the time to = 3.0 s \ after launch?\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ The basic free fall equations, assuming the x-axis points vertically upward \ and that the origin of the coordinate system is at the launch point, are:\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "\tv[t] = v[0] - gt\n x[t] = v[0]t - gt", StyleBox["2", FontVariations->{"CompatibilityType"->"Superscript"}], "/2" }], "Special1", ImageRegion->{{0, 1}, {0, 1}}, FontFamily->"Courier", FontSize->13], Cell[TextData[{ "The initial information is then v[0] = 20 m/s, to = 3.0 s, and g = 9.8 \ m/s", StyleBox["2", FontVariations->{"CompatibilityType"->"Superscript"}], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Solution", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Step 1 - Launch MMA's front end by double-clicking the MMA icon.\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 1", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 1. The kernel is the mathematical engine. 2. The notebook front end is for input and output.\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 2 - Use the MMA menu system to located and open the file ", StyleBox[" Ex01.ma", FontFamily->"Helvetica"] }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 3 - You'll first use MMA as a calculator and find v[to], assuming \ all the numbers are integers. Take g = 9 and use ", StyleBox["*", FontFamily->"Courier"], " for multiplication and ", StyleBox[" - ", FontFamily->"Courier"], " for subtraction. Move the cursor below this cell. When it becomes a \ horizontal bar, click the mouse and type in the appropriate numbers. Press \ ", StyleBox["", FontFamily->"Helvetica"], " to send the results to the kernel. " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 3", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. The first time you enter any result, it takes what seems like a long \ time for MMA to respond. Why?\n2. To activate a cell, you can use either \ ", StyleBox["", FontFamily->"Helvetica"], " or ", StyleBox[" ", FontFamily->"Helvetica"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 4 - Now calculate x[to], again assuming all the number are \ integers. Use ", StyleBox["^", FontFamily->"Courier"], " for power and ", StyleBox[" /", FontFamily->"Courier"], " for division." }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 4", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Arithmetic operators: addition, subtraction, multiplication, power, \ and division.\n2. Special objects (atomic types): Integers and Rationals.\n\ 3. Input and output cells: the ", StyleBox["In[] ", FontFamily->"Courier"], "and ", StyleBox["Out[]", FontFamily->"Courier"], " notation.\n4. Cells: definition, boundaries, brackets, cursor, and \ creation.\n5. Standard use for parentheses to group numbers." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell["\<\ Step 5 - In a cell below, repeat the calculations for v[to] and x[to] \ with reals, now using g = 9.8. Use parentheses to make the order of the \ evaluation clear.\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 5", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 1. Atomic type: Real. 2. Real and Integer types can be mixed, but the result is a Real.\ \>", "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 6 - Copy the last input cell for x[to] to a new cell below by \ highlighting the old cell's bracket, pressing ", StyleBox["-c", FontFamily->"Helvetica"], ", clicking the cursor below Step 6's cell when you see the cusor become a \ horizontal bar, and then pressing ", StyleBox["-v", FontFamily->"Helvetica"], ". Now replace the two ", StyleBox["*", FontFamily->"Courier"], " with spaces and enter the calculation. Note that your cursor can be \ anywhere in the input cell when you press ", StyleBox["", FontFamily->"Helvetica"], ". What do you find?" }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 6", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Use standard commands to edit the contents of cells. If you forget \ what to use, go to MMA's ", StyleBox["Edit", FontFamily->"Helvetica"], " menu." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 7 - Editing old output. Go back to the previous input, change g to \ 9.81, and enter the calculation. What do you observe about the reference \ numbers for ", StyleBox["In[]", FontFamily->"Courier"], " and ", StyleBox["Out[]", FontFamily->"Courier"], "?" }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 7", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. What's the index order for the ", StyleBox["In[]", FontFamily->"Courier"], "'s (input) and ", StyleBox["Out[]", FontFamily->"Courier"], "'s (output)?\n2. Ways to reference cells:\n a. ", StyleBox["%", FontFamily->"Courier"], ", ", StyleBox["%%", FontFamily->"Courier"], ", ", StyleBox["%%%", FontFamily->"Courier"], " ", StyleBox["...", FontFamily->"Courier"], "\n b. ", StyleBox["%n", FontFamily->"Courier"], "\n c. ", StyleBox["In[n]", FontFamily->"Courier"], " or ", StyleBox["Out[n]", FontFamily->"Courier"], "; ", StyleBox["n", FontFamily->"Courier"], " can be negative, so ", StyleBox["In[-1]", FontFamily->"Courier"], " is equivalent to %." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell["\<\ Step 8 - Check for the presence of the missing input and output cells using \ some of the cell reference options discussed in Comment 7.\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Step 9 - You're now going to calculate v[to] and x[to] using reals \ along with symbols for units. Right after your numbers, type a space and \ then type in unit(s) using the symbols ", StyleBox["m ", FontFamily->"Courier"], " for meters and ", StyleBox["sec", FontFamily->"Courier"], " for seconds. Use parentheses to make the groupings clear. " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 9", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Error message : MMA is warning you that there's a MMA symbol very \ similar to yours. Error messages are meant to be helpful. Sometimes they \ are and sometimes they're not.\n2. Go back to the last input, stick in an \ extra left parenthesis somewhere, and enter the results. What happens? \n\ 3. Atomic type: Symbol: ", StyleBox["m", FontFamily->"Courier"], ", ", StyleBox["sec", FontFamily->"Courier"], "\n a. MMA defines its own symbols with upper case letters.\n b. \ Start your symbols with lower case letters.\n c. Don't start symbols \ with numbers. What do you think ", StyleBox["5sec", FontFamily->"Courier"], " means?\n4. In your calculation, did you really need a space between the \ number and its symbol?\n5. Atomic type: Complex: 5.0 + 6.5I. Complex \ distinguishes between Integer, Rational, and Real.\n6. Atomic type: String: \ \"my string\"." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 10 - Use ", StyleBox["Save As", FontFamily->"Helvetica"], " in MMA's Notebook menu to save this notebook in your directory under", StyleBox[" myEx01", FontFamily->"Helvetica"], ". Then quit MMA. Look in your directory to see whether the file was \ indeed saved. What extension to you see on the file? " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 10", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. MMA file extension ", StyleBox[" ma ", FontFamily->"Helvetica"], " is added to the file under NeXTStep, but not on Macs.\n2. Under \ NeXTStep, there's also a ", StyleBox[".mb", FontFamily->"Helvetica"], " file which contains, among other things, formating information. You can \ usually eliminate the ", StyleBox[".mb ", FontFamily->"Helvetica"], " file without undue harm." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[TextData[{ "Step 11 - Reload your file ", StyleBox["myEx01", FontFamily->"Helvetica"], " into MMA by double-clicking on the file's name or its icon. " }], "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment 11", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. Notice that the ", StyleBox["In[]", FontFamily->"Courier"], " and ", StyleBox["Out[] ", FontFamily->"Courier"], "aren't saved. Why? " }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]]}, Open]], Cell[CellGroupData[{Cell["Practice Problems", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 1. Calculate the area of a circle of radius 2.5 m, keeping the unit for \ the meter in your calculation.\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 2. Use the unit conversion method to find the number of seconds in a year, \ starting with 60 sec = 1 min. Use parentheses to make the conversion \ factors and calculation clear. Type all the input on one line; the input \ won't wrap around. When you enter the calculation, you may get an error \ message, depending on what symbols you use for the various units.\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 3. Repeat practice problem 2, but break the line between two parentheses \ using the return key. What happens when you now enter the calculation? Why? \ How can you avoid this problem?\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[CellGroupData[{Cell["Comment ", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "1. It's ok to break up a command with a ", StyleBox["", FontFamily->"Helvetica"], " provided what's on a single line can't be executed by itself." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell["\<\ 4. Cube the complex number 4 + 5I. Now take its reciprocal. Repeat with \ the complex number 4 + 5.0I. Why do the results differ?\ \>", "Subsection", ImageRegion->{{0, 1}, {0, 1}}]}, Open]], Cell[CellGroupData[{Cell["Save Your Notebook", "Section", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "In order to conserve on memory space, remove all the output cells from \ this notebook by highlighting the output cell bracket and pressing ", StyleBox["-x", FontFamily->"Helvetica"], ". Then select ", StyleBox["Save", FontFamily->"Helvetica"], " to store your notebook under the name ", StyleBox["myEx01", FontFamily->"Helvetica"], "." }], "Special1", ImageRegion->{{0, 1}, {0, 1}}]}, Open]]}, Open]] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowToolbars->{}, CellGrouping->Manual, WindowSize->{499, 599}, WindowMargins->{{36, Automatic}, {Automatic, 0}}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False} ] (******************************************************************* 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[1727, 52, 193, 8, 70, "Title"], Cell[1923, 62, 265, 7, 70, "Subsubtitle"], Cell[CellGroupData[{ Cell[2211, 71, 69, 1, 70, "Section"], Cell[2283, 74, 453, 12, 70, "Special1"] }, Open ]], Cell[CellGroupData[{ Cell[2768, 88, 59, 1, 70, "Section"], Cell[2830, 91, 234, 5, 70, "Special1"], Cell[3067, 98, 212, 4, 70, "Special1"], Cell[3282, 104, 231, 8, 70, "Special1"], Cell[3516, 114, 231, 7, 70, "Special1"] }, Open ]], Cell[CellGroupData[{ Cell[3779, 123, 60, 1, 70, "Section"], Cell[3842, 126, 127, 3, 70, "Subsection"], Cell[CellGroupData[{ Cell[3992, 131, 64, 1, 70, "Subsection"], Cell[4059, 134, 155, 4, 70, "Special1"] }, Open ]], Cell[4226, 140, 186, 5, 70, "Subsection"], Cell[4415, 147, 575, 15, 70, "Subsection"], Cell[CellGroupData[{ Cell[5013, 164, 64, 1, 70, "Subsection"], Cell[5080, 167, 353, 11, 70, "Special1"] }, Open ]], Cell[5445, 180, 289, 10, 70, "Subsection"], Cell[CellGroupData[{ Cell[5757, 192, 64, 1, 70, "Subsection"], Cell[5824, 195, 505, 12, 70, "Special1"] }, Open ]], Cell[6341, 209, 232, 5, 70, "Subsection"], Cell[CellGroupData[{ Cell[6596, 216, 64, 1, 70, "Subsection"], Cell[6663, 219, 151, 4, 70, "Special1"] }, Open ]], Cell[6826, 225, 693, 18, 70, "Subsection"], Cell[CellGroupData[{ Cell[7542, 245, 64, 1, 70, "Subsection"], Cell[7609, 248, 231, 7, 70, "Special1"] }, Open ]], Cell[7852, 257, 354, 11, 70, "Subsection"], Cell[CellGroupData[{ Cell[8229, 270, 64, 1, 70, "Subsection"], Cell[8296, 273, 832, 36, 70, "Special1"] }, Open ]], Cell[9140, 311, 199, 4, 70, "Subsection"], Cell[9342, 317, 444, 11, 70, "Subsection"], Cell[CellGroupData[{ Cell[9809, 330, 64, 1, 70, "Subsection"], Cell[9876, 333, 993, 21, 70, "Special1"] }, Open ]], Cell[10881, 356, 401, 10, 70, "Subsection"], Cell[CellGroupData[{ Cell[11305, 368, 65, 1, 70, "Subsection"], Cell[11373, 371, 475, 14, 70, "Special1"] }, Open ]], Cell[11860, 387, 219, 6, 70, "Subsection"], Cell[CellGroupData[{ Cell[12102, 395, 65, 1, 70, "Subsection"], Cell[12170, 398, 226, 9, 70, "Special1"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[12437, 409, 69, 1, 70, "Section"], Cell[12509, 412, 170, 4, 70, "Subsection"], Cell[12682, 418, 430, 7, 70, "Subsection"], Cell[13115, 427, 251, 5, 70, "Subsection"], Cell[CellGroupData[{ Cell[13389, 434, 63, 1, 70, "Subsection"], Cell[13455, 437, 233, 6, 70, "Special1"] }, Open ]], Cell[13700, 445, 199, 4, 70, "Subsection"] }, Open ]], Cell[CellGroupData[{ Cell[13931, 451, 70, 1, 70, "Section"], Cell[14004, 454, 442, 13, 70, "Special1"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)