(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. 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[ 4481, 146]*) (*NotebookOutlinePosition[ 5121, 169]*) (* CellTagsIndexPosition[ 5077, 165]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Mathematica and Matrices", "Subsection"], Cell["\<\ This short demo is inteded to show you a bit about how to define and manipulate matrices using Mathematica. It is nowhere near comprehensive, but as always, you have the supplement to the textbook and the Mathematica help features to tell you more.\ \>", "Text"], Cell[BoxData[{ \(Let\ \(a\_n\) denote\ the\ nth\ Fibonacci\ number, \ \(\(Let\)\(\ \)\(v\&\ \[RightVector]\_n\) \(denote\)\(\ \)\(the\)\(\ \)\)\), "\n", \(vector\ \((a\_n, a\_\(n - 1\))\) . \ \ Then\ \ v\&\[RightVector]\_0 = \ \(\((1, 1)\)\(\ \)\(and\)\(\ \)\(\n\)\)\), "\n", \(\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\(v\&\[RightVector]\_\(n + 1\)\)\(\ \)\(=\)\(\ \)\(A\ v\&\[RightVector]\_n\ = \ \(\(...\)\(\ \ \)\(=\)\(A\^\(n + 1\)\ v\&\[RightVector]\_0\)\)\)\(\n\)\)\), "\n", \(where\)}], "Text"], Cell[BoxData[ \(A\ = \ {{1, 1}, {1, 0}}\)], "Input"], Cell["\<\ is a 2\[Times]2 matrix. To display A as a matrix, rather than a \ list of lists, use the \"MatrixForm\" command:\ \>", "Text"], Cell[BoxData[ \(MatrixForm[A]\)], "Input"], Cell["\<\ In order to find a (non-recursive) formula for the nth Fibonacci \ number we diagonalize A. First we find eigenvalues and eigenvectors using these to find the diagonal matrix conjugate to A and the conjugating matrix, respectively.\ \>", "Text"], Cell[BoxData[ \(Eigenvalues[A]\)], "Input"], Cell[BoxData[ \(Diag\ = \ DiagonalMatrix[%]\)], "Input"], Cell[BoxData[ \(T\ = \ Eigenvectors[A]\)], "Input"], Cell["\<\ But we want our eigenvectors to be columns, not rows, of the conjugating matrix:\ \>", "Text"], Cell[BoxData[ \(T\ = \ Transpose[T]\)], "Input"], Cell["\<\ Better. But how do we know that these are in the right order--that \ is, in the same order as the eigenvalues in \"Diag\"?\ \>", "Text"], Cell[BoxData[ \(Eigensystem[A]\)], "Input"], Cell["\<\ gives us the eigenvalues and corresponding eigenvectors together. \ Now we see that things are in order above. At this point we have diagonalized A:\t\t\ \>", "Text"], Cell[BoxData[ \(Simplify[T . Diag . Inverse[T]]\)], "Input"], Cell[BoxData[{ \(To\ compute\ the\ 1000 th\ Fibonacci\ number\ we\ use\ the\ diagonalization\), "\n", \(to\ compute\ \(\(A\^1000\)\(:\)\)\n\t\t\)}], "Text"], Cell[BoxData[ \(Simplify[Expand[T . \((Diag^1000)\) . Inverse[T] . {1, 1}]]\)], "Input"], Cell[BoxData[{ \(The\ first\ entry\ of\ the\ result\ is\ \(a\_1000!\)\ \ Actually, \ Mathematica\ is\), "\n", \(pretty\ good\ at\ handling\ matrix\ powers\ on\ its\ \ \(\(own\)\(:\)\)\)}], "Text"], Cell[BoxData[ \(MatrixPower[A, 1000] . {1, 1}\)], "Input"] }, Open ]] }, FrontEndVersion->"4.0 for X", ScreenRectangle->{{0, 1280}, {0, 1024}}, WindowSize->{1272, 947}, WindowMargins->{{0, Automatic}, {Automatic, 23}} ] (*********************************************************************** 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[1739, 51, 46, 0, 45, "Subsection"], Cell[1788, 53, 273, 5, 86, "Text"], Cell[2064, 60, 556, 10, 115, "Text"], Cell[2623, 72, 57, 1, 27, "Input"], Cell[2683, 75, 137, 4, 50, "Text"], Cell[2823, 81, 46, 1, 27, "Input"], Cell[2872, 84, 258, 6, 86, "Text"], Cell[3133, 92, 47, 1, 27, "Input"], Cell[3183, 95, 61, 1, 27, "Input"], Cell[3247, 98, 56, 1, 27, "Input"], Cell[3306, 101, 105, 3, 50, "Text"], Cell[3414, 106, 53, 1, 27, "Input"], Cell[3470, 109, 147, 4, 50, "Text"], Cell[3620, 115, 47, 1, 27, "Input"], Cell[3670, 118, 179, 5, 68, "Text"], Cell[3852, 125, 64, 1, 27, "Input"], Cell[3919, 128, 173, 3, 63, "Text"], Cell[4095, 133, 92, 1, 27, "Input"], Cell[4190, 136, 210, 4, 45, "Text"], Cell[4403, 142, 62, 1, 27, "Input"] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)