(* 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[ 11793, 390] NotebookOptionsPosition[ 8502, 291] NotebookOutlinePosition[ 10260, 346] CellTagsIndexPosition[ 9960, 336] WindowTitle->Lecture 06 MIT 3.016 (Fall 2009) \251 W. Craig Carter \ 2003--2009 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 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->{1013, 681}, WindowMargins->{{34, Automatic}, {Automatic, 83}}, WindowTitle->"Lecture 06 MIT 3.016 (Fall 2009) \[Copyright] W. Craig Carter \ 2003--2009", 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->"7.0 for Mac OS X x86 (32-bit) (November 11, 2008)", StyleDefinitions->"3016-Carter.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{ "mmtag:06:matrix__example__mapping_molecules_to_elements"->{ Cell[754, 29, 811, 22, 70, "Text", CellTags->"mmtag:06:matrix__example__mapping_molecules_to_elements"]}, "mmtag:06:MatrixForm[]"->{ Cell[2894, 90, 577, 15, 70, "Input", CellTags->"mmtag:06:MatrixForm[]"]}, "mmtag:06:Transpose[]"->{ Cell[3822, 121, 308, 9, 70, "Input", CellTags->"mmtag:06:Transpose[]"]}, "mmtag:06:Inverse[]"->{ Cell[4207, 137, 470, 14, 70, "Input", CellTags->"mmtag:06:Inverse[]"]}, "mmtag:06:Det[]"->{ Cell[4893, 159, 180, 4, 70, "Input", CellTags->"mmtag:06:Det[]"]}, "mmtag:06:Eliminate[]"->{ Cell[7976, 271, 266, 9, 70, "Input", CellTags->"mmtag:06:Eliminate[]"]} } *) (*CellTagsIndex CellTagsIndex->{ {"mmtag:06:matrix__example__mapping_molecules_to_elements", 9314, 315}, {"mmtag:06:MatrixForm[]", 9453, 318}, {"mmtag:06:Transpose[]", 9559, 321}, {"mmtag:06:Inverse[]", 9662, 324}, {"mmtag:06:Det[]", 9760, 327}, {"mmtag:06:Eliminate[]", 9859, 330} } *) (*NotebookFileOutline Notebook[{ Cell[626, 22, 72, 1, 78, "Title"], Cell[CellGroupData[{ Cell[723, 27, 28, 0, 70, "Subtitle"], Cell[754, 29, 811, 22, 70, "Text", CellTags->"mmtag:06:matrix__example__mapping_molecules_to_elements"], Cell[1568, 53, 544, 15, 70, "Input"], Cell[2115, 70, 119, 3, 70, "Input"], Cell[2237, 75, 654, 13, 70, "Text"], Cell[2894, 90, 577, 15, 70, "Input", CellTags->"mmtag:06:MatrixForm[]"], Cell[3474, 107, 148, 4, 70, "Input"], Cell[3625, 113, 105, 2, 70, "Subsection"], Cell[3733, 117, 86, 2, 70, "Input"], Cell[3822, 121, 308, 9, 70, "Input", CellTags->"mmtag:06:Transpose[]"] }, Closed]], Cell[CellGroupData[{ Cell[4167, 135, 37, 0, 56, "Subtitle"], Cell[4207, 137, 470, 14, 70, "Input", CellTags->"mmtag:06:Inverse[]"], Cell[4680, 153, 210, 4, 70, "Text"], Cell[4893, 159, 180, 4, 70, "Input", CellTags->"mmtag:06:Det[]"], Cell[5076, 165, 184, 4, 70, "Text"], Cell[5263, 171, 126, 2, 70, "Input"], Cell[5392, 175, 121, 1, 70, "Text"], Cell[5516, 178, 197, 4, 70, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[5750, 187, 52, 0, 56, "Subtitle"], Cell[5805, 189, 159, 3, 70, "Text"], Cell[5967, 194, 330, 10, 70, "Input"], Cell[6300, 206, 94, 2, 70, "Text"], Cell[6397, 210, 142, 4, 70, "Input"], Cell[6542, 216, 111, 3, 70, "Text"], Cell[6656, 221, 138, 4, 70, "Input"], Cell[6797, 227, 91, 2, 70, "Input"], Cell[6891, 231, 160, 3, 70, "Text"], Cell[7054, 236, 329, 10, 70, "Input"], Cell[7386, 248, 330, 10, 70, "Input"], Cell[7719, 260, 199, 6, 70, "Input"], Cell[7921, 268, 52, 1, 70, "Input"], Cell[7976, 271, 266, 9, 70, "Input", CellTags->"mmtag:06:Eliminate[]"], Cell[8245, 282, 68, 1, 70, "Input"], Cell[8316, 285, 170, 3, 70, "Input"] }, Closed]] } ] *) (* End of internal cache information *)