(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 7.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 11890, 393] NotebookOptionsPosition[ 8510, 292] NotebookOutlinePosition[ 10354, 349] CellTagsIndexPosition[ 10054, 339] WindowTitle->Lecture 06 MIT 3.016 (Fall 2011) \251 W. Craig Carter \ 2003--2011 WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[TextData[StyleBox["Vectors and Matrices", FontSize->36]], "Title"], Cell[CellGroupData[{ Cell["Matrices", "Subtitle"], Cell[BoxData[ RowBox[{ SubscriptBox["M", "HC"], " ", "is", " ", "our", " ", "matrix", " ", "that", " ", "maps", " ", "the", " ", "three", " ", "hydrocarbons", " ", RowBox[{"(", RowBox[{ RowBox[{"methane", " ", SubscriptBox["CH", RowBox[{"4", " "}]]}], ",", RowBox[{"propane", " ", SubscriptBox["C", "3"], SubscriptBox["H", RowBox[{"8", " "}]]}], ",", RowBox[{"butane", " ", SubscriptBox["C", "4"], SubscriptBox["H", RowBox[{"10", " "}]]}], ",", " ", RowBox[{ "to", " ", "number", " ", "of", " ", "hydrogens", " ", "and", " ", "carbons"}]}]}]}]], "Text", CellChangeTimes->{{3.3975606836188183`*^9, 3.397560804474546*^9}}, FontFamily->"Helvetica", CellTags->"mmtag:06:matrix__example__mapping_molecules_to_elements"], Cell[BoxData[{ RowBox[{ RowBox[{ SubscriptBox["M", "HC"], " ", "=", " ", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"4", ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"8", ",", "3"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"10", ",", "4"}], "}"}]}], "\[IndentingNewLine]", "}"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ SubscriptBox["M", "HC"], "//", "MatrixForm"}]}], "Input", FontFamily->"Helvetica"], Cell[BoxData[ RowBox[{ RowBox[{"Transpose", "[", SubscriptBox["M", "HC"], "]"}], "//", "MatrixForm"}]], "Input"], Cell[BoxData[ RowBox[{"PTmatrix", " ", "is", " ", "our", " ", "matrix", " ", "of", " ", "kinetic", " ", "data", " ", "that", " ", "gives", " ", "rates", " ", "of", " ", "change", " ", "of", " ", "a", " ", "particular", " ", "atomic", " ", "species", " ", RowBox[{"(", RowBox[{"C", " ", "or", " ", "H"}], ")"}], "as", " ", "a", " ", "function", " ", "of", " ", "pressure", " ", "and", " ", "temperature", " ", RowBox[{ RowBox[{"(", RowBox[{ "see", " ", "lecture", " ", "notes", " ", "corresponding", " ", "to", " ", "this", " ", "Mathematica", " ", "notebook"}], ")"}], "."}]}]], "Text", FontFamily->"Helvetica"], Cell[BoxData[{ RowBox[{ RowBox[{"PTmatrix", " ", "=", " ", RowBox[{"{", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"\[Alpha]", ",", "\[Beta]"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"\[Gamma]", ",", "\[Delta]"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"\[Epsilon]", ",", "\[Phi]"}], "}"}]}], "\[IndentingNewLine]", "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"PTmatrix", "//", "MatrixForm"}]}], "Input", FontFamily->"Helvetica", CellTags->"mmtag:06:MatrixForm[]"], Cell[BoxData[ RowBox[{"MPT", " ", "=", " ", RowBox[{ SubscriptBox["M", "HC"], ".", " ", "PTmatrix"}]}]], "Input", FontFamily->"Helvetica"], Cell["\<\ The matrix multiplication above does not work because the sizes are \ inconsistent.\ \>", "Subsection"], Cell[BoxData[ RowBox[{"Clear", "[", "MPT", "]"}]], "Input", FontFamily->"Helvetica"], Cell[BoxData[{ RowBox[{ RowBox[{"MPT", " ", "=", " ", RowBox[{ RowBox[{"Transpose", "[", SubscriptBox["M", "HC"], "]"}], ".", " ", "PTmatrix"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"MPT", "//", "MatrixForm"}]}], "Input", FontFamily->"Helvetica", CellTags->"mmtag:06:Transpose[]"] }, Closed]], Cell[CellGroupData[{ Cell["Matrix Inversions", "Subtitle"], Cell[BoxData[{ RowBox[{ RowBox[{"MPT", " ", "=", " ", RowBox[{ RowBox[{"Transpose", "[", SubscriptBox["M", "HC"], "]"}], ".", " ", "PTmatrix"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"MPTinverse", " ", "=", RowBox[{"Factor", "[", RowBox[{"Inverse", "[", "MPT", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"MPTinverse", "//", "MatrixForm"}]}], "Input", FontFamily->"Helvetica", CellTags->"mmtag:06:Inverse[]"], Cell["\<\ The denominators are related to the determinant---if the determinant \ vanishes, then the inverse matrix is not defined.\ \>", "Text", CellChangeTimes->{{3.397567696587372*^9, 3.397567757703637*^9}}], Cell[BoxData[ RowBox[{"Det", "[", "MPT", "]"}]], "Input", CellChangeTimes->{{3.39756749869079*^9, 3.3975675296961403`*^9}}, FontFamily->"Helvetica", CellTags->"mmtag:06:Det[]"], Cell["\<\ Checking to see if the the inverse multiplied by the original matrix is the \ identity matrix:\ \>", "Text", CellChangeTimes->{{3.397567873168024*^9, 3.397567903015593*^9}}], Cell[BoxData[ RowBox[{"MPT", ".", "MPTinverse"}]], "Input", CellChangeTimes->{{3.397567764654478*^9, 3.397567847480843*^9}}], Cell["It is not obvious unless simplified...", "Text", CellChangeTimes->{{3.39756791126331*^9, 3.3975679324797363`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"Simplify", "[", RowBox[{"MPT", ".", "MPTinverse"}], "]"}], "//", "MatrixForm"}]], "Input", CellChangeTimes->{{3.397567764654478*^9, 3.3975678542483463`*^9}}] }, Closed]], Cell[CellGroupData[{ Cell["Redundant Rows: Rank of a Matrix", "Subtitle"], Cell["\<\ Same example for water and water complexes: use the matrix watmat to store \ molecular formulas for each type of molecule in the system\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"watmat", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "2"}], "}"}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"watmat", "//", "MatrixForm"}]}], "Input", FontFamily->"Helvetica"], Cell["\<\ The vector molvec is used to store the number of each kind of molecule\ \>", "Text"], Cell[BoxData[ RowBox[{"molvec", " ", "=", " ", RowBox[{"{", RowBox[{"h20", ",", "h402"}], "}"}]}]], "Input", FontFamily->"Helvetica"], Cell["\<\ The vector atomvec is used to store the number of each atomic species that is \ present\ \>", "Text"], Cell[BoxData[ RowBox[{"atomvec", " ", "=", " ", RowBox[{"{", RowBox[{"h", ",", "o"}], "}"}]}]], "Input", FontFamily->"Helvetica"], Cell[BoxData[ RowBox[{"atomvec", "//", "MatrixForm"}]], "Input", FontFamily->"Helvetica"], Cell["\<\ The vector eq is now defined and its two elements are equations that give the \ number of hydrogen atoms and the number of oxygen atoms:\ \>", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"eq", "[", "1", "]"}], " ", "=", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"watmat", ".", "molvec"}], ")"}], "[", RowBox[{"[", "1", "]"}], "]"}], " ", "\[Equal]", " ", RowBox[{"atomvec", "[", RowBox[{"[", "1", "]"}], "]"}]}]}]], "Input", FontFamily->"Helvetica"], Cell[BoxData[ RowBox[{ RowBox[{"eq", "[", "2", "]"}], " ", "=", " ", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"watmat", ".", "molvec"}], ")"}], "[", RowBox[{"[", "2", "]"}], "]"}], " ", "\[Equal]", " ", RowBox[{"atomvec", "[", RowBox[{"[", "2", "]"}], "]"}]}]}]], "Input", FontFamily->"Helvetica"], Cell[BoxData[ RowBox[{"Solve", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"eq", "[", "1", "]"}], ",", RowBox[{"eq", "[", "2", "]"}]}], "}"}], ",", "molvec"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"?", "Eliminate"}]], "Input"], Cell[BoxData[ RowBox[{"Eliminate", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"eq", "[", "1", "]"}], ",", RowBox[{"eq", "[", "2", "]"}]}], "}"}], ",", "molvec"}], "]"}]], "Input",\ FontFamily->"Helvetica", CellTags->"mmtag:06:Eliminate[]"], Cell[BoxData[ RowBox[{"MatrixRank", "[", "watmat", "]"}]], "Input"], Cell[BoxData[{ RowBox[{"NullSpace", "[", "watmat", "]"}], "\[IndentingNewLine]", RowBox[{"Length", "[", RowBox[{"NullSpace", "[", "watmat", "]"}], "]"}]}], "Input"] }, Closed]] }, ScreenStyleEnvironment->"Presentation", CellGrouping->Manual, WindowSize->{1273, 695}, WindowMargins->{{110, Automatic}, {Automatic, 87}}, WindowTitle->"Lecture 06 MIT 3.016 (Fall 2011) \[Copyright] W. Craig Carter \ 2003--2011", PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrintingOptions->{"PaperOrientation"->"Portrait", "PrintCellBrackets"->False, "PrintMultipleHorizontalPages"->False, "PrintRegistrationMarks"->False, "PrintingMargins"->{{54, 54}, {72, 72}}}, ShowSelection->True, ShowCellLabel->False, CellLabelAutoDelete->True, FrontEndVersion->"8.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (November 6, \ 2010)", StyleDefinitions->FrontEnd`FileName[{"Creative"}, "NaturalColor.nb", CharacterEncoding -> "UTF-8"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "mmtag:06:matrix__example__mapping_molecules_to_elements"->{ Cell[754, 29, 811, 22, 75, "Text", CellTags->"mmtag:06:matrix__example__mapping_molecules_to_elements"]}, "mmtag:06:MatrixForm[]"->{ Cell[2894, 90, 577, 15, 184, "Input", CellTags->"mmtag:06:MatrixForm[]"]}, "mmtag:06:Transpose[]"->{ Cell[3830, 122, 308, 9, 84, "Input", CellTags->"mmtag:06:Transpose[]"]}, "mmtag:06:Inverse[]"->{ Cell[4215, 138, 470, 14, 109, "Input", CellTags->"mmtag:06:Inverse[]"]}, "mmtag:06:Det[]"->{ Cell[4901, 160, 180, 4, 58, "Input", CellTags->"mmtag:06:Det[]"]}, "mmtag:06:Eliminate[]"->{ Cell[7984, 272, 266, 9, 58, "Input", CellTags->"mmtag:06:Eliminate[]"]} } *) (*CellTagsIndex CellTagsIndex->{ {"mmtag:06:matrix__example__mapping_molecules_to_elements", 9406, 318}, {"mmtag:06:MatrixForm[]", 9545, 321}, {"mmtag:06:Transpose[]", 9652, 324}, {"mmtag:06:Inverse[]", 9755, 327}, {"mmtag:06:Det[]", 9854, 330}, {"mmtag:06:Eliminate[]", 9953, 333} } *) (*NotebookFileOutline Notebook[{ Cell[626, 22, 72, 1, 81, "Title"], Cell[CellGroupData[{ Cell[723, 27, 28, 0, 39, "Subtitle"], Cell[754, 29, 811, 22, 75, "Text", CellTags->"mmtag:06:matrix__example__mapping_molecules_to_elements"], Cell[1568, 53, 544, 15, 209, "Input"], Cell[2115, 70, 119, 3, 58, "Input"], Cell[2237, 75, 654, 13, 75, "Text"], Cell[2894, 90, 577, 15, 184, "Input", CellTags->"mmtag:06:MatrixForm[]"], Cell[3474, 107, 148, 4, 58, "Input"], Cell[3625, 113, 113, 3, 58, "Subsection"], Cell[3741, 118, 86, 2, 52, "Input"], Cell[3830, 122, 308, 9, 84, "Input", CellTags->"mmtag:06:Transpose[]"] }, Closed]], Cell[CellGroupData[{ Cell[4175, 136, 37, 0, 39, "Subtitle"], Cell[4215, 138, 470, 14, 109, "Input", CellTags->"mmtag:06:Inverse[]"], Cell[4688, 154, 210, 4, 73, "Text"], Cell[4901, 160, 180, 4, 58, "Input", CellTags->"mmtag:06:Det[]"], Cell[5084, 166, 184, 4, 44, "Text"], Cell[5271, 172, 126, 2, 58, "Input"], Cell[5400, 176, 121, 1, 44, "Text"], Cell[5524, 179, 197, 4, 58, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[5758, 188, 52, 0, 39, "Subtitle"], Cell[5813, 190, 159, 3, 73, "Text"], Cell[5975, 195, 330, 10, 84, "Input"], Cell[6308, 207, 94, 2, 44, "Text"], Cell[6405, 211, 142, 4, 58, "Input"], Cell[6550, 217, 111, 3, 44, "Text"], Cell[6664, 222, 138, 4, 58, "Input"], Cell[6805, 228, 91, 2, 58, "Input"], Cell[6899, 232, 160, 3, 73, "Text"], Cell[7062, 237, 329, 10, 58, "Input"], Cell[7394, 249, 330, 10, 58, "Input"], Cell[7727, 261, 199, 6, 58, "Input"], Cell[7929, 269, 52, 1, 58, "Input"], Cell[7984, 272, 266, 9, 58, "Input", CellTags->"mmtag:06:Eliminate[]"], Cell[8253, 283, 68, 1, 58, "Input"], Cell[8324, 286, 170, 3, 84, "Input"] }, Closed]] } ] *) (* End of internal cache information *)