(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' 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[ 6943, 216]*) (*NotebookOutlinePosition[ 7646, 240]*) (* CellTagsIndexPosition[ 7602, 236]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Inner Products", "Title"], Cell[TextData[{ "Example 2.1 (Page 5)\nDr. Van Fleet\n\nCommands Used (Linked to Help \ Browser): \n\t", ButtonBox["MatrixForm", ButtonStyle->"MainBookLink"], "\n\t", ButtonBox["Transpose", ButtonStyle->"MainBookLink"], "\n\t", ButtonBox["Dot(.)", ButtonStyle->"MainBookLink"], "\n\t", ButtonBox["Clear", ButtonStyle->"MainBookLink"], "\n\t", ButtonBox["Table", ButtonStyle->"MainBookLink"] }], "Subtitle"], Cell[TextData[{ "Defining Vectors in ", StyleBox["Mathematica", FontSlant->"Italic"], " " }], "Subsubtitle"], Cell[TextData[{ "We will compute the following inner products using ", StyleBox["Mathematica", FontSlant->"Italic"], ". First, we will define two vectors. We will call these vectors ", StyleBox["v", FontWeight->"Bold"], " and ", StyleBox["w", FontWeight->"Bold"], ". ", "Creating vectors in ", StyleBox["Mathematica", FontSlant->"Italic"], " ", "is quite simple. A vector in ", StyleBox["Mathematica", FontSlant->"Italic"], " is a ", "list", ". Elements of a list are separated by commas and enclosed with curly \ brackets, i.e., {}. ", "These curly brackets define a list, which is essentially a column of a \ matrix. To represent a row, you must create a list of lists by using two \ sets of curly brackets. This will be portrayed more clearly when we use \ matrices in later examples. " }], "Text"], Cell[TextData[StyleBox["Remember: the two vectors you want to dot must be the \ same length!", FontWeight->"Bold", FontSlant->"Italic"]], "SmallText"], Cell[BoxData[{ \(\(v = {1, 4, \(-1\)};\)\), "\[IndentingNewLine]", \(\(w = {3, 2, \(-2\)};\)\)}], "Input"], Cell[TextData[{ "To check that you have correctly defined the two vectors, you can simply \ type ", StyleBox["v", FontWeight->"Bold"], " in the input cell. If you want to display the vector in our regular \ vector format, you can type the following after the vector: ", StyleBox["//MatrixForm.", FontWeight->"Bold"], " You can see this by executing the cell below. " }], "Text"], Cell[BoxData[{ \(v\), "\[IndentingNewLine]", \(v // MatrixForm\)}], "Input"], Cell[TextData[{ "To take the inner product of vectors in ", StyleBox["Mathematica", FontSlant->"Italic"], ", you must use a period. If you use a regular multiplication sign, i.e., \ *, the two vectors will be multiplied. \n\nv.w = Tramspose[v] * w\n\nThis \ will be demonstrated with the two vectors ", StyleBox["v", FontWeight->"Bold"], " and ", StyleBox["w", FontWeight->"Bold"], " in the cell below. To make sure that ", StyleBox["Mathematica", FontSlant->"Italic"], " is producing the correct answer, check by hand." }], "Text"], Cell[BoxData[ \(v . w\)], "Input"], Cell[TextData[{ "Let's try another example with v={-1,3} and w={6,2}. You can simply \ redefine ", StyleBox["v", FontWeight->"Bold"], " and ", StyleBox["w", FontWeight->"Bold"], " without having to worry what the two vectors were defined previously in \ the notebook. Although, you can use the ", StyleBox["Clear", FontWeight->"Bold"], " command, which will erase any previous definitions of any variables as \ long as you specify their names separated by commas. Compute the inner \ product with the new vectors in the cell below." }], "Text"], Cell[BoxData[{ \(\(Clear[v, w];\)\), "\[IndentingNewLine]", \(v = \[IndentingNewLine]\(\(w\)\(=\)\)\)}], "Input"], Cell[CellGroupData[{ Cell["Further Exploration", "Section"], Cell[TextData[{ "A really useful tool for creating lists is the ", StyleBox["Table", FontWeight->"Bold"], " command. A Table command is a function, so its contents are enclosed \ with [ ]. For most of our purposes, the command takes two arguments. These \ arguments are separated by commas. The first is a function of the index \ variable, and the second is a list that gives the range of the index \ variable. This list can take many different forms. Execute the cell below \ to see some examples:" }], "Text"], Cell[BoxData[{ \(v = Table[2*k, {k, 1, 6}]\), "\[IndentingNewLine]", \(\(\(w = Table[k, {k, 2, 12, 2}]\)\(\[IndentingNewLine]\) \)\), "\[IndentingNewLine]", \(\(n = 20;\)\), "\[IndentingNewLine]", \(\(f[m_] := Sin[2*Pi*m/n];\)\), "\[IndentingNewLine]", \(\(\(x = Table[f[m], {m, 1, n}]\)\(\[IndentingNewLine]\) \)\), "\[IndentingNewLine]", \(z = Table[{k, k^2}, {k, 1, 5}]\)}], "Input"], Cell["\<\ To review what occured in the previous cell, the first vector v is a simply \ table of the first six even positive integers. We can generate exactly the \ same list, if we change the range on the index variable. For w, we started \ at 2 and stopped at 12, but stepped by intervals of 2. The next example showed how you can define a function (in this case the sine \ curve) and build a list of samples of the function. Finally, the last \ example shows that you can even generate a list of order pairs. We can also \ think of z as a 2 x 5 matrix.\ \>", "Text"] }, Open ]] }, Open ]] }, FrontEndVersion->"5.2 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 929}}, WindowSize->{1272, 902}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, Magnification->1, StyleDefinitions -> "stylesheetJOSH.nb" ] (******************************************************************* 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[1776, 53, 31, 0, 94, "Title"], Cell[1810, 55, 446, 17, 292, "Subtitle"], Cell[2259, 74, 118, 5, 40, "Subsubtitle"], Cell[2380, 81, 861, 26, 74, "Text"], Cell[3244, 109, 154, 3, 31, "SmallText"], Cell[3401, 114, 115, 2, 66, "Input"], Cell[3519, 118, 399, 10, 54, "Text"], Cell[3921, 130, 85, 2, 66, "Input"], Cell[4009, 134, 568, 16, 114, "Text"], Cell[4580, 152, 38, 1, 46, "Input"], Cell[4621, 155, 573, 15, 74, "Text"], Cell[5197, 172, 122, 2, 86, "Input"], Cell[CellGroupData[{ Cell[5344, 178, 38, 0, 70, "Section"], Cell[5385, 180, 527, 10, 70, "Text"], Cell[5915, 192, 423, 8, 70, "Input"], Cell[6341, 202, 574, 10, 70, "Text"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)