Transcription of Linear Algebra Using MATLAB - UH
1 Linear Algebra UsingMATLABMATH 53311 May 12, 20101 Selected material from the textLinear Algebra and Differential Equations Using MATLABbyMartin Golubitsky and Michael DellnitzContents1 Vectors and Matrices .. MATLAB .. Special Kinds of Matrices .. The Geometry of Vector Operations .. 112 Solving Linear Systems of Linear Equations and Matrices .. The Geometry of Low-Dimensional Solutions .. Gaussian Elimination .. Reduction to Echelon Form .. Linear Equations with Special Coefficients .. *Uniqueness of Reduced Echelon Form .. 643 Matrices and Matrix Multiplication of Vectors .. Matrix Mappings .. Linearity .. The Principle of Superposition .. Composition and Multiplication of Matrices .. Properties of Matrix Multiplication.
2 Solving Linear Systems and Inverses .. Determinants of 2 2 Matrices .. 1064 Determinants and Determinants .. Determinants, An Alternative Treatment .. Eigenvalues .. Eigenvalues and Eigenvectors .. *Markov Chains .. Appendix: Existence of Determinants .. 1665 Vector Vector Spaces and Subspaces .. Construction of Subspaces .. Spanning Sets and MATLAB .. Linear Dependence and Linear Independence .. Dimension and Bases .. The Proof of the Main Theorem .. 1936 Linear Maps and Changes of Linear Mappings and Bases .. Row Rank Equals Column Rank .. Vectors and Matrices in Coordinates .. Matrices of Linear Maps on a Vector Space .. 219ii7 Orthonormal Bases .. Least Squares Approximations .. Least Squares Fitting of Data.
3 Symmetric Matrices .. Orthogonal Matrices andQRDecompositions .. 2468 Matrix Normal Real Diagonalizable Matrices .. Simple Complex Eigenvalues .. Multiplicity and Generalized Eigenvectors .. The Jordan Normal Form Theorem .. *Appendix: Markov Matrix Theory .. *Appendix: Proof of Jordan Normal Form .. 288 MATLABC ommands292iiiChapter 1 PreliminariesThe subjects of Linear Algebra and differential equations involve manipulating vector equa-tions. In this chapter we introduce our notation for vectors and matrices and we intro-duce MATLAB , a computer program that is designed to perform vector manipulations in anatural begin, in Section , by defining vectors and matrices, and by explaining how to addand scalar multiply vectors and matrices. In Section we explain how to enter vectors andmatrices into MATLAB , and how to perform the operations of addition and scalar multipli-cation in MATLAB .
4 There are many special types of matrices; these types are introduced inSection In the concluding section, we introduce the geometric interpretations of vectoraddition and scalar multiplication; in addition we discuss the angle between vectors throughthe use of the dot product of two Vectors and MatricesIn their elementary form, matrices and vectors are just lists of real numbers in differentformats. Ann-vector is a list ofnnumbers (x1,x2,..,xn). We may write this vector as arowvector as we have just done or as acolumnvector .The set of all (real-valued)n-vectors is denoted byRn; so points inRnare called setsRnwhennis small are very familiar sets. The setR1=Ris the real numberline, and the setR2is the Cartesian plane. The setR3consists of points or vectors in threedimensional nmatrixis a rectangular array of numbers withmrows andncolumns.
5 Ageneral 2 3 matrix has the formA=(a11a12a13a21a22a23).We use the convention that matrix entriesaijare indexed so that the first subscriptirefersto therowwhile the second subscriptjrefers to thecolumn. So the entrya21refers to thematrix entry in the 2ndrow, nmatrixAand anm n matrixBare equal precisely when the sizes of thematrices are equal (m=m andn=n ) and when each of the corresponding entries areequal (aij=bij).There is some redundancy in the use of the terms vector and matrix . For example,a rown-vector may be thought of as a 1 nmatrix, and a columnn-vector may be thoughtof as an 1 matrix. There are situations where matrix notation is preferable to vectornotation and and Scalar Multiplication of VectorsThere are two basic operations on vectors: addition and scalar multiplication. Letx=(x1,..,xn) andy=(y1.)
6 ,yn)ben-vectors. Thenx+y=(x1+y1,..,xn+yn);that is,vector additionis defined as componentwise ,scalar multiplicationis defined as componentwise multiplication. Ascalarisjust a number. Initially, we use the term scalar to refer to a real number but later on wesometimes use the term scalar to refer to acomplexnumber. Supposeris a real number;then the multiplication of a vector by the scalarris defined asrx=(rx1,..,rxn).Subtraction of vectors is defined simply asx y=(x1 y1,..,xn yn).Formally, subtraction of vectors may also be defined asx y=x+( 1) of a vectorxby a scalarris defined to standard difficulties concerning division by zero still and Scalar Multiplication of MatricesSimilarly, we add twom nmatrices by adding corresponding entries, and we multiply ascalar times a matrix by multiplying each entry of the matrix by that scalar.
7 For example,(0246)+(1 314)=(1 15 10)and4(2 431)=(8 16124).The main restriction on adding two matrices is that the matrices must be of the same you cannot add a 4 3 matrix to 6 2 matrix even though they both have ExercisesIn Exercises 1 3, letx= (2,1,3) andy= (1,1, 1) and compute the given + the 3 4 matrixA= 2 10134 7 106 342 .(a) For whichnis a row ofAa vector inRn?(b) What is the 2ndcolumn ofA?(c) Letaijbe the entry ofAin theithrow and thejthcolumn. What isa23 a31?For each of the pairs of vectors or matrices in Exercises 5 9, decide whether addition of the membersof the pair is possible; and, if addition is possible, perform the (2,1) andy= (3, 1). (1,2,2) andy=( 2,1,4). (1,2,3) andy=( 2,1). (1304)andB=(211 2). 210410000 andB=(211 2).In Exercises 10 11, letA=(21 14)andB=(023 1)and compute the given + MATLABWe shall use MATLAB to compute addition and scalar multiplication of vectors in two and threedimensions.
8 This will serve the purpose of introducing some basic MATLAB Vectors and Vector OperationsBegin a MATLAB session. We now discuss how to enter a vector into MATLAB . The syntax isstraightforward; to enter the row vectorx= (1,2,1) type1x = [1 2 1]and MATLAB responds withx=121 Next we show how easy it is to perform addition and scalar multiplication in MATLAB . Enterthe row vectory= (2, 1,1) by typingy = [2 -1 1]and MATLAB responds withy=2 -1 11 MATLABhas several useful line editing features. We point out two here:(a) Horizontal arrow keys ( , ) move the cursor one space without deleting a character.(b) Vertical arrow keys ( , ) recall previous and next command add the vectorsxandy, typex+yand MATLAB responds withans =312 This vector is easily checked to be the sum of the vectorsxandy. Similarly, to perform a scalarmultiplication, type2*xwhich yieldsans =242 MATLAB subtracts the vectoryfrom the vectorxin the natural way.
9 Typex-yto obtainans =-1 3 0We mention two points concerning the operations that we have just performed in MATLAB .(a) When entering a vector or a number, MATLAB automatically echoes what has been echoing can be suppressed by appending a semicolon to the example, typez = [-1 2 3];and MATLAB responds with a new line awaiting a new command. To see the contents of thevectorzjust typezand MATLAB responds withz=-1 2 3(b) MATLAB stores in a new vector the information obtained by algebraic manipulation. Typea = 2*x - 3*y + 4*z;5 Now typeato finda=-8 15 11We see that MATLAB has created a new row vectorawith the correct number of : In order to use the result of a calculation later in a MATLAB session, we need to namethe result of that calculation. To recall the calculation2*x - 3*y + 4*z, we needed to name thatcalculation, which we did by typinga = 2*x - 3*y + 4*z.
10 Then we were able to recall the resultjust by have seen that we enter a rownvector into MATLAB by surrounding a list ofnnumbersseparated by spaces with square brackets. For example, to enter the 5-vectorw= (1,3,5,7,9) justtypew = [1 3 5 7 9]Note that the addition of two vectors is only defined when the vectors have the same number ofentries. Trying to add the 3-vectorxwith the 5-vectorwby typingx+win MATLAB yields thewarning:??? Error Using ==> +Matrix dimensions must MATLAB new rows are indicated by typing;. For example, to enter the column vectorz= 123 ,just type:z = [-1; 2; 3]and MATLAB responds withz=-123 Note that MATLAB will not add a row vector and a column vector. Try typingx+ entries of a vector can also be addressed. For instance, to display the first componentofztypez(1).6 Entering MatricesMatrices are entered into MATLAB row by row with rows separated either by semicolons or by linereturns.