(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.1' 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[ 8573, 263]*) (*NotebookOutlinePosition[ 9238, 286]*) (* CellTagsIndexPosition[ 9194, 282]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Row Reduction and Arithmetic", "Title"], Cell["February 15, 2006", "Subtitle"], Cell[CellGroupData[{ Cell["Some Special Matrices", "Subsubtitle"], Cell[TextData[{ StyleBox["Mathematica", FontSlant->"Italic"], " has built-in commands for some common matrices. Play with (that means \ change the arguments and see how the ouput changes) the following commands \ until you understand how they work. They will save you some typing." }], "Text"], Cell[BoxData[ \(MatrixForm[IdentityMatrix[5]]\)], "Input"], Cell[BoxData[ \(MatrixForm[DiagonalMatrix[{1.0, 2.2, \(-1.1\)}]]\)], "Input"], Cell[BoxData[ \(MatrixForm[Table[Random[], {i, 5}, {j, 7}]]\)], "Input"], Cell[TextData[{ "The command \"Random[]\" produces a random number between 0 and 1. Use ", StyleBox["Mathematica", FontSlant->"Italic"], "'s help system to find the command \"Random\", and look at the examples \ given there. Now produce a matrix with 3 rows and 5 columns whose entries are \ random real numbers between 1.1 and 22." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Row Reduction", "Subsubtitle"], Cell[TextData[{ "The command \"Timing[ whatever; ]\" tells you how long it took ", StyleBox["Mathematica", FontSlant->"Italic"], " to evaluate \"whatever\". For example:" }], "Text"], Cell[BoxData[ \(Timing[\(\[Sum]\+\(i = 1\)\%1000000 i\^3;\)]\)], "Input"], Cell[TextData[{ "On my laptop the output of this is \"{11.897 Second,Null}\". This tells us \ that it takes ", StyleBox["Mathematica", FontSlant->"Italic"], " about 12 seconds to compute the sum of the cubes of the first million \ natural numbers, and the \"Null\" happened because of the semicolon (remove \ the semicolon and rerun if that didn't make sense)." }], "Text"], Cell[TextData[{ "How long does it take ", StyleBox["Mathematica", FontSlant->"Italic"], " to find the reduced row echelon form of a 5\[Cross]7 matrix, with random \ real entries between 0 and 1? The command to get the reduced row echelon form \ is \"RowReduce[ matrix ]\"." }], "Text"], Cell["How long did it take for you to type in that command?", "Text"], Cell[TextData[{ "How big does the matrix have to be before it takes ", StyleBox["Mathematica", FontSlant->"Italic"], " 10 seconds to find the reduced row echelon form? How big does it have to \ be before it takes 100 seconds?" }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Arithmetic", "Subsubtitle"], Cell["Here's how to add matrices, and some other things.", "Text"], Cell[BoxData[{ \(MatrixForm[ A = Table[ Random[Integer, {1, 5}], {i, 3}, {j, 5}]]\), "\[IndentingNewLine]", \(MatrixForm[ B = Table[ Random[Integer, {1, 5}], {i, 3}, {j, 5}]]\), "\[IndentingNewLine]", \(MatrixForm[A + B]\), "\[IndentingNewLine]", \(MatrixForm[\(1\/3\) A]\), "\[IndentingNewLine]", \(MatrixForm[Transpose[A]]\)}], "Input"], Cell["Multiplying matrices is trickier.", "Text"], Cell[BoxData[{ \(MatrixForm[ M1 = Table[ Random[Integer, {\(-10\), 10}], {i, 3}, {j, 3}]]\), "\[IndentingNewLine]", \(MatrixForm[ M2 = Table[ Random[Integer, {\(-10\), 10}], {i, 3}, {j, 3}]]\), "\[IndentingNewLine]", \(MatrixForm[M1 . M2]\)}], "Input"], Cell[TextData[{ "That's a period between the two matrices. ", StyleBox["Mathematica", FontSlant->"Italic"], " will not let you use \"C\", \"D\", or \"N\" as variables because they are \ commands (\"N\" converts an expression to a decimal, \"D\" takes a \ derivative, \"C\" is an integration constant). What happens if you try to \ multiply two matrices with incompatible shapes?" }], "Text"], Cell["We also learned about the inverse of a square matrix.", "Text"], Cell[BoxData[{ \(MatrixForm[ A = Table[ Random[Integer, {\(-5\), 5}], {i, 3}, {j, 3}]]\), "\[IndentingNewLine]", \(MatrixForm[B = Inverse[A]]\), "\[IndentingNewLine]", \(MatrixForm[A . B]\), "\[IndentingNewLine]", \(MatrixForm[B . A]\), "\[IndentingNewLine]", \(\)}], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Challenge Problem", "Subsubtitle"], Cell["\<\ Let's start by taking a 3\[Cross]5 matrix, and then think about how Gaussian \ Elimination works.\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"A", "=", TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"0", "3", "5", \(-1\), "4"}, {\(-1\), "0", \(-1\), "1", "3"}, {"2", "1", \(-1\), "0", "3"} }, RowSpacings->1, ColumnSpacings->1, ColumnAlignments->{Left}], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]]}], ";"}]], "Input"], Cell["\<\ The first step is to interchange the top two rows. Find a 3\[Cross]3 matrix \ R1 so that R1.A is just like A, but with the first two rows exchanged.\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"R1", "=", RowBox[{"(", GridBox[{ {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"}, {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"}, {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"} }], ")"}]}], ";"}], "\[IndentingNewLine]", \(MatrixForm[ R1 . A]\)}], "Input"], Cell["\<\ Now you need to multiply the first row by -1. Find a 3\[Cross]3 matrix R2 so \ that R2.(R1.A) is just like R1.A, but with the first row multiplied by -1.\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"R2", "=", RowBox[{"(", GridBox[{ {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"}, {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"}, {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"} }], ")"}]}], ";"}], "\[IndentingNewLine]", \(MatrixForm[ R2 . \((R1 . A)\)]\)}], "Input"], Cell["\<\ The next step is to replace the third row with (third row-2*first row). Find \ a 3\[Times]3 matrix R3 so that R3.(R2.(R1.A)) is just like (R2.(R1.A)), but \ with the third row replaced by (third row-2*first row).\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"R3", "=", RowBox[{"(", GridBox[{ {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"}, {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"}, {"\[Placeholder]", "\[Placeholder]", "\[Placeholder]"} }], ")"}]}], ";"}], "\[IndentingNewLine]", \(MatrixForm[ R3 . \((R2 . \((R1 . A)\))\)]\)}], "Input"], Cell["Do the parentheses matter?", "Text"], Cell["Can you complete the Gaussian elimination like this?", "Text"] }, Open ]] }, Open ]] }, FrontEndVersion->"5.1 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 685}}, CellGrouping->Manual, WindowSize->{781, 527}, WindowMargins->{{0, Automatic}, {Automatic, 0}} ] (******************************************************************* 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, 45, 0, 95, "Title"], Cell[1824, 55, 37, 0, 51, "Subtitle"], Cell[CellGroupData[{ Cell[1886, 59, 44, 0, 30, "Subsubtitle"], Cell[1933, 61, 301, 6, 52, "Text"], Cell[2237, 69, 62, 1, 30, "Input"], Cell[2302, 72, 81, 1, 27, "Input"], Cell[2386, 75, 76, 1, 27, "Input"], Cell[2465, 78, 354, 7, 71, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[2856, 90, 36, 0, 32, "Subsubtitle"], Cell[2895, 92, 192, 5, 33, "Text"], Cell[3090, 99, 77, 1, 51, "Input"], Cell[3170, 102, 383, 8, 71, "Text"], Cell[3556, 112, 295, 7, 52, "Text"], Cell[3854, 121, 69, 0, 33, "Text"], Cell[3926, 123, 248, 6, 52, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4211, 134, 33, 0, 32, "Subsubtitle"], Cell[4247, 136, 66, 0, 33, "Text"], Cell[4316, 138, 420, 11, 124, "Input"], Cell[4739, 151, 49, 0, 30, "Text"], Cell[4791, 153, 324, 9, 70, "Input"], Cell[5118, 164, 401, 8, 68, "Text"], Cell[5522, 174, 69, 0, 33, "Text"], Cell[5594, 176, 329, 8, 110, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[5960, 189, 40, 0, 32, "Subsubtitle"], Cell[6003, 191, 121, 3, 33, "Text"], Cell[6127, 196, 489, 13, 57, "Input"], Cell[6619, 211, 172, 3, 33, "Text"], Cell[6794, 216, 392, 8, 80, "Input"], Cell[7189, 226, 177, 3, 52, "Text"], Cell[7369, 231, 403, 8, 80, "Input"], Cell[7775, 241, 237, 4, 52, "Text"], Cell[8015, 247, 414, 8, 80, "Input"], Cell[8432, 257, 42, 0, 33, "Text"], Cell[8477, 259, 68, 0, 33, "Text"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)