(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' 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[ 28095, 960]*) (*NotebookOutlinePosition[ 28777, 983]*) (* CellTagsIndexPosition[ 28733, 979]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Working with Lists, Part 2", "Title"], Cell[CellGroupData[{ Cell["Initialization", "Section"], Cell[BoxData[{ \(Clear[vector3D]\), "\[IndentingNewLine]", \(vector3D[a_List] := Module[{vectorLength, cone, arrowLength = .05, arrowWidth = .0125, nFaces = 6, normal, binormal, conePoints}, \[IndentingNewLine] (*\ arrowLength\ is\ percentage\ of\ total\ vector\ length\ to\ be\ \ used\ for\ arrow\ at\ the\ end\ of\ the\ vector\ *) \[IndentingNewLine] (*\ \ \(nFaces\ --\)\ number\ of\ faces\ on\ the\ arrow\ \ *) \[IndentingNewLine]vector3D::"\" = "\"; \[IndentingNewLine]If[ Length[a] =!= 3, \[IndentingNewLine]Message[ vector3D::"\"]; \[IndentingNewLine]Return;\ \[IndentingNewLine]]; \[IndentingNewLine]vectorLength = N[\@\(a . a\)]; \[IndentingNewLine]normal = N[{a[\([2]\)], \(-a[\([1]\)]\), 0}]; \[IndentingNewLine]normal = normal/\@\(normal . normal\); \[IndentingNewLine]binormal = Cross[a, normal]; \[IndentingNewLine]binormal = binormal/\@\(binormal . binormal\); \[IndentingNewLine]conePoints = Table[\((1 - arrowLength)\)*a + arrowWidth*vectorLength*Cos[\[Theta]]\ normal + arrowWidth*vectorLength*Cos[\[Theta]]\ binormal, {\[Theta], 0, 2 \[Pi], 2 \[Pi]/nFaces}]; \[IndentingNewLine]cone = Table[Polygon[{conePoints[\([i]\)], conePoints[\([i + 1]\)], a}], {i, 1, nFaces - 1}]; \[IndentingNewLine]Return[ Graphics3D[{cone, Line[{{0, 0, 0}, a}]}]];\[IndentingNewLine]]\)}], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Lists as vectors", "Section"], Cell[TextData[{ "We saw in the previous session that lists can be treated as arrays in \ computer programming languages or as mathematical sequences. Lists can also \ represent vectors, and we can perform linear algebra operations on them. ", StyleBox["Mathematica", FontSlant->"Italic"], " does not distinguish between row vectors and column vectors. Here are a \ few vectors in ", Cell[BoxData[ \(TraditionalForm\`\[DoubleStruckCapitalR]\^3\)]], "." }], "Text"], Cell[BoxData[{ \(\(a = {2, \(-3\), 5};\)\), "\[IndentingNewLine]", \(\(b = {1, 2, 4};\)\), "\[IndentingNewLine]", \(\(c = {3, 5, 1};\)\)}], "Input"], Cell["We can add two vectors together,", "Text"], Cell[BoxData[ \(a + b\)], "Input"], Cell["We can take a scalar multiple of a vector,", "Text"], Cell[BoxData[ \(10 a\)], "Input"], Cell["and we can take linear combinations of vectors.", "Text"], Cell[BoxData[ \(3 a + 4 b - 2 c\)], "Input"], Cell[TextData[{ "Colors are lists of red, green, and blue components. So, we can take \ linear combinations of them to create new colors. Here is a function that \ goes from red at ", StyleBox["x", FontSlant->"Italic"], " = 0 to green at ", StyleBox["x", FontSlant->"Italic"], " = 1, by taking a linear combination of the ", StyleBox["red", FontSlant->"Italic"], " list and the ", StyleBox["green", FontSlant->"Italic"], " list." }], "Text"], Cell[BoxData[{ \(\(red = {1, 0, 0};\)\), "\[IndentingNewLine]", \(\(green = {0, 1, 0};\)\), "\[IndentingNewLine]", \(colorGradient[x_] = Apply[RGBColor, \((1 - x)\)*red + x*green]\)}], "Input"], Cell[TextData[{ "We will study the ", StyleBox["Apply", FontFamily->"Courier"], " command in a later section. Here is a list of ", StyleBox["x", FontSlant->"Italic"], " values from 0 to 1 and a plot of the colors associated with those values \ of ", StyleBox["x", FontSlant->"Italic"], "." }], "Text"], Cell[BoxData[{ \(gradient = Table[x, {x, 0, 1, .1}]\), "\[IndentingNewLine]", \(\(ListDensityPlot[{gradient, gradient}, ColorFunction \[Rule] colorGradient, Mesh \[Rule] False];\)\)}], "Input"], Cell[TextData[{ "Although colors are awkward to specify in ", StyleBox["Mathematica", FontSlant->"Italic"], ", this example shows how we can use ", StyleBox["Mathematica", FontSlant->"Italic"], "'s power to algorithmically generate colors. If we were forced to select \ colors from menus, we would not be able to create these types of effects. We \ will generalize this example in a later section." }], "Text"], Cell["\<\ We can take the dot product of two vectors by typing a \"period\" \ as the multiplication symbol\ \>", "Text"], Cell[BoxData[ \(a . c\)], "Input"], Cell[TextData[{ "or by using the ", StyleBox["Dot", FontFamily->"Courier"], " command." }], "Text"], Cell[BoxData[ \(Dot[a, c]\)], "Input"], Cell[TextData[{ "You can calculate cross products using the ", StyleBox["Cross", FontFamily->"Courier"], " command." }], "Text"], Cell[BoxData[ \(Cross[a, b]\)], "Input"], Cell[TextData[{ StyleBox["Exercise 10.1:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Use cross products to determine whether or not the four points, (1, 3, \ \[Dash]7), (2, \[Dash]1, 7), and (6, \[Dash]2, 18), and (0, 3, \[Dash]9), are \ coplanar." }], "Text", Background->GrayLevel[0.750011]], Cell[TextData[{ StyleBox["Exercise 10.2:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Create a function, called vectorAngle, that finds the angle between two \ vectors in ", Cell[BoxData[ \(TraditionalForm\`\[DoubleStruckCapitalR]\^2\)]], " or ", Cell[BoxData[ \(TraditionalForm\`\[DoubleStruckCapitalR]\^3\)]], ". Use this function to find the angles of the triangle with the following \ vertices." }], "Text", Background->GrayLevel[0.750011]], Cell[BoxData[{ \(\(a = {2, \(-4\), 1};\)\), "\[IndentingNewLine]", \(\(b = {1, 0, \(-3\)};\)\), "\[IndentingNewLine]", \(\(c = {5, 1, 7};\)\)}], "Input"], Cell[TextData[{ "In ", StyleBox["Mathematica", FontSlant->"Italic"], ", matrices are represented as lists of lists, with each inner list forming \ a row. Here is a 3\[Times]3 matrix." }], "Text"], Cell[BoxData[ \(m = {{3, 2, 0}, {1, 4, 2}, {5, 2, 4}}\)], "Input"], Cell[TextData[{ "You can view it in ", StyleBox["MatrixForm", FontFamily->"Courier"], "." }], "Text"], Cell[BoxData[ \(m // MatrixForm\)], "Input"], Cell["You can take a scalar multiple of a matrix,", "Text"], Cell[BoxData[ \(100 m\)], "Input"], Cell["\<\ you can multiply a matrix by a vector using a \"period\" as the \ multiplicaiton symbol,\ \>", "Text"], Cell[BoxData[ \(m . a\)], "Input"], Cell["and you can multiply two matrices together", "Text"], Cell[BoxData[ \(m . {{2, \(-3\)}, {1, 4}, {3, 8}}\)], "Input"], Cell[TextData[{ "All of the most familiar matrix functions are available, such as ", StyleBox["Inverse", FontFamily->"Courier"], ", ", StyleBox["Transpose", FontFamily->"Courier"], ", ", StyleBox["Eigenvalues", FontFamily->"Courier"], ", ", StyleBox["Eigenvectors", FontFamily->"Courier"], ", ", StyleBox["NullSpace", FontFamily->"Courier"], ", ", StyleBox["LUDecomposition", FontFamily->"Courier"], ", and ", StyleBox["Det.", FontFamily->"Courier"], " Of course, these functions are all useful for linear algebra problems. \ But ", StyleBox["Transpose", FontFamily->"Courier"], " has other uses, too." }], "Text"], Cell[TextData[{ "Suppose we have a list of points, represented as ordered pairs. Here are \ 20 ordered pairs of random integers with the ", StyleBox["x", FontSlant->"Italic"], " coordinates ", "between \[Dash]1000 and 1000 and the ", StyleBox["y", FontSlant->"Italic"], " coordinates between \[Dash]10 and 10." }], "Text"], Cell[BoxData[ \(points = Table[{Random[Integer, {\(-1000\), 1000}], Random[Integer, {\(-10\), 10}]}, {20}]\)], "Input"], Cell[TextData[{ "Suppose that we want to determine the smallest interval containing the ", StyleBox["x", FontSlant->"Italic"], " coordinates and the smallest interval containing the ", StyleBox["y", FontSlant->"Italic"], " coordinates. Look what happens when we take the transpose." }], "Text"], Cell[BoxData[ \(Transpose[points]\)], "Input"], Cell[TextData[{ "Notice that the ", StyleBox["x", FontSlant->"Italic"], " coordinates are grouped into the first list and the ", StyleBox["y", FontSlant->"Italic"], " coordinates are grouped into the second list. This is a handy method for \ extracting all of the first members of lists within lists. If we take the \ first part, we get the ", StyleBox["x", FontSlant->"Italic"], " coordinates." }], "Text"], Cell[BoxData[ \(xCoordinates = \(Transpose[points]\)[\([1]\)]\)], "Input"], Cell[TextData[{ "And if we take the second part, we get the ", StyleBox["y", FontSlant->"Italic"], " coordinates." }], "Text"], Cell[BoxData[ \(yCoordinates = \(Transpose[points]\)[\([2]\)]\)], "Input"], Cell[TextData[{ "Here is the smallest interval containing all of the ", StyleBox["x", FontSlant->"Italic"], " values." }], "Text"], Cell[BoxData[ \({Min[xCoordinates], Max[xCoordinates]}\)], "Input"], Cell[TextData[{ "Here is the smallest interval containing all of the ", StyleBox["y", FontSlant->"Italic"], " values." }], "Text"], Cell[BoxData[ \({Min[yCoordinates], Max[yCoordinates]}\)], "Input"], Cell["\<\ These intervals determine the smallest viewing window containing \ all of the points.\ \>", "Text"], Cell[TextData[{ StyleBox["Exercise 10.3:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Create a function that lists the names of the ", StyleBox["n", FontSlant->"Italic"], " most populous countries. The arguments to the function should be ", StyleBox["n", FontSlant->"Italic"], " and the list of countries and populations as read from the data file \ using the ", StyleBox["Import", FontFamily->"Courier"], " command. You should be able to do this in one line." }], "Text", Background->GrayLevel[0.750011]], Cell[TextData[{ "You can visualize the elements of a matrix using ", StyleBox["ListDensityPlot", FontFamily->"Courier"], ". Here is a matrix that is involved in approximating the solution of the \ equation modeling diffusion processes, ", Cell[BoxData[ \(TraditionalForm\`\[PartialD]u\/\[PartialD]t = \[PartialD]\^2 u\/\ \[PartialD]x\^2\)]], "." }], "Text"], Cell[BoxData[{ \(\(n = 5;\)\), "\[IndentingNewLine]", \(\(diffusion = DiagonalMatrix[Table[4, {n\^2}]];\)\), "\[IndentingNewLine]", \(\(Do[ diffusion[\([i, i + n]\)] = \(-1\), {i, 1, n\^2 - n}];\)\), "\[IndentingNewLine]", \(\(Do[ diffusion[\([i + n, i]\)] = \(-1\), {i, 1, n\^2 - n}];\)\), "\[IndentingNewLine]", \(\(diffusion[\([1, 1]\)] = 2;\)\), "\[IndentingNewLine]", \(\(diffusion[\([n\^2, n\^2]\)] = 2;\)\), "\[IndentingNewLine]", \(diffusion\)}], "Input"], Cell["\<\ Here is a density plot of the matrix elements. The 1,1 entry is at \ the bottom left corner,. You would have to perform a vertical reflection of \ the graph to orient the elements in the usual way, with the 1,1 entry in the \ top left corner.\ \>", "Text"], Cell[BoxData[ \(\(ListDensityPlot[diffusion];\)\)], "Input"], Cell[TextData[{ "It might help to add a legend. This is available in a package called \ ExtendedGraphics, available on Wolfram Research's Web site. You can also \ specify the spectrum of colors that you want to use to represent the values \ of the matrix elements. The most commonly used alternative to the default \ grayscale map is a built-in function called ", StyleBox["Hue", FontFamily->"Courier"], "." }], "Text"], Cell[BoxData[ \(\(ListDensityPlot[diffusion, ColorFunction \[Rule] Hue];\)\)], "Input"], Cell[TextData[{ "You can import photographs into ", StyleBox["Mathematica", FontSlant->"Italic"], " as greyscale or color images and manipulate them as matrices. We will \ see this how to do this in the next section." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Transforming space with matrices", "Section"], Cell["\<\ Matrices can be used to transform shapes in two-dimensional and \ three-dimensional space. Let's look at some of these transformations in two \ dimensions.\ \>", "Text"], Cell[CellGroupData[{ Cell["Expansions and Reflections", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["Let's build a house.", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(\(house = {{0, 0, 1, 1, 0, 1\/2, 1, 1, 3\/4, 3\/4}, {1, 0, 0, 1, 1, 3\/2, 1, 3\/2, 3\/2, 5\/4}};\)\), "\[IndentingNewLine]", \(\(housePlot = ListPlot[Transpose[house], PlotJoined \[Rule] True, AspectRatio \[Rule] Automatic, PlotStyle \[Rule] RGBColor[1, 0, 0]];\)\)}], "Input"], Cell["\<\ The columns of the 2\[Times]10 matrix, house, are the coordinates \ of the vertices in the picture.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["house//MatrixForm", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ We are going to use matrices to transform this image, but first \ let's see how matrices affect individual points.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ If we multiply a 2\[Times]2 matrix by a 2\[Times]1 vector, we get \ another 2\[Times]1 vector. If we think of these 2\[Times]1 vectors as \ coordinates of points in the plane, then the matrix transforms one point in \ the plane into another point in the plane. Let's see what the following \ matrix does to points in the plane.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(\(a = {{2, 0}, {0, 1}};\)\), "\[IndentingNewLine]", \(MatrixForm[a]\)}], "Input"], Cell["Applying this matrix to a general symbolic vector gives", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Clear[v] v = {v1, v2}\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["a.v", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "So the matrix, ", StyleBox["a", FontSlant->"Italic"], ", doubles the ", StyleBox["x", FontSlant->"Italic"], " coordinate. What does this represent graphically?" }], "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["Answer:", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Doubling the x coordinate expands points horizontally away from the \ y-axis by a factor of 2.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Now, let's apply the matrix, ", StyleBox["a", FontSlant->"Italic"], ", to our house. " }], "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(newHouse = a . house\), "\[IndentingNewLine]", \(\(newHousePlot = ListPlot[Transpose[newHouse], PlotJoined \[Rule] True, AspectRatio \[Rule] Automatic, DisplayFunction \[Rule] Identity];\)\), "\[IndentingNewLine]", \(\(Show[housePlot, newHousePlot];\)\)}], "Input"], Cell[TextData[{ StyleBox["Exercise 10.4:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " What matrix would make the original house twice as tall? Verify your \ prediction by applying this matrix to a general symbolic vector and then to \ the house." }], "Text", Background->GrayLevel[0.750011]], Cell[TextData[{ "Apply the matrix ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"0", "1"}, {"1", "0"} }], ")"}], TraditionalForm]]], " to a general symbolic vector. What is its effect? What do you think the \ effect will be on our house? Try it confirm your answer." }], "Text"], Cell[TextData[{ StyleBox["Exercise 10.5:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " What matrix would turn the house upside down, that is, reflect it about \ the ", StyleBox["x", FontSlant->"Italic"], " axis? Apply the matrix transformation to the house to confirm your \ answer." }], "Text", Background->GrayLevel[0.750011]] }, Closed]], Cell[CellGroupData[{ Cell["Rotations", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ " You may recall from analytic geometry that rotating the ", StyleBox["x", FontSlant->"Italic"], ",", StyleBox["y", FontSlant->"Italic"], " axes counterclockwise through an angle \[Theta] will give a new ", StyleBox["r", FontSlant->"Italic"], ",", StyleBox["s", FontSlant->"Italic"], " coordinate system with\n \n r = x cos(\[Theta]) - y \ sin(\[Theta])\n s = x sin(\[Theta]) + y cos(\[Theta])\n \nWe can \ write this in matrix form as" }], "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Clear[\[Theta]] a = {{Cos[\[Theta]],-Sin[\[Theta]]}, {Sin[\[Theta]],Cos[\[Theta]]}}; MatrixForm[a]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Clear[x,y] {r,s} = a.{x,y}\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Let's try rotating our house through an angle of \[Pi]/4.\ \>", \ "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ aNew = a/.{\[Theta] -> \[Pi]/4}; MatrixForm[aNew]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(\(newHouse = aNew . house;\)\), "\[IndentingNewLine]", \(\(newHousePlot = ListPlot[Transpose[newHouse], PlotJoined \[Rule] True, AspectRatio \[Rule] Automatic, DisplayFunction \[Rule] Identity];\)\), "\[IndentingNewLine]", \(\(Show[housePlot, newHousePlot];\)\)}], "Input"], Cell["\<\ Now, just for the fun of it, let's simulate Dorothy traveling to \ the Land of Oz.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(Clear[\[Theta]]\), "\[IndentingNewLine]", \(\(Table[ ListPlot[Transpose[a . newHouse], PlotJoined \[Rule] True, AspectRatio \[Rule] Automatic, PlotRange \[Rule] {{\(-2\), 2}, {\(-2\), 2}}], {\[Theta], 0, 2 \[Pi], \[Pi]\/4}];\)\)}], "Input"], Cell["\<\ The advantage of using linear algebra to send Dorothy to the Land \ of Oz is that we can reverse the process to get her back.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ aInverse = Inverse[a]; MatrixForm[aInverse]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["Let's simplify those denominators.", "Text"], Cell["\<\ aInverse = Simplify[aInverse]; MatrixForm[aInverse]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Notice that this is the same as the matrix, a, with \[Theta] \ replaced by \[Dash]\[Theta].\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ aInverse /.{\[Theta] -> -\[Theta]}; MatrixForm[%]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["a//MatrixForm", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ We have just deduced the profoundly obvious (?) result that if the \ house has been rotated by \[Theta], we can restore it to its original \ position through rotating by \[Dash]\[Theta].\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["This rotation matrix is an example of an orthonormal matrix.", "Text"], Cell[TextData[{ "Definition: A matrix is ", StyleBox["orthonormal", FontWeight->"Bold"], " if its inverse is equal to its transpose (equal to its conjugate \ transpose for complex matrices)." }], "Text"], Cell["Simplify[Inverse[a]] == Transpose[a]", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ This definition is equivalent to the following important properties \ of orthonormal matrices.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ 1) The columns of othonormal matrices are orthonormal; that is, \ their lengths are one and their dot products are zero.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(column1ofa\ = \ \(Transpose[a]\)\_\(\(\[LeftDoubleBracket]\)\(1\)\(\ \[RightDoubleBracket]\)\)\), "\[IndentingNewLine]", \(column2ofa\ = \ \(Transpose[a]\)\_\(\(\[LeftDoubleBracket]\)\(2\)\(\ \[RightDoubleBracket]\)\)\)}], "Input"], Cell["column1ofa.column2ofa", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(Simplify[\@\(column1ofa . column1ofa\)]\), "\[IndentingNewLine]", \(Simplify[\@\(column2ofa . column2ofa\)]\)}], "Input"], Cell[TextData[{ "Matrices whose columns are orthogonal (dot products are zero), but not \ necessarily normal (lengths are one), are called ", StyleBox["orthogonal", FontWeight->"Bold"], " matrices" }], "Text"], Cell["\<\ 2) Orthogonal transformations preserve angles. We observed this \ with the house. When the house was rotated, no angles within the house were \ changed.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["3) Orthonormal transformations preserve angles and lengths.", "Text"], Cell[TextData[{ StyleBox["Exercise 10.6:", FontWeight->"Bold", FontColor->RGBColor[0, 0.500008, 0.250004]], " Determine if each of the matrices, a = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"1", "2"}, {\(-2\), "3"} }], ")"}], TraditionalForm]]], ", b = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"1", "2"}, {\(-2\), "1"} }], ")"}], TraditionalForm]]], ", and c = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {\(3\/5\), \(-\(4\/5\)\)}, {\(4\/5\), \(3\/5\)} }], ")"}], TraditionalForm]]], " is orthonormal, orthogonal, or neither. Apply each transformation to the \ house and comment on its relation to properties 2 and 3." }], "Text", Background->GrayLevel[0.750011]] }, Closed]], Cell[CellGroupData[{ Cell["Eigenvalues and Eigenvectors", "Subsection", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ We can better understand more general matrix transformations by \ examining their eigenvalues and eigenvectors. You should only work through \ this section if you have already had a linear algebra class. Otherwise, it \ won't make much sense to you. There are no exercises to turn in for this \ section, so you can safely skip it, if you have not had linear algebra.\ \>", \ "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["Consider the following example.", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ a = {{4,-1},{-1,4}}; MatrixForm[a]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ We can use the Eigensystem command to get its eigenvalues and \ eigenvectors.\ \>", "Text"], Cell["?Eigensystem", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Here are the eigenvalues and eigenvectors of our matrix, ", StyleBox["a", FontSlant->"Italic"], "." }], "Text"], Cell["Eigensystem[a]", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ So the eigenvalues are 3 and 5, with corresponding eigenvectors \ {1,1} and {-1,1}, respectively.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ These eigenvectors are basis vectors for a new coordinate system in \ which the linear transformation is represented by a diagonal matrix with the \ eigenvalues on the diagonal. The change of basis matrix, q, is the matrix \ whose columns are the eigenvectors of a.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ {eigenvalues,q} = Eigensystem[a]; d = DiagonalMatrix[eigenvalues]; d//MatrixForm q//MatrixForm\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["Then the matrix, a, can be written as", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["Inverse[q].d.q", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["Here is a graph of the new coordinate vectors.", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ ListPlot[{Transpose[q][[1]],{0,0},Transpose[q][[2]]}, \t\t PlotJoined -> True, AspectRatio -> Automatic];\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["Notice also, that q is an orthogonal matrix.", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Transpose[q]//MatrixForm Inverse[q]//MatrixForm\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ We can normalize the eigenvectors by dividing by their \ lengths.\ \>", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ qNormal = Transpose[Map[#/Sqrt[#.#] &,Transpose[q]]]; MatrixForm[qNormal]\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["Now qNormal is an orthonormal matrix.", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["\<\ Transpose[qNormal]//MatrixForm Inverse[qNormal]//MatrixForm\ \>", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell["And we can still decompose the matrix, a, into", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell["Inverse[qNormal].d.qNormal//MatrixForm", "Input", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "So, how will the matrix, a, transform a point in the plane? The \ transformed vector, a.v, can be thought of as being subjected to three \ successive transformations since\n\n ", StyleBox["a.v = Inverse[qNormal].d.qNormal.v", FontFamily->"Courier"], ".\n \n1) qNormal.v will rotate the vector v by -\[Pi]/4 radians. We \ are now in the new eigenvector coordinate system.\n\n2) In the eigenvector \ coordinate system, d will stretch the vector by a factor of 3 in the first \ coordinate direction and a factor of 5 in the second coordinate direction.\n\n\ 3) Inverse[qNormal] will rotate the vector back \[Pi]/4 radians.\n\nLet's \ look at our new house." }], "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[BoxData[{ \(\(newHouse = a . house;\)\), "\[IndentingNewLine]", \(\(newHousePlot = ListPlot[Transpose[newHouse], PlotJoined \[Rule] True, AspectRatio \[Rule] Automatic, DisplayFunction \[Rule] Identity];\)\), "\[IndentingNewLine]", \(\(Show[housePlot, newHousePlot];\)\)}], "Input"], Cell["Wouldn't you hate to be a carpenter for this family!", "Text", ImageRegion->{{0, 1}, {0, 1}}], Cell[TextData[{ "Perform an eigenvalue decomposition of a = ", Cell[BoxData[ FormBox[ RowBox[{"(", GridBox[{ {"1", "4"}, {"4", "1"} }], ")"}], TraditionalForm]]], " and see if you can describe what it will do to the house. Then apply the \ transformation to the house." }], "Text"] }, Open ]] }, Closed]] }, Open ]] }, FrontEndVersion->"5.2 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 951}}, WindowSize->{1045, 846}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, StyleDefinitions -> "PastelColor.nb" ] (******************************************************************* 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, 43, 0, 98, "Title"], Cell[CellGroupData[{ Cell[1844, 57, 33, 0, 51, "Section"], Cell[1880, 59, 1593, 25, 415, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[3510, 89, 35, 0, 35, "Section"], Cell[3548, 91, 486, 11, 50, "Text"], Cell[4037, 104, 162, 3, 78, "Input"], Cell[4202, 109, 48, 0, 29, "Text"], Cell[4253, 111, 38, 1, 38, "Input"], Cell[4294, 114, 58, 0, 29, "Text"], Cell[4355, 116, 38, 1, 38, "Input"], Cell[4396, 119, 63, 0, 29, "Text"], Cell[4462, 121, 51, 1, 38, "Input"], Cell[4516, 124, 477, 16, 50, "Text"], Cell[4996, 142, 214, 4, 78, "Input"], Cell[5213, 148, 328, 12, 29, "Text"], Cell[5544, 162, 221, 4, 58, "Input"], Cell[5768, 168, 430, 10, 50, "Text"], Cell[6201, 180, 120, 3, 29, "Text"], Cell[6324, 185, 38, 1, 38, "Input"], Cell[6365, 188, 109, 5, 29, "Text"], Cell[6477, 195, 42, 1, 38, "Input"], Cell[6522, 198, 138, 5, 29, "Text"], Cell[6663, 205, 44, 1, 38, "Input"], Cell[6710, 208, 332, 8, 35, "Text"], Cell[7045, 218, 503, 14, 35, "Text"], Cell[7551, 234, 167, 3, 78, "Input"], Cell[7721, 239, 206, 6, 29, "Text"], Cell[7930, 247, 70, 1, 38, "Input"], Cell[8003, 250, 111, 5, 29, "Text"], Cell[8117, 257, 48, 1, 38, "Input"], Cell[8168, 260, 59, 0, 29, "Text"], Cell[8230, 262, 39, 1, 38, "Input"], Cell[8272, 265, 112, 3, 29, "Text"], Cell[8387, 270, 38, 1, 38, "Input"], Cell[8428, 273, 58, 0, 29, "Text"], Cell[8489, 275, 66, 1, 38, "Input"], Cell[8558, 278, 682, 27, 50, "Text"], Cell[9243, 307, 343, 10, 50, "Text"], Cell[9589, 319, 141, 3, 38, "Input"], Cell[9733, 324, 313, 8, 29, "Text"], Cell[10049, 334, 50, 1, 38, "Input"], Cell[10102, 337, 435, 13, 50, "Text"], Cell[10540, 352, 78, 1, 38, "Input"], Cell[10621, 355, 136, 5, 29, "Text"], Cell[10760, 362, 78, 1, 38, "Input"], Cell[10841, 365, 140, 5, 29, "Text"], Cell[10984, 372, 71, 1, 38, "Input"], Cell[11058, 375, 140, 5, 29, "Text"], Cell[11201, 382, 71, 1, 38, "Input"], Cell[11275, 385, 109, 3, 29, "Text"], Cell[11387, 390, 569, 16, 56, "Text"], Cell[11959, 408, 378, 10, 33, "Text"], Cell[12340, 420, 544, 12, 162, "Input"], Cell[12887, 434, 268, 5, 50, "Text"], Cell[13158, 441, 64, 1, 38, "Input"], Cell[13225, 444, 432, 9, 50, "Text"], Cell[13660, 455, 91, 1, 38, "Input"], Cell[13754, 458, 240, 6, 29, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[14031, 469, 51, 0, 35, "Section"], Cell[14085, 471, 180, 4, 29, "Text"], Cell[CellGroupData[{ Cell[14290, 479, 81, 1, 39, "Subsection"], Cell[14374, 482, 69, 1, 29, "Text"], Cell[14446, 485, 347, 6, 71, "Input"], Cell[14796, 493, 156, 4, 29, "Text"], Cell[14955, 499, 67, 1, 38, "Input"], Cell[15025, 502, 171, 4, 29, "Text"], Cell[15199, 508, 386, 7, 50, "Text"], Cell[15588, 517, 107, 2, 58, "Input"], Cell[15698, 521, 104, 1, 29, "Text"], Cell[15805, 524, 79, 4, 56, "Input"], Cell[15887, 530, 53, 1, 38, "Input"], Cell[15943, 533, 242, 9, 29, "Text"], Cell[16188, 544, 56, 1, 29, "Text"], Cell[16247, 547, 151, 4, 29, "Text"], Cell[16401, 553, 158, 6, 29, "Text"], Cell[16562, 561, 327, 6, 78, "Input"], Cell[16892, 569, 330, 8, 35, "Text"], Cell[17225, 579, 347, 10, 39, "Text"], Cell[17575, 591, 374, 11, 35, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[17986, 607, 64, 1, 25, "Subsection"], Cell[18053, 610, 553, 17, 134, "Text"], Cell[18609, 629, 156, 5, 74, "Input"], Cell[18768, 636, 84, 4, 56, "Input"], Cell[18855, 642, 116, 4, 29, "Text"], Cell[18974, 648, 107, 4, 56, "Input"], Cell[19084, 654, 335, 6, 78, "Input"], Cell[19422, 662, 139, 4, 29, "Text"], Cell[19564, 668, 308, 6, 69, "Input"], Cell[19875, 676, 182, 4, 29, "Text"], Cell[20060, 682, 101, 4, 56, "Input"], Cell[20164, 688, 50, 0, 29, "Text"], Cell[20217, 690, 109, 4, 56, "Input"], Cell[20329, 696, 148, 4, 29, "Text"], Cell[20480, 702, 107, 4, 56, "Input"], Cell[20590, 708, 63, 1, 38, "Input"], Cell[20656, 711, 243, 5, 29, "Text"], Cell[20902, 718, 76, 0, 29, "Text"], Cell[20981, 720, 213, 6, 29, "Text"], Cell[21197, 728, 86, 1, 38, "Input"], Cell[21286, 731, 151, 4, 29, "Text"], Cell[21440, 737, 179, 4, 29, "Text"], Cell[21622, 743, 259, 4, 60, "Input"], Cell[21884, 749, 71, 1, 38, "Input"], Cell[21958, 752, 147, 2, 64, "Input"], Cell[22108, 756, 219, 6, 29, "Text"], Cell[22330, 764, 213, 5, 29, "Text"], Cell[22546, 771, 75, 0, 29, "Text"], Cell[22624, 773, 881, 28, 84, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[23542, 806, 83, 1, 25, "Subsection"], Cell[23628, 809, 428, 8, 50, "Text"], Cell[24059, 819, 80, 1, 29, "Text"], Cell[24142, 822, 92, 4, 56, "Input"], Cell[24237, 828, 101, 3, 29, "Text"], Cell[24341, 833, 62, 1, 38, "Input"], Cell[24406, 836, 138, 5, 29, "Text"], Cell[24547, 843, 64, 1, 38, "Input"], Cell[24614, 846, 154, 4, 29, "Text"], Cell[24771, 852, 323, 6, 50, "Text"], Cell[25097, 860, 152, 6, 92, "Input"], Cell[25252, 868, 86, 1, 29, "Text"], Cell[25341, 871, 64, 1, 38, "Input"], Cell[25408, 874, 95, 1, 29, "Text"], Cell[25506, 877, 163, 4, 56, "Input"], Cell[25672, 883, 93, 1, 29, "Text"], Cell[25768, 886, 105, 4, 56, "Input"], Cell[25876, 892, 122, 4, 29, "Text"], Cell[26001, 898, 131, 4, 56, "Input"], Cell[26135, 904, 86, 1, 29, "Text"], Cell[26224, 907, 117, 4, 56, "Input"], Cell[26344, 913, 95, 1, 29, "Text"], Cell[26442, 916, 88, 1, 38, "Input"], Cell[26533, 919, 736, 13, 239, "Text"], Cell[27272, 934, 332, 6, 78, "Input"], Cell[27607, 942, 101, 1, 29, "Text"], Cell[27711, 945, 344, 10, 39, "Text"] }, Open ]] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)