(* 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[ 16478, 622] NotebookOptionsPosition[ 12850, 519] NotebookOutlinePosition[ 13251, 536] CellTagsIndexPosition[ 13208, 533] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell["Getting Started, Constants, and Functions", "Title"], Cell["", "Subsubtitle", CellChangeTimes->{{3.454518688515625*^9, 3.454518689375*^9}}], Cell[TextData[{ "Getting around - Using ", StyleBox["Mathematica", FontSlant->"Italic"], " as a calculator" }], "Subsubsection"], Cell["\<\ To enter an expression, just start typing! You can enter multiple \ expressions by pressing the \"Enter\" key after each one. To evaluate \ expressions, press \"Shift+Enter\". If you don't want to see the output of \ your expression, follow the expression with a semi-colon, \" ; \"\ \>", "Text"], Cell[BoxData[{ RowBox[{"1", "+", "2"}], "\[IndentingNewLine]", RowBox[{"2", "+", "2"}]}], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"3", "^", "2"}], "+", RowBox[{"4", "^", "2"}]}]], "Input"], Cell["\<\ All functions, commands, and mathematical constants start with a capital \ letter. Common examples are Sin, Cos, Sqrt, Pi, E, etc.\ \>", "Text"], Cell[TextData[{ "All functions and commands use ", StyleBox["square brackets", FontSlant->"Italic"], " ", StyleBox["not", FontWeight->"Bold"], " ", StyleBox["parentheses", FontSlant->"Italic"], ". Parentheses are used ", StyleBox["only", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], " to show order of operations." }], "Text"], Cell[BoxData[ RowBox[{"Sqrt", "[", "9", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Sin", "[", RowBox[{"Pi", "/", "2"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"ArcCos", "[", "0", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Exp", "[", "4", "]"}]], "Input"], Cell[BoxData[ RowBox[{"Exp", "[", RowBox[{"I", "*", "Pi"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Sqrt", "[", "5", "]"}]], "Input"], Cell[TextData[{ "Notice in the last expression, we asked ", StyleBox["Mathematica", FontSlant->"Italic"], " what the square root of 5 was. It responded by telling us that it is the \ square root of 5! What we really wanted was a numerical approximation to the \ square root of 5. To do this, use the N[ ] command. " }], "Text"], Cell[BoxData[ RowBox[{"N", "[", RowBox[{"Sqrt", "[", "5", "]"}], "]"}]], "Input"], Cell["\<\ What if we wanted more digits? Lets look at the help file for the command N \ [ ]\ \>", "Text"], Cell[BoxData[ RowBox[{"?", "N"}]], "Input"], Cell[BoxData[ RowBox[{"N", "[", RowBox[{ RowBox[{"Sqrt", "[", "5", "]"}], ",", "20"}], "]"}]], "Input"], Cell[TextData[{ "Lets see if ", StyleBox["Mathematica", FontSlant->"Italic"], " knows Pi to 100 digits!" }], "Text"], Cell[BoxData[ RowBox[{"N", "[", RowBox[{"Pi", ",", "100"}], "]"}]], "Input"], Cell[TextData[{ "The percent sign in ", StyleBox["Mathematica", FontSlant->"Italic"], " means 'the previous output', and it is sometimes quite handy. For example," }], "Text"], Cell[BoxData[ RowBox[{"Sqrt", "[", "924", "]"}]], "Input"], Cell[BoxData[ RowBox[{"N", "[", RowBox[{"%", ",", "10"}], "]"}]], "Input"], Cell["Cells", "Subsubsection"], Cell[TextData[{ "Information within a ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook is contained in cells. Different cells have different \ properties. The default cell type is \"Input\". When an input cell is \ evaluated, it produces an \"Output\" cell. This is what the small colored \ In[ ]:= and Out[ ]:= mean on the left side of the notebook. To create a new \ cell, move the mouse cursor until it becomes horizontal, click, and then \ start typing. \nCreate a new cell between this line ---------------" }], "Text"], Cell["and this line ----------------------------------------------", "Text"], Cell[TextData[{ "To create a text cell, (like this one), move the mouse until it becomes \ horizontal, click, then select the menu item:", StyleBox[" ", FontVariations->{"Underline"->True}], StyleBox["Format", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], StyleBox[",", FontVariations->{"Underline"->True}], " then ", StyleBox["Style", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ", then ", StyleBox["Text", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ", then type away! Try inserting a text cell right after this one. " }], "Text"], Cell[TextData[{ "To change the type of a cell, click on the blue cell marker on the right of \ the screen, then go to ", StyleBox["Format", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ", ", StyleBox["Style", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ", and choose a type." }], "Text"], Cell["Defining constants and vectors", "Subsubsection"], Cell["\<\ To define constants (numbers or vectors) use a single equals sign.\ \>", "Text"], Cell[BoxData[ RowBox[{"a", "=", "5"}]], "Input"], Cell[BoxData[ RowBox[{"b", "=", "2"}]], "Input"], Cell[TextData[{ "Vectors are entered using ", StyleBox["curly brackets", FontSlant->"Italic"], ". For example, the vector ", StyleBox["v", FontWeight->"Bold"], " = ", StyleBox["i ", FontWeight->"Bold"], "+ 3 ", StyleBox["j ", FontWeight->"Bold"], "- 2 ", StyleBox["k ", FontWeight->"Bold"], "would be entered as" }], "Text"], Cell[BoxData[ RowBox[{"v", "=", RowBox[{"{", RowBox[{"1", ",", "3", ",", RowBox[{"-", "2"}]}], "}"}]}]], "Input"], Cell["\<\ Once defined, you can use your constants anywhere in the notebook!\ \>", "Text"], Cell[BoxData[ RowBox[{"a", "+", "b"}]], "Input"], Cell[BoxData[ RowBox[{"a", "*", "v"}]], "Input"], Cell[BoxData[ RowBox[{"a", "^", "2"}]], "Input"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " can do dot and cross products for vectors. It can also find the length of \ a vector by using the command Norm[ ]" }], "Text"], Cell[BoxData[ RowBox[{"u", "=", RowBox[{"{", RowBox[{"2", ",", RowBox[{"-", "1"}], ",", "1"}], "}"}]}]], "Input"], Cell[BoxData[ RowBox[{"Dot", "[", RowBox[{"u", ",", "v"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Cross", "[", RowBox[{"u", ",", "v"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{"Norm", "[", "u", "]"}], "\[IndentingNewLine]"}]], "Input"], Cell["\<\ To clear a constant so it is again a symbolic variable, use \" = . \".\ \>", "Text"], Cell[BoxData[ RowBox[{"a", "=."}]], "Input"], Cell[BoxData[ RowBox[{"a", "+", "b"}]], "Input"], Cell[BoxData[ RowBox[{"b", "=."}]], "Input"], Cell[BoxData[ RowBox[{"a", "+", "b"}]], "Input"], Cell["\<\ If you want to clear everything you have done from memory, use the command \ Quit\ \>", "Text"], Cell[BoxData["u"], "Input"], Cell[BoxData["Quit"], "Input"], Cell[BoxData["u"], "Input"], Cell["\<\ Notice how the numbers in the In[ ] and Out[ ] were reset to 1.\ \>", "Text"], Cell["Defining functions", "Subsubsection"], Cell["\<\ To define a function, use an underscore after each argument name on the left \ hand side of the = but not on the right.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"f", "[", "x_", "]"}], "=", RowBox[{ RowBox[{"x", "^", "2"}], "-", "1"}]}]], "Input"], Cell["We can now evaluate f for any x value.", "Text"], Cell[BoxData[ RowBox[{"f", "[", "5", "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"Sqrt", "[", "9", "]"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"f", "[", RowBox[{"a", "+", "b"}], "]"}]], "Input"], Cell["\<\ We can define functions of multiple variables in the same way.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"g", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{ RowBox[{"x", "^", "2"}], "+", RowBox[{"y", "^", "2"}], "-", "1"}]}]], "Input"], Cell[BoxData[ RowBox[{"g", "[", RowBox[{"0", ",", "0"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"g", "[", RowBox[{"1", ",", "1"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"g", "[", RowBox[{"x", ",", "1"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"g", "[", RowBox[{"2", ",", "y"}], "]"}]], "Input"], Cell["Working with expressions", "Subsubsection"], Cell["\<\ There are five commands that are very helpful when you want to simplify \ expressions. They are Factor[ ] , Expand[ ] , Together[ ] , Apart[ ] , and \ Simplify[ ].\ \>", "Text"], Cell["\<\ Factor[ ] and Expand[ ] do just what they sound like - they factor or expand \ polynomials.\ \>", "Text"], Cell[BoxData[ RowBox[{"Factor", "[", RowBox[{ RowBox[{"x", "^", "3"}], "-", RowBox[{"7", RowBox[{"x", "^", "2"}]}], "+", RowBox[{"16", "x"}], "-", "12"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Factor", "[", RowBox[{"f", "[", "x", "]"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Expand", "[", RowBox[{ RowBox[{"(", RowBox[{"x", "-", "3"}], ")"}], "^", "2"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Expand", "[", RowBox[{ RowBox[{"(", RowBox[{"x", "-", "1"}], ")"}], "^", "9"}], "]"}]], "Input"], Cell["\<\ If you want the powers of x in decreasing order, you can add the command \" \ //TraditionalForm \"\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Expand", "[", RowBox[{ RowBox[{"(", RowBox[{"x", "-", "1"}], ")"}], "^", "9"}], "]"}], "//", "TraditionalForm"}]], "Input"], Cell["\<\ The commands Apart[ ] and Together[ ] are helpful when working with fractions.\ \>", "Text"], Cell[BoxData[ RowBox[{"Together", "[", RowBox[{ RowBox[{"a", "/", "b"}], "+", RowBox[{"c", "/", "d"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"Apart", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"b", "*", "c"}], "+", RowBox[{"a", "*", "d"}]}], ")"}], "/", RowBox[{"(", RowBox[{"b", "*", "d"}], ")"}]}], "]"}]], "Input"], Cell["\<\ Remember Partial fractions? What is the Partial Fraction Decomposition of 1 \ / ( (x-1)(x+1) ) ?\ \>", "Text"], Cell[BoxData[ RowBox[{"Apart", "[", RowBox[{"1", "/", RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{"x", "-", "1"}], ")"}], "*", RowBox[{"(", RowBox[{"x", "+", "1"}], ")"}]}], ")"}]}], "]"}]], "Input"], Cell["\<\ The last command, Simplify[ ], tries to find the \"Simplest\" form of an \ expression.\ \>", "Text"], Cell[BoxData[ RowBox[{"Simplify", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"x", "^", "2"}], "+", RowBox[{"2", "*", "x", "*", "y"}], "+", RowBox[{"y", "^", "2"}]}], ")"}], "/", RowBox[{"(", RowBox[{"x", "+", "y"}], ")"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"Sin", "[", "x", "]"}], "^", "2"}], "+", RowBox[{ RowBox[{"Cos", "[", "x", "]"}], "^", "2"}]}]], "Input"], Cell["\<\ OK, this should be equal to 1, right? Remember that % means 'previous \ output', and lets use Simplify[ ]\ \>", "Text"], Cell[BoxData[ RowBox[{"Simplify", "[", "%", "]"}]], "Input"], Cell["How do I save?", "Subsubsection"], Cell[TextData[{ "Before saving, go to the menu item ", StyleBox["Cell", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ", then ", StyleBox["Delete all output", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ", then click OK. This is ", StyleBox["very", FontWeight->"Bold"], " important, especially if your ", StyleBox["Mathematica", FontSlant->"Italic"], " notebook has graphs. Doing this will delete the graphs and other output, \ but it will leave all of your commands. This ", StyleBox["greatly", FontWeight->"Bold"], " reduces the size of the file. If you submit homework for class without \ doing this first, it will not be accepted\[LongDash]if it is too large, it \ won't even enter the colorado.edu system\[LongDash]and you will be asked to \ submit again." }], "Text", CellChangeTimes->{{3.452861876496085*^9, 3.452861890413157*^9}, { 3.454518803*^9, 3.454518861453125*^9}}], Cell[TextData[{ "To save, go to ", StyleBox["File", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ", then ", StyleBox[" Save as", FontWeight->"Bold", FontSlant->"Italic", FontVariations->{"Underline"->True}], ". If you are in the lab, you should save to the desktop, e-mail the file \ to yourself and your instructor, then delete the file from the desktop." }], "Text"] }, ScreenStyleEnvironment->"Working", WindowSize->{961, 858}, WindowMargins->{{-2, Automatic}, {Automatic, 0}}, ShowSelection->True, FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (February 18, 2009)", StyleDefinitions->"DemoText.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[545, 20, 58, 0, 56, "Title"], Cell[606, 22, 86, 1, 56, "Subsubtitle"], Cell[695, 25, 133, 5, 44, "Subsubsection"], Cell[831, 32, 310, 5, 43, "Text"], Cell[1144, 39, 101, 2, 59, "Input"], Cell[1248, 43, 95, 3, 38, "Input"], Cell[1346, 48, 155, 3, 25, "Text"], Cell[1504, 53, 382, 16, 25, "Text"], Cell[1889, 71, 57, 1, 38, "Input"], Cell[1949, 74, 80, 2, 38, "Input"], Cell[2032, 78, 59, 1, 38, "Input"], Cell[2094, 81, 56, 1, 38, "Input"], Cell[2153, 84, 80, 2, 38, "Input"], Cell[2236, 88, 57, 1, 38, "Input"], Cell[2296, 91, 336, 7, 43, "Text"], Cell[2635, 100, 85, 2, 38, "Input"], Cell[2723, 104, 106, 3, 25, "Text"], Cell[2832, 109, 44, 1, 38, "Input"], Cell[2879, 112, 110, 3, 38, "Input"], Cell[2992, 117, 121, 5, 25, "Text"], Cell[3116, 124, 80, 2, 38, "Input"], Cell[3199, 128, 181, 5, 25, "Text"], Cell[3383, 135, 59, 1, 38, "Input"], Cell[3445, 138, 78, 2, 38, "Input"], Cell[3526, 142, 30, 0, 44, "Subsubsection"], Cell[3559, 144, 546, 10, 91, "Text"], Cell[4108, 156, 76, 0, 25, "Text"], Cell[4187, 158, 668, 22, 43, "Text"], Cell[4858, 182, 373, 13, 25, "Text"], Cell[5234, 197, 55, 0, 44, "Subsubsection"], Cell[5292, 199, 90, 2, 25, "Text"], Cell[5385, 203, 49, 1, 38, "Input"], Cell[5437, 206, 49, 1, 38, "Input"], Cell[5489, 209, 346, 17, 25, "Text"], Cell[5838, 228, 126, 4, 38, "Input"], Cell[5967, 234, 90, 2, 25, "Text"], Cell[6060, 238, 49, 1, 38, "Input"], Cell[6112, 241, 49, 1, 38, "Input"], Cell[6164, 244, 49, 1, 38, "Input"], Cell[6216, 247, 195, 5, 25, "Text"], Cell[6414, 254, 126, 4, 38, "Input"], Cell[6543, 260, 79, 2, 38, "Input"], Cell[6625, 264, 81, 2, 38, "Input"], Cell[6709, 268, 93, 2, 59, "Input"], Cell[6805, 272, 94, 2, 25, "Text"], Cell[6902, 276, 45, 1, 38, "Input"], Cell[6950, 279, 49, 1, 38, "Input"], Cell[7002, 282, 45, 1, 38, "Input"], Cell[7050, 285, 49, 1, 38, "Input"], Cell[7102, 288, 105, 3, 25, "Text"], Cell[7210, 293, 27, 0, 38, "Input"], Cell[7240, 295, 30, 0, 38, "Input"], Cell[7273, 297, 27, 0, 38, "Input"], Cell[7303, 299, 88, 2, 25, "Text"], Cell[7394, 303, 43, 0, 44, "Subsubsection"], Cell[7440, 305, 143, 3, 25, "Text"], Cell[7586, 310, 125, 4, 38, "Input"], Cell[7714, 316, 54, 0, 25, "Text"], Cell[7771, 318, 54, 1, 38, "Input"], Cell[7828, 321, 85, 2, 38, "Input"], Cell[7916, 325, 77, 2, 38, "Input"], Cell[7996, 329, 86, 2, 25, "Text"], Cell[8085, 333, 184, 6, 38, "Input"], Cell[8272, 341, 77, 2, 38, "Input"], Cell[8352, 345, 77, 2, 38, "Input"], Cell[8432, 349, 77, 2, 38, "Input"], Cell[8512, 353, 77, 2, 38, "Input"], Cell[8592, 357, 49, 0, 44, "Subsubsection"], Cell[8644, 359, 188, 4, 25, "Text"], Cell[8835, 365, 115, 3, 25, "Text"], Cell[8953, 370, 191, 6, 38, "Input"], Cell[9147, 378, 87, 2, 38, "Input"], Cell[9237, 382, 131, 4, 38, "Input"], Cell[9371, 388, 131, 4, 38, "Input"], Cell[9505, 394, 122, 3, 25, "Text"], Cell[9630, 399, 175, 6, 38, "Input"], Cell[9808, 407, 102, 2, 25, "Text"], Cell[9913, 411, 132, 4, 38, "Input"], Cell[10048, 417, 231, 8, 38, "Input"], Cell[10282, 427, 121, 3, 25, "Text"], Cell[10406, 432, 236, 8, 38, "Input"], Cell[10645, 442, 110, 3, 25, "Text"], Cell[10758, 447, 280, 9, 38, "Input"], Cell[11041, 458, 157, 5, 38, "Input"], Cell[11201, 465, 130, 3, 25, "Text"], Cell[11334, 470, 61, 1, 38, "Input"], Cell[11398, 473, 39, 0, 44, "Subsubsection"], Cell[11440, 475, 983, 27, 61, "Text"], Cell[12426, 504, 420, 13, 43, "Text"] } ] *) (* End of internal cache information *)