New version page

MSU PHY 102 - worksheet03

Upgrade to remove ads
Upgrade to remove ads
Unformatted text preview:

Worksheet #3 – PHY102 (Spring 2011)Matrices and linear algebraLast week we did vector operations with lists. This week we introduceyou to matrices: their representation using lists, and some of the matrixoperations that can be done in Mathematica.(This worksheet assumes that you already have some familiarity withwith what a matrix is, and what it means to multiply a matrix by a vector.If this is all new to you, ask the instructor for a brief introduction!)Let us first see how to represent matrices in Mathematica as a list. Type“m={{a,b}, {c,d}}”. Now type “MatrixForm[m]”. Note that all of the Math-ematica operations must be applied to the list form of the matrix (not thematrix form). You can see that you get the matrix m with its elementsa, b, c, d in the usual form. You can think of this matrix as consisting of tworow vectors (a,b) and (c,d). Type “m[[1]]” and ch eck you get the first rowvector (a,b). Now type “m[[1,1]]”; this will give you the 1st element of thefirst vector, namely a (notice that “m[[1]][[1]]” also does the same thing).Likewise, to access the element d, type “m[[2,2]]”. To access the element c,type “m[[2,1]]”. Note that the element i, j in m[[i,j]] corresponds directly tothe subscripts in the mathematical matrix form mi,j—the first index is therow and the second index is the column. As you have done with vectors, youcan perform algebraic operations on matrices. You can multiply a matrixwith a vector. To see this, type “r={x,y}”. In order to take a dot productof the matrix m with this vector r, Type “m.r” (or Dot[m,r]). Now type“Dimensions[m]”. The output (2,2) verifies that the matrix m is a 2 × 2matrix.At times, you need to get the transpose of a matrix, which is obtained byexchanging its off-diagonal elements (in this case the elements c and d). Type“t=Transpose[m]”. Now type “MatrixForm[t]”. You see that the matrix hasdiagonal elements the same but the elements c and d got interchanged withrespect to the original matrix m. In general, that transpose is defined math-1ematically byfMi,j= Mj,i.Often we require the determinant of a matrix, which is a scalar quan-tity constructed from the elements. Type “Det[m]” which will give you thedeterminant of the matrix m. Now type “Det[t]” and verify that the de-terminant is the same for the transposed matrix. A diagonal matrix has alloff-diagonal elements set to zero. Type “DiagonalMatrix[{e,f}]”. Now type“MatrixForm[DiagonalMatrix[{e,f}]]”.The “Inverse” of a matrix is th e matrix which, when multiplied by the orig-inal matrix, produces a unit diagonal matrix (unit matrix, as it is oftencalled). Type “mi=Inverse[m]”. Now take the product “h=m.mi” and checkthat h is indeed a unit matrix ( you may have to perform “Simp lify” on h).In general any n × n matrix has n eigenvalues and n eigenvectors. Type“Eigenvalues[m]” followed by “Eigenvectors[m]” to see what they are for thematrix m.Assignment 3Problem 1. A 2 × 2 matrix A is constructed from the following rows: (5,3)and (2,1).(i) Write it in matrix form.(ii) Find its determinant.(iii) Find its transpose.(iv) Find its inverse A−1.(v) Check A·A−1is a unit matrix.(vi) Check A−1·A is also a unit matrix.(vii) Find its eigenvalues and eigenvectors.(viii) Check that A · eigenvector = eigenvalue times eigenvector for each ofthe eigenvectors.Problem 2.(i) Find the solution to the following set of equations:2x − y + 2z = 2−x + 5y + z = 12x + y + 6z = 12by writing them as a matrix equation Av = b, whose solution is v = A−1b.(This is not the most straightforward way to solve these equations usingMathematica—see below—but it is the method you would have learned whenyou first learned matrices.)Check that you have the solution by evaluating A · v − b.Also solve these equations using Mathematica’s Solve command. (To dothat, define the solution vector in terms of its components, e.g., u = {ux, uy, uz},and note that the equation to be solved must be typed with a double equalsign, e.g. A.u - b == 0.Also solve these equations using Mathematica’s LinearSolve command.(ii) Try to find the solution to the following set of equations:1x + 2y − z = −0.41.3x − 3.2y + 1.3z = 1−2.5x − 5y + 2.5z = 1What does Mathematica tell you? What does this mean? From a math-ematical point of view, explain why this set of equations does not have aunique solution. Write your answers in a text cell.Also solve these equations using the Solve command.Also solve these equations using the LinearSolve command, and notethat it is misleading, since it gives only one out of the infinite number ofpossible


View Full Document
Download worksheet03
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view worksheet03 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view worksheet03 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?