(* Content-type: application/mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 6.0' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 145, 7]
NotebookDataLength[ 17949, 673]
NotebookOptionsPosition[ 13499, 528]
NotebookOutlinePosition[ 13908, 544]
CellTagsIndexPosition[ 13865, 541]
WindowFrame->Normal
ContainsDynamic->False*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[CellGroupData[{
Cell[TextData[{
StyleBox["Mathematica ",
FontSlant->"Italic"],
"Numerics"
}], "Title",
Evaluatable->False,
AspectRatioFixed->True],
Cell["\<\
by
K. D. Stroyan
University of Iowa\
\>", "Subsubtitle",
Evaluatable->False,
AspectRatioFixed->True],
Cell["copyright 2007 by Keith Stroyan - All rights reserved.", "Text",
Evaluatable->False,
CellChangeTimes->{{3.397565813092762*^9, 3.397565820816804*^9}},
AspectRatioFixed->True,
FontFamily->"Times"],
Cell[CellGroupData[{
Cell[TextData[{
" Review: Closed and Open ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" Cells"
}], "Section",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"The NoteBook ",
StyleBox["MmaNtBkCells",
FontWeight->"Bold"],
" introduces you to use of cells."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Times"],
Cell["\<\
To open a closed cell, use your mouse to position the cursor over the dark \
arrowhead and click the button on the mouse twice rapidly. When you are done \
looking at a section, you can position the cursor at the far right bracket \
again and double click to close that section.\
\>", "Text",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Times"],
Cell["\<\
Open the cell containing \"Notebook Overview\" now. Then close this cell.\
\>", "Text",
Evaluatable->False,
AspectRatioFixed->True,
FontFamily->"Times"]
}, Open ]],
Cell[CellGroupData[{
Cell[" Notebook Overview", "Section",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
"This NoteBook introduces you to numerical computations in ",
StyleBox["Mathematica",
FontSlant->"Italic"],
". This includes both exact and decimal arithmetic and simple variable \
expressions that are assigned numerical values. Work the Exercises as they \
arise in the NoteBook. The other calculations show you how to solve the \
exercises."
}], "Text"],
Cell[CellGroupData[{
Cell["References to the Text", "Subsection"],
Cell["This NoteBook goes with Chapter 1 of the text.", "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell["Numerics in Mathematica", "Section",
Evaluatable->False,
AspectRatioFixed->True],
Cell["\<\
Mathematica can do arithmetic just like an ordinary calculator. Unlike a \
calculator, however, Mathematica can also give exact results.\
\>", "Text"],
Cell[CellGroupData[{
Cell["Exact Rational Arithmetic", "Subsection"],
Cell["\<\
Computations can only be executed if they are entered in \"input\" cells. \
These are marked with the plain square brackets (with no flags or arrows.) \
Inactive text and \"output\" cells have the little tick mark (or flag) at the \
top. Mathematica cannot do a computation if you type it in an inactive cell.\
\
\>", "Text"],
Cell["\<\
Once a computation is typed in an input cell, you must press the Enter key at \
the far right of the keyboard (you can also use + ). Your \
commands must be in an input (or active computation) cell and the answer will \
be in an output (inactive) cell. The pair looks like the following:\
\>", "Text"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"15", "+", "20"}]], "Input"],
Cell[OutputFormData["\<\
35\
\>", "\<\
35\
\>"], "Output"]
}, Closed]],
Cell["\<\
A space (or * ) between numbers is Mathematica's notation for multiplication. \
For example, 2*3 evaluates to 6. So does 2 3, but it is sometimes hard to \
read the space...\
\>", "Text"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"2", "*", "3"}]], "Input"],
Cell[OutputFormData["\<\
6\
\>", "\<\
6\
\>"], "Output"]
}, Closed]],
Cell["\<\
Now YOU try an exact arithmetic computation. Move the cursor to the empty \
input cell just below this cell (see the bars on the right side of the \
window), click once (so you see a little vertical line) and type\
\>", "Text"],
Cell["15/14 +5/7", "Text"],
Cell["\<\
Then press the key (or hold and press the key.)\
\>", "Text"],
Cell[BoxData[""], "Input"],
Cell["\<\
You need to be a little careful with typewriter arithmetic. For example, how \
much is 2/14*7 ? It could mean 2/(14*7) = 2/98 = 1/49 or (2/14)*7 = \
(1/7)*7 = 1. Enter the computation in the next cell to learn the order of \
Mathematica operations.\
\>", "Text"],
Cell["2/14*7", "Input"],
Cell[TextData[{
StyleBox["Mathematica",
FontSlant->"Italic"],
" has operators that look almost the same as traditional mathematical \
notation. For example, here is the previous computation in traditional \
notation:"
}], "Text"],
Cell[BoxData[
FractionBox[
RowBox[{"2", "*", "7"}], "14"]], "Input"],
Cell[TextData[{
"You can enter these operators from a \"Palette\". To get theBasid Input \
Palette, click and hold on the File menu at the top of the screen. Drag your \
mouse down to Palettes and selece BasicInput. If you put the cursor in the \
next input cell and click on the palette, you get an operatof that you can \
fil out. For example, use the following to fill in the computation ",
Cell[BoxData[
FormBox[
RowBox[{
FractionBox[
RowBox[{"2", "*", "3"}], "12"],
SqrtBox["49"]}], TraditionalForm]]],
". (You can also drag over this and paste it into the Input Cell.)"
}], "Text"],
Cell[BoxData[
RowBox[{"\n",
RowBox[{
FractionBox["\[Placeholder]", "\[Placeholder]"],
SqrtBox["\[Placeholder]"]}]}]], "Input"],
Cell["\<\
Most calculators cannot raise 3 to the 100th power and give an exact answer. \
Mathematica can. Move the cursor to the next cell, click, and then press \
to see this number.\
\>", "Text"],
Cell[BoxData[
SuperscriptBox["3", "100"]], "Input"],
Cell["Compute 3 raised to the 1000th power in the next cell.", "Text"],
Cell[BoxData[""], "Input"],
Cell["\<\
Mathematica can also perform exact calculations with fractions and built in \
operations. For example, Enter the cell below to see the exact sum of\
\>", "Text"],
Cell["1/2 + 1/3 + 1/4 + ... + 1/25", "Text"],
Cell["We use the Sum command to do the arithmetic.", "Text"],
Cell[BoxData[
RowBox[{
UnderoverscriptBox["\[Sum]",
RowBox[{"i", "=", "2"}], "25"],
FractionBox["1", "i"]}]], "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell["Floating Point (Real Number) Arithmetic", "Subsection"],
Cell["\<\
Often exact answers like the ones above above are not as useful as decimal \
approximations, especially for estimation. We can use the N command to get \
\"numerical\" (or decimal) approximations as follows:\
\>", "Text"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"N", "[",
RowBox[{
FractionBox["15", "14"], "+",
FractionBox["5", "7"]}], "]"}]], "Input"],
Cell[OutputFormData["\<\
1.785714285714286\
\>", "\<\
1.78571\
\>"], "Output"]
}, Closed]],
Cell["\<\
Enter the computation in the next cell to compare the exact sum 1/2 + 1/3 + \
...+ 1/25 that you computed above with it's decimal approximation.\
\>", "Text"],
Cell[BoxData[
RowBox[{"N", "[",
RowBox[{
UnderoverscriptBox["\[Sum]",
RowBox[{"i", "=", "2"}], "25"],
FractionBox["1", "i"]}], "]"}]], "Input"],
Cell[TextData[{
"Mathematica has many important constants built in. The natural base of \
logarithms is known to Mathematica as (upper case)\n\t\t\tE\nor the special \
(open face lower case)\n\n\t\t\t\[ExponentialE]\n\n",
StyleBox["Mathematica",
FontSlant->"Italic"],
" does not approximate this conastant unless you ask it to do so. For \
example, here are some exact computations:"
}], "Text"],
Cell[CellGroupData[{
Cell[BoxData["\[ExponentialE]"], "Input"],
Cell[OutputFormData["\<\
E\
\>", "\<\
E\
\>"], "Output"]
}, Closed]],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"Log", "[",
SuperscriptBox["E", "2"], "]"}]], "Input"],
Cell[OutputFormData["\<\
2\
\>", "\<\
2\
\>"], "Output"]
}, Closed]],
Cell["\<\
\tThe N command can be used to get numerical approximations of built-in exact \
constants. Enter the cell below to see an approximate value of E.\
\>", "Text"],
Cell["N[ E ]", "Input"],
Cell["\tYou can get higher precision as follows:", "Text"],
Cell["N[\[ExponentialE],555]", "Input"],
Cell["\<\
The number usually denoted by Greek \"pi\" is known exactly to Mathematica as
\t\t\tPi or \[Pi]
\[Pi] is the area of the unit circle, for example. You should know the exact \
values of the Sine and Cosine functions at angles such as \"30 degrees,\" \
which is \[Pi]/6 radians. Enter the computation in the next cell to see the \
value of Sin[\[Pi]/6].\
\>", "Text"],
Cell[BoxData[
RowBox[{"Sin", "[",
FractionBox["\[Pi]", "6"], "]"}]], "Input"],
Cell[BoxData["Pi"], "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell["Practice Arithmetic Exercises", "Subsection"],
Cell["\<\
1) Use Mathematica to compute 5/13 + 10/29 both exactly as a ratio of \
integers and approximately as a decimal number.\
\>", "Text"],
Cell["", "Input"],
Cell["", "Input"],
Cell["\<\
2) Use Mathematica to give the decimal approximation to the number \[Pi] \
to 666 places.\
\>", "Text"],
Cell["\<\
\
\>", "Input"],
Cell["\<\
3) Use Mathematica to give the exact value of Cosine of \"30 degrees\", \
Cos[\[Pi]/6].\
\>", "Text"],
Cell["\<\
\
\>", "Input"],
Cell["\<\
3) Compute the decimal approximation of Cosine of \"30 degrees\", \
Cos[\[Pi]/6].\
\>", "Text"],
Cell["\<\
\
\>", "Input"]
}, Closed]]
}, Open ]],
Cell[CellGroupData[{
Cell["Numerical Variables", "Section",
Evaluatable->False,
AspectRatioFixed->True],
Cell[TextData[{
StyleBox["Mathematica",
FontSlant->"Italic"],
" can assign values to variables. When you Enter the cell below, ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" will remember that \"a\" refers to the value 0.0001."
}], "Text"],
Cell[BoxData[
RowBox[{"a", "=", "0.0001"}]], "Input"],
Cell["\<\
Now if you Enter the computation in the blank cell below, Mathematica will \
give you the value associated with the constant a. (Be sure you pressed \
Enter with the insert cursor in the \"a = 0.0001\" cell above before you \
press enter in the \"a\" cell below here.\
\>", "Text"],
Cell[BoxData["a"], "Input"],
Cell[TextData[{
"A space between two numbers or constants means multiplication in ",
StyleBox["Mathematica",
FontSlant->"Italic"],
". Enter the cell below and Mathematica will multiply a by 12."
}], "Text"],
Cell[BoxData[
RowBox[{"12", " ", "a"}]], "Input"],
Cell["\<\
Mathematica will do similar algebra using this value of a. Enter the \
computation in the next cell now.\
\>", "Text"],
Cell[BoxData[
RowBox[{
RowBox[{"3", " ", "a"}], "+", "5"}]], "Input"],
Cell["\<\
Mathematica will remember the values of constants until you change them. If \
you enter the cell below, Mathematica will reset the value of a to 50. Do \
NOT Enter the next computation now, but move down two cells and Enter that \
computation.\
\>", "Text"],
Cell[TextData[{
"Then move back up and Enter the \"a = 1/50\" computation and the \
following computation again. What you will see is that ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" remembers the computations that you have Entered, not their position on \
the screen. Moreover, it performs exact arithmetic when the value assigned \
to a variable is exact and decimal arithmetic when the assigned value is \
approximate."
}], "Text"],
Cell[BoxData[
RowBox[{"a", "=",
FractionBox["1", "50"]}]], "Input"],
Cell[BoxData[
RowBox[{"a", "+", "a"}]], "Input"],
Cell[TextData[{
"You may have noticed ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" reprints the value of the constant \"a\" after you Enter that cell. \
Sometimes this may be undesirable. If a semi-colon is typed at the end of a \
line Mathematica will not print anything. For example, entering the cell \
below will set the value of b to be 3/4."
}], "Text"],
Cell[BoxData[
RowBox[{
RowBox[{"b", "=",
FractionBox["3", "4"]}], ";"}]], "Input"],
Cell["\<\
Notice that no output is generated. If you type b in the blank cell below, \
however, and Enter you will see that Mathematica has still set the value of b \
to be 3/4\
\>", "Text"],
Cell[BoxData[""], "Input"],
Cell[BoxData[{
RowBox[{
RowBox[{"c", "=", ".25"}], ";"}], "\n",
RowBox[{"a", "-", "c"}]}], "Input"],
Cell["Variables can be assigned values by expressions, ", "Text"],
Cell[BoxData[{
RowBox[{"f", "=",
RowBox[{"a", "+", "b", "+", "c"}]}], "\n",
RowBox[{"g", "=",
RowBox[{
UnderoverscriptBox["\[Sum]",
RowBox[{"i", "=", "2"}], "25"],
FractionBox["1", "i"]}]}], "\n",
RowBox[{"f", " ", "g"}]}], "Input"],
Cell[CellGroupData[{
Cell["Practice with Numerical Variables.", "Subsection"],
Cell["\<\
1) Assign values c = 15 and b = 14 in a Mathematica cell and Enter the \
assignments.\
\>", "Text"],
Cell[BoxData[""], "Input"],
Cell["\<\
2) Compute the value of the variable a = b c (or b*c) given by the \
product of b and c.\
\>", "Text"],
Cell[BoxData[""], "Input"]
}, Open ]]
}, Closed]]
}, Open ]]
},
WindowSize->{668, 717},
WindowMargins->{{0, Automatic}, {Automatic, 0}},
FrontEndVersion->"6.0 for Mac OS X PowerPC (32-bit) (June 19, 2007)",
StyleDefinitions->FrontEnd`FileName[{"Creative"}, "NaturalColor.nb",
CharacterEncoding -> "UTF-8"]
]
(* End of Notebook Content *)
(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[590, 23, 136, 6, 66, "Title",
Evaluatable->False],
Cell[729, 31, 113, 6, 60, "Subsubtitle",
Evaluatable->False],
Cell[845, 39, 204, 4, 26, "Text",
Evaluatable->False],
Cell[CellGroupData[{
Cell[1074, 47, 165, 7, 72, "Section",
Evaluatable->False],
Cell[1242, 56, 198, 8, 26, "Text",
Evaluatable->False],
Cell[1443, 66, 371, 8, 56, "Text",
Evaluatable->False],
Cell[1817, 76, 167, 5, 26, "Text",
Evaluatable->False]
}, Open ]],
Cell[CellGroupData[{
Cell[2021, 86, 83, 2, 72, "Section",
Evaluatable->False],
Cell[2107, 90, 379, 8, 81, "Text"],
Cell[CellGroupData[{
Cell[2511, 102, 44, 0, 38, "Subsection"],
Cell[2558, 104, 62, 0, 26, "Text"]
}, Closed]]
}, Closed]],
Cell[CellGroupData[{
Cell[2669, 110, 88, 2, 42, "Section",
Evaluatable->False],
Cell[2760, 114, 161, 3, 41, "Text"],
Cell[CellGroupData[{
Cell[2946, 121, 47, 0, 34, "Subsection"],
Cell[2996, 123, 338, 6, 56, "Text"],
Cell[3337, 131, 329, 5, 56, "Text"],
Cell[CellGroupData[{
Cell[3691, 140, 51, 1, 37, "Input"],
Cell[3745, 143, 58, 4, 34, "Output"]
}, Closed]],
Cell[3818, 150, 200, 4, 38, "Text"],
Cell[CellGroupData[{
Cell[4043, 158, 49, 1, 37, "Input"],
Cell[4095, 161, 56, 4, 34, "Output"]
}, Closed]],
Cell[4166, 168, 238, 4, 50, "Text"],
Cell[4407, 174, 26, 0, 20, "Text"],
Cell[4436, 176, 96, 2, 20, "Text"],
Cell[4535, 180, 26, 0, 33, "Input"],
Cell[4564, 182, 277, 5, 65, "Text"],
Cell[4844, 189, 23, 0, 33, "Input"],
Cell[4870, 191, 234, 6, 50, "Text"],
Cell[5107, 199, 71, 2, 52, "Input"],
Cell[5181, 203, 615, 13, 105, "Text"],
Cell[5799, 218, 137, 4, 65, "Input"],
Cell[5939, 224, 207, 4, 50, "Text"],
Cell[6149, 230, 52, 1, 36, "Input"],
Cell[6204, 233, 70, 0, 20, "Text"],
Cell[6277, 235, 26, 0, 33, "Input"],
Cell[6306, 237, 172, 3, 35, "Text"],
Cell[6481, 242, 44, 0, 20, "Text"],
Cell[6528, 244, 60, 0, 20, "Text"],
Cell[6591, 246, 128, 4, 62, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[6756, 255, 61, 0, 26, "Subsection"],
Cell[6820, 257, 232, 4, 56, "Text"],
Cell[CellGroupData[{
Cell[7077, 265, 123, 4, 57, "Input"],
Cell[7203, 271, 78, 4, 34, "Output"]
}, Closed]],
Cell[7296, 278, 169, 3, 38, "Text"],
Cell[7468, 283, 159, 5, 66, "Input"],
Cell[7630, 290, 402, 8, 146, "Text"],
Cell[CellGroupData[{
Cell[8057, 302, 41, 0, 37, "Input"],
Cell[8101, 304, 56, 4, 34, "Output"]
}, Closed]],
Cell[CellGroupData[{
Cell[8194, 313, 80, 2, 40, "Input"],
Cell[8277, 317, 56, 4, 34, "Output"]
}, Closed]],
Cell[8348, 324, 171, 3, 38, "Text"],
Cell[8522, 329, 23, 0, 37, "Input"],
Cell[8548, 331, 58, 0, 26, "Text"],
Cell[8609, 333, 39, 0, 37, "Input"],
Cell[8651, 335, 380, 7, 86, "Text"],
Cell[9034, 344, 81, 2, 51, "Input"],
Cell[9118, 348, 28, 0, 33, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[9183, 353, 51, 0, 26, "Subsection"],
Cell[9237, 355, 146, 3, 41, "Text"],
Cell[9386, 360, 17, 0, 37, "Input"],
Cell[9406, 362, 17, 0, 37, "Input"],
Cell[9426, 364, 118, 3, 26, "Text"],
Cell[9547, 369, 26, 3, 50, "Input"],
Cell[9576, 374, 113, 3, 26, "Text"],
Cell[9692, 379, 26, 3, 50, "Input"],
Cell[9721, 384, 107, 3, 26, "Text"],
Cell[9831, 389, 26, 3, 50, "Input"]
}, Closed]]
}, Open ]],
Cell[CellGroupData[{
Cell[9906, 398, 84, 2, 72, "Section",
Evaluatable->False],
Cell[9993, 402, 252, 7, 41, "Text"],
Cell[10248, 411, 54, 1, 37, "Input"],
Cell[10305, 414, 295, 5, 56, "Text"],
Cell[10603, 421, 27, 0, 37, "Input"],
Cell[10633, 423, 212, 5, 41, "Text"],
Cell[10848, 430, 50, 1, 37, "Input"],
Cell[10901, 433, 130, 3, 26, "Text"],
Cell[11034, 438, 72, 2, 37, "Input"],
Cell[11109, 442, 269, 5, 56, "Text"],
Cell[11381, 449, 450, 9, 71, "Text"],
Cell[11834, 460, 71, 2, 57, "Input"],
Cell[11908, 464, 49, 1, 37, "Input"],
Cell[11960, 467, 375, 8, 56, "Text"],
Cell[12338, 477, 89, 3, 56, "Input"],
Cell[12430, 482, 191, 4, 41, "Text"],
Cell[12624, 488, 26, 0, 37, "Input"],
Cell[12653, 490, 104, 3, 53, "Input"],
Cell[12760, 495, 66, 0, 26, "Text"],
Cell[12829, 497, 255, 8, 101, "Input"],
Cell[CellGroupData[{
Cell[13109, 509, 56, 0, 34, "Subsection"],
Cell[13168, 511, 114, 3, 26, "Text"],
Cell[13285, 516, 26, 0, 37, "Input"],
Cell[13314, 518, 116, 3, 26, "Text"],
Cell[13433, 523, 26, 0, 37, "Input"]
}, Open ]]
}, Closed]]
}, Open ]]
}
]
*)
(* End of internal cache information *)