(* 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[ 9129, 320] NotebookOptionsPosition[ 8240, 284] NotebookOutlinePosition[ 8627, 301] CellTagsIndexPosition[ 8584, 298] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Introduction to the ", StyleBox["Mathematica", FontSlant->"Italic"], " \nComputing Environment" }], "Title", TextAlignment->Center, FontFamily->"Times"], Cell[TextData[{ "This laboratory will introduce to several of the aspects of programming, \ printing results, and plotting in the ", StyleBox["Mathematica", FontSlant->"Italic"], " environment. You will be presented with an example of a code that performs \ a calculation and prints the result. You will then be asked to solve a \ similar problem on your own. The second part of the laboratory will introduce \ you to plotting with ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text", FontSize->14], Cell[CellGroupData[{ Cell["1. A Simple Calculation with Output", "Section", FontFamily->"Times"], Cell[TextData[{ "Consider the following problem. The radioactive decay of the element \ thorium is given by the equation \n\n \ ", Cell[BoxData[ FormBox[ SubscriptBox["N", "f"], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ SubscriptBox["N", "i"], TraditionalForm]]], " ", Cell[BoxData[ FormBox[ SuperscriptBox["e", RowBox[{"-", "\[Lambda]t"}]], TraditionalForm]]], "\n\nwhere \[Lambda]=", Cell[BoxData[ FormBox[ RowBox[{"ln", " ", RowBox[{"2", " ", "/", " ", SubscriptBox["t", RowBox[{"1", "/", "2"}]]}]}], TraditionalForm]]], " = ", Cell[BoxData[ FormBox[ RowBox[{"1.14", "\[Times]", SuperscriptBox["10", RowBox[{"-", "8"}]]}], TraditionalForm]]], " ", Cell[BoxData[ FormBox[ SuperscriptBox["s", RowBox[{"-", "1"}]], TraditionalForm]]], " and ", Cell[BoxData[ FormBox[ SubscriptBox["N", "f"], TraditionalForm]]], " is the number of remaining thorium nuclei, ", Cell[BoxData[ FormBox[ SubscriptBox["N", "i"], TraditionalForm]]], " is the initial number of thorium nuclei, t is the time elapsed, and ", Cell[BoxData[ FormBox[ SubscriptBox["t", RowBox[{"1", "/", "2"}]], TraditionalForm]]], " is the half-life of the thorium. When t=0, ", Cell[BoxData[ FormBox[ SubscriptBox["N", "f"], TraditionalForm]]], " is equal to ", Cell[BoxData[ FormBox[ SubscriptBox["N", "0"], TraditionalForm]]], " and no decay has occurred. As t increases the amount of thorium, ", Cell[BoxData[ FormBox[ SubscriptBox["N", "f"], TraditionalForm]]], " decreases. Below is a short code that calculates the amount of thorium \ remaining after a given time. Execute the code and investigate the functions \ of the different elements of the code. For example, what happens if you \ remove the \";\" or the \"(*\" from one of the lines. Notice the use of \ comments and variable names that make the code readable." }], "Text", TextAlignment->Left], Cell[BoxData[ StyleBox[ RowBox[{ RowBox[{"Ni", "=", " ", "1000.0"}], ";", " ", RowBox[{"(*", " ", RowBox[{"Initial", " ", "Amount", " ", "in", " ", "kg"}], " ", "*)"}], "\n", RowBox[{"time", " ", "=", " ", "2000"}], ";", " ", RowBox[{"(*", " ", RowBox[{"Decay", " ", "time", " ", "in", " ", RowBox[{"seconds", "."}]}], " ", "*)"}], "\n", RowBox[{"lambda", " ", "=", " ", RowBox[{"1.14", "*", RowBox[{"10", "^", RowBox[{"(", RowBox[{"-", "8"}], ")"}]}]}]}], ";", " ", RowBox[{"(*", " ", RowBox[{"Decay", " ", "constant", " ", "in", " ", RowBox[{"s", "^", RowBox[{"(", RowBox[{"-", "1"}], ")"}]}]}], " ", "*)"}], "\n", RowBox[{"Nf", "=", " ", RowBox[{"Ni", "*", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", "lambda"}], "*", "time"}], "]"}]}]}], ";", "\n", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "Nf", ",", "\"\< kg.\>\""}], "]"}]}], FontSize->14]], "Input", FontSize->12] }, Open ]], Cell[CellGroupData[{ Cell["2. The Volume of a Hollow Ball", "Section", FontFamily->"Charter"], Cell["\<\ Write a program to compute the volume of the shell of a hollow ball. Clearly \ show the user which quantities are to be entered. Consider the example in \ Part 1.\ \>", "Text", FontFamily->"Charter"] }, Open ]], Cell[CellGroupData[{ Cell["3. Plotting a Falling Object", "Section", FontFamily->"Charter"], Cell[TextData[{ "A ball is tossed from the top of the Gottwald Science Center. The height of \ the ball, h, as a function of time, t, is\n\n \ ", StyleBox["y(t)", FontSlant->"Italic"], " = -", Cell[BoxData[ FormBox[ FractionBox["1", "2"], TraditionalForm]]], "g", Cell[BoxData[ FormBox[ SuperscriptBox["t", "2"], TraditionalForm]]], " + ", Cell[BoxData[ FormBox[ SubscriptBox["v", "iy"], TraditionalForm]]], "t + ", Cell[BoxData[ FormBox[ SubscriptBox["y", "i"], TraditionalForm]]], "\n\nwhere ", StyleBox["g", FontSlant->"Italic"], " is the acceleration of gravity, ", Cell[BoxData[ FormBox[ SubscriptBox["v", "iy"], TraditionalForm]]], " is the initial speed in the vertical direction, and ", Cell[BoxData[ FormBox[ SubscriptBox["y", "i"], TraditionalForm]]], " is the height from which the ball is thrown. We want to make a plot of \ this function when ", Cell[BoxData[ FormBox[ SubscriptBox["v", "iy"], TraditionalForm]]], "=3.0 m/s and ", Cell[BoxData[ FormBox[ SubscriptBox["y", "i"], TraditionalForm]]], " is 10.0 m. Execute the code and investigate the functions of the different \ elements of the code. Note especially how functions are defined." }], "Text", FontFamily->"Charter"], Cell[BoxData[{ RowBox[{ RowBox[{"viy", "=", "9.0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"yi", "=", "1.0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"grav", "=", "9.8"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"y", "[", "t_", "]"}], ":=", RowBox[{ RowBox[{ RowBox[{"-", "0.5"}], "*", "grav", "*", SuperscriptBox["t", "2"]}], "+", RowBox[{"viy", "*", "t"}], "+", "yi"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"myfunc", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"t", ",", RowBox[{"y", "[", "t", "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "2", ",", "0.2`"}], "}"}]}], "]"}]}], ";", RowBox[{"ListPlot", "[", RowBox[{"myfunc", ",", RowBox[{"Joined", "\[Rule]", "True"}], ",", RowBox[{"Frame", "\[Rule]", "True"}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\<\>\"", ",", "\"\<\>\""}], "}"}]}]}], "]"}]}]}], "Input", CellChangeTimes->{{3.408106630917713*^9, 3.40810670595925*^9}}, FontFamily->"Charter", FontSize->12] }, Open ]], Cell[CellGroupData[{ Cell["4. The Gaussian Density Function", "Section", FontFamily->"Charter"], Cell[TextData[{ "The Gaussian density function is a common function in physics. It is \ defined by the expression\n\n y = ", Cell[BoxData[ FormBox[ FractionBox["1", SqrtBox["2"]], TraditionalForm]]], Cell[BoxData[ FormBox[ SuperscriptBox["e", RowBox[{ RowBox[{"-", SuperscriptBox["x", "2"]}], "/", "2"}]], TraditionalForm]]], " .\n \nWrite a \ code that calculates the value of y at a series of points and enters the data \ into an array. Plot the array with ", StyleBox["ListPlot", FontFamily->"Courier"], ". Consider the example in Part 3." }], "Text", FontFamily->"Charter"] }, Open ]] }, Open ]] }, WindowSize->{996, 939}, WindowMargins->{{62, Automatic}, {Automatic, 4}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, FrontEndVersion->"6.0 for Linux x86 (32-bit) (April 20, 2007)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 176, 7, 141, "Title"], Cell[769, 32, 520, 13, 95, "Text"], Cell[CellGroupData[{ Cell[1314, 49, 76, 1, 74, "Section"], Cell[1393, 52, 2013, 65, 190, "Text"], Cell[3409, 119, 1037, 30, 126, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[4483, 154, 73, 1, 73, "Section"], Cell[4559, 157, 210, 5, 49, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[4806, 167, 71, 1, 73, "Section"], Cell[4880, 170, 1309, 45, 159, "Text"], Cell[6192, 217, 1192, 35, 136, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[7421, 257, 75, 1, 73, "Section"], Cell[7499, 260, 713, 20, 147, "Text"] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)