(************** 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[ 7098, 280]*) (*NotebookOutlinePosition[ 7744, 302]*) (* CellTagsIndexPosition[ 7700, 298]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData[{ "Working with matrices in ", StyleBox["Mathematica", FontSlant->"Italic"] }], "Subtitle"], Cell[CellGroupData[{ Cell["\<\ Created by Professor Caleb Shor at Bates College for Math 205, Linear \ Algebra, Winter 2006. Feel free to use this and modify as appropriate.\ \>", "Subsubsection"], Cell[TextData[{ "This document (called a \"notebook\" in ", StyleBox["Mathematica", FontSlant->"Italic"], " lingo) will serve as a brief introduction to working with matrices in ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"], Cell[TextData[{ "We can use ", StyleBox["Mathematica", FontSlant->"Italic"], " just like a calculator. To execute a command, hold down shift and press \ enter. (If you just press enter, ", StyleBox["Mathematica", FontSlant->"Italic"], " thinks that you are typing a command that requires more than one line..)" }], "Text"], Cell[BoxData[ \(3\)], "Input"], Cell[BoxData[ \(3 + 4\)], "Input"], Cell[BoxData[ \(5^4\)], "Input"], Cell[BoxData[ \(6 - \((5*4)\) + 3\)], "Input"], Cell[TextData[{ StyleBox["(Mathematica", FontSlant->"Italic"], " keeps track of inputs and outputs so that we can refer back to a \ calculation if we want.) The command '%' gives the previous output, and '%n' \ gives output number n." }], "Text"], Cell[BoxData[ \(%\)], "Input"], Cell[BoxData[ \(%1 + %2\)], "Input"], Cell["We can create variables and assign values to them", "Text"], Cell[BoxData[ \(x = 5\)], "Input"], Cell[BoxData[ \(x + 19\)], "Input"], Cell[BoxData[ \(x^200\)], "Input"], Cell["\<\ Lists are made with curly brackets. We can think of a vector as a list..\ \>", "Text"], Cell[BoxData[ \(u = {1, 2}\)], "Input"], Cell[BoxData[ \(v = {1, 3}\)], "Input"], Cell[BoxData[ \(u + v\)], "Input"], Cell["\<\ ...and think of a matrix as a list of lists, where each list corresponds to a \ row of the matrix.\ \>", "Text"], Cell[BoxData[ \(A = {{1, 2}, {3, 4}}\)], "Input"], Cell[BoxData[ \(M = {{1, 4}, {5, \(-1\)}}\)], "Input"], Cell[BoxData[ \(A + M\)], "Input"], Cell["\<\ For displaying purposes, we have the command MatrixForm, which allows us to \ see our vectors and matrices more easily. (Arguments for commands go inside \ square brackets.)\ \>", "Text"], Cell[BoxData[ \(MatrixForm[u]\)], "Input"], Cell[BoxData[ \(MatrixForm[A]\)], "Input"], Cell["\<\ We use period \".\" to multiply a matrix with a matrix or a matrix with a \ vector.\ \>", "Text"], Cell[BoxData[ \(A . u\)], "Input"], Cell[BoxData[ \(A . M\)], "Input"], Cell["\<\ If we want to use the last output in a calculation, we \"%\". To use a \ particular output, try \"%n\", where n is the output number.\ \>", "Text"], Cell[BoxData[ \(MatrixForm[%]\)], "Input"], Cell["\<\ To raise a matrix to a power, we have a special command. Notice that \"A^2\" \ doesn't give you the same thing as \"A.A\"..\ \>", "Text"], Cell[BoxData[ \(A^2\)], "Input"], Cell[BoxData[ \(A . A\)], "Input"], Cell["\<\ A^2 has the effect of squaring each entry in the matrix, which isn't what we \ want. To raise a matrix A to a power n, we can use the command \ MatrixPower[A,n].\ \>", "Text"], Cell[BoxData[ \(MatrixPower[A, 2]\)], "Input"], Cell[BoxData[ \(MatrixPower[M, 3]\)], "Input"], Cell[TextData[{ "We can use ", StyleBox["Mathematica", FontSlant->"Italic"], " to calculate determinants." }], "Text"], Cell[BoxData[ \(MatrixForm[A]\)], "Input"], Cell[BoxData[ \(Det[A]\)], "Input"], Cell[TextData[{ "Since the determinant of A is non-zero, it is invertible. We can make an \ augmented matrix with the identity matrix and row reduce [A I] to get [I B], \ where B is the inverse of A. (To do this, we need to load a special package \ for ", StyleBox["Mathematica", FontSlant->"Italic"], ".)" }], "Text"], Cell[BoxData[ \(<< LinearAlgebra`MatrixManipulation`\)], "Input"], Cell[BoxData[ \(AUG = AppendRows[A, IdentityMatrix[2]]\)], "Input"], Cell[BoxData[ \(RowReduce[AUG]\)], "Input"], Cell[BoxData[ \(MatrixForm[%]\)], "Input"], Cell[TextData[{ "Or we could have just asked ", StyleBox["Mathematica", FontSlant->"Italic"], " for the inverse to begin with.." }], "Text"], Cell[BoxData[ \(MatrixForm[Inverse[A]]\)], "Input"], Cell[TextData[{ "There are many more things that ", StyleBox["Mathematica", FontSlant->"Italic"], " can do. For help with specific commands, check the help browser, which \ is under the Help menu." }], "Text"], Cell[TextData[{ "One thing to note is that ", StyleBox["Mathematica", FontSlant->"Italic"], " will keep track of all variables that have been assigned unless you \ \"quit the kernel\", which you can do in the Kernel menu. (When you quit ", StyleBox["Mathematica", FontSlant->"Italic"], ", you automatically quit the kernel.) This is something to beware of if \ you are working with multiple ", StyleBox["Mathematica", FontSlant->"Italic"], " notebooks at the same time.." }], "Text"] }, Open ]], Cell["\<\ Your first homework assignment, due on Friday, February 17, is available on \ our course webpage. (http://www.bates.edu/~cshor/winter2006/ma205)\ \>", "Subsubsection"] }, Open ]] }, FrontEndVersion->"5.1 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 685}}, WindowSize->{495, 527}, WindowMargins->{{125, Automatic}, {Automatic, 34}} ] (******************************************************************* 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, 113, 4, 52, "Subtitle"], Cell[CellGroupData[{ Cell[1914, 61, 176, 3, 46, "Subsubsection"], Cell[2093, 66, 260, 8, 52, "Text"], Cell[2356, 76, 342, 9, 71, "Text"], Cell[2701, 87, 34, 1, 30, "Input"], Cell[2738, 90, 38, 1, 30, "Input"], Cell[2779, 93, 36, 1, 30, "Input"], Cell[2818, 96, 50, 1, 30, "Input"], Cell[2871, 99, 255, 6, 71, "Text"], Cell[3129, 107, 34, 1, 30, "Input"], Cell[3166, 110, 40, 1, 30, "Input"], Cell[3209, 113, 65, 0, 33, "Text"], Cell[3277, 115, 38, 1, 30, "Input"], Cell[3318, 118, 39, 1, 30, "Input"], Cell[3360, 121, 38, 1, 30, "Input"], Cell[3401, 124, 97, 2, 33, "Text"], Cell[3501, 128, 43, 1, 30, "Input"], Cell[3547, 131, 43, 1, 30, "Input"], Cell[3593, 134, 38, 1, 30, "Input"], Cell[3634, 137, 122, 3, 52, "Text"], Cell[3759, 142, 53, 1, 30, "Input"], Cell[3815, 145, 58, 1, 30, "Input"], Cell[3876, 148, 38, 1, 30, "Input"], Cell[3917, 151, 198, 4, 71, "Text"], Cell[4118, 157, 46, 1, 30, "Input"], Cell[4167, 160, 46, 1, 30, "Input"], Cell[4216, 163, 107, 3, 33, "Text"], Cell[4326, 168, 38, 1, 30, "Input"], Cell[4367, 171, 38, 1, 30, "Input"], Cell[4408, 174, 158, 3, 52, "Text"], Cell[4569, 179, 46, 1, 30, "Input"], Cell[4618, 182, 148, 3, 52, "Text"], Cell[4769, 187, 36, 1, 30, "Input"], Cell[4808, 190, 38, 1, 30, "Input"], Cell[4849, 193, 186, 4, 71, "Text"], Cell[5038, 199, 50, 1, 30, "Input"], Cell[5091, 202, 50, 1, 30, "Input"], Cell[5144, 205, 128, 5, 33, "Text"], Cell[5275, 212, 46, 1, 30, "Input"], Cell[5324, 215, 39, 1, 30, "Input"], Cell[5366, 218, 330, 8, 90, "Text"], Cell[5699, 228, 69, 1, 30, "Input"], Cell[5771, 231, 71, 1, 30, "Input"], Cell[5845, 234, 47, 1, 30, "Input"], Cell[5895, 237, 46, 1, 30, "Input"], Cell[5944, 240, 150, 5, 33, "Text"], Cell[6097, 247, 55, 1, 30, "Input"], Cell[6155, 250, 220, 6, 52, "Text"], Cell[6378, 258, 511, 13, 109, "Text"] }, Open ]], Cell[6904, 274, 178, 3, 46, "Subsubsection"] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)