(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of 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[ 4705, 149]*) (*NotebookOutlinePosition[ 5383, 173]*) (* CellTagsIndexPosition[ 5339, 169]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Mathematica and Matrices", "Section"], 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[{ \(TextForm \`Let\ \(a\_n\) denote\ the\ nth\ Fibonacci\ number . \ Let\ \(\(v\& \[RightVector] \)\_n\) denote\ the\ vector\ \((a\_n, a\_\(n - 1\))\) . \ \ Then\ \ \(v\& \[RightVector] \)\_0 = \ \((1, 1)\)\ and\ \n\), \(TextForm\`\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(v\& \[RightVector] \)\_\(n + 1\)\ = \ \(A\ \(v\& \[RightVector] \)\_n\ = \ \( ... \ = A\^\(n + 1\)\ \(v\& \[RightVector] \)\_0\)\)\n\), \(TextForm\`where\)}], "Text"], Cell[BoxData[ \(A\ = \ {{1, 1}, {1, 0}}\)], "Input"], Cell[TextData[ "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[TextData[{ "Notice that ", StyleBox["Mathematica", FontSlant->"Italic"], " will interpret this as a 2\[Times]2 matrix with\nrows equal to the \ eigenvectors--how convenient for our purposes.\nBut we want our eigenvectors \ to be columns, not rows, of the \nconjugating 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 (1st pair) and corresponding eigenvectors (the rest) together and in the same order. 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[{ \(TextForm \`To\ compute\ the\ 1000 th\ Fibonacci\ number\ we\ use\ the\ diagonalization\), \(TextForm\`to\ compute\ \(\(A\^1000\) : \)\n\t\t\)}], "Text"], Cell[BoxData[ \(Simplify[Expand[T . \((Diag^1000)\) . Inverse[T] . {1, 1}]]\)], "Input"], Cell[BoxData[{ \(TextForm \`The\ first\ entry\ of\ the\ result\ is\ \(a\_1000!\)\ \ Actually, \ Mathematica\ is\), \(TextForm \`pretty\ good\ at\ handling\ matrix\ powers\ on\ its\ \(own : \)\)}], "Text"], Cell[BoxData[ \(MatrixPower[A, 1000] . {1, 1}\)], "Input"] }, Open ]] }, FrontEndVersion->"X 3.0", ScreenRectangle->{{0, 1280}, {0, 1024}}, ScreenStyleEnvironment->"Presentation", WindowSize->{520, 600}, WindowMargins->{{264, Automatic}, {142, Automatic}} ] (*********************************************************************** 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[1731, 51, 43, 0, 70, "Section"], Cell[1777, 53, 273, 5, 112, "Text"], Cell[2053, 60, 509, 10, 152, "Text"], Cell[2565, 72, 57, 1, 39, "Input"], Cell[2625, 75, 140, 2, 66, "Text"], Cell[2768, 79, 46, 1, 39, "Input"], Cell[2817, 82, 260, 5, 112, "Text"], Cell[3080, 89, 47, 1, 39, "Input"], Cell[3130, 92, 61, 1, 39, "Input"], Cell[3194, 95, 56, 1, 39, "Input"], Cell[3253, 98, 304, 7, 112, "Text"], Cell[3560, 107, 53, 1, 39, "Input"], Cell[3616, 110, 147, 4, 66, "Text"], Cell[3766, 116, 47, 1, 39, "Input"], Cell[3816, 119, 221, 4, 89, "Text"], Cell[4040, 125, 64, 1, 39, "Input"], Cell[4107, 128, 190, 4, 86, "Text"], Cell[4300, 134, 92, 1, 63, "Input"], Cell[4395, 137, 229, 6, 61, "Text"], Cell[4627, 145, 62, 1, 39, "Input"] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)