### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# Selected Topics in Math MATH 6397

UH

GPA 3.69

### View Full Document

## 30

## 0

## Popular in Course

## Popular in Mathmatics

This 17 page Class Notes was uploaded by Alvena McDermott on Saturday September 19, 2015. The Class Notes belongs to MATH 6397 at University of Houston taught by Staff in Fall. Since its upload, it has received 30 views. For similar materials see /class/208432/math-6397-university-of-houston in Mathmatics at University of Houston.

## Reviews for Selected Topics in Math

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/19/15

Linear algebra in R S ren Hojsgaard February 157 2005 Contents 1 Introduction 1 2 Vectors 1 Vectors i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i 1 2 2 Transpose of vectors i i i i i i i i i i i i i i i i i i i i i i i i i i i 2 2 3 Multiplying a vector by a number i i i i i i i i i i i i i i i i i i i i 3 2 4 Sum of vectors i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i 3 215 Inner product of vectors i i i i i i i i i i i i i i i i i i i i i i i i 4 216 The length norm of a vector i i i i i i i i i i i i i i i i i i i i i i 5 217 The Oivector and livector i i i i i i i i i i i i i i i i i i i i i i i i 5 2 8 Orthogonal perpendicular vectors i i i i i i i i i i i i i i i i i i i 5 3 Matrices 6 3 1 Matrices i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i 6 3 2 Multiplying a matrix with a number i i i i i i i i i i i i i i i i i i 6 3 3 Transpose of matrices i i i i i i i i i i i i i i i i i i i i i i i i i i 7 34 Sum of matrices i i i i i i i i i i i i i i i i i i i i i i i i i i i i i 7 3 5 Multiplication of a matrix and a vector i i i i i i i i i i i i i i i i 7 3 6 Multiplication of matrices i i i i i i i i i i i i i i i i i i i i i i i i 8 3 7 Vectors as matrices i i i i i i i i i i i i i i i i i i i i i i i i i i i i 9 318 Some special matrices i i i i i i i i i i i i i i i i i i i i i i i i i i 9 3 9 Inverse of matrices i i i i i i i i i i i i i i i i i i i i i i i i i i i i 10 3 10 Solving systems of linear equations i i i i i i i i i i i i i i i i i i i 11 3111 Trace i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i 12 312 Determinant i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i 12 3113 Some additional rules for matrix operations i i i i i i i i i i i i i i 12 3114 Details on inverse matrices i i i i i i i i i i i i i i i i i i i i i i i 12 311411 Inverse of a 2 X 2 matrix i i i i i i i i i i i i i i i i i i i i 12 311412 Inverse of diagonal matrices i i i i i i i i i i i i i i i i i i 13 311413 Generalized inverse i i i i i i i i i i i i i i i i i i i i i i i 13 311414 Inverting an n X n matrix i i i i i i i i i i i i i i i i i i i 13 4 Least squares 15 5 A neat little exercise 7 from a bird s perspective 16 1 Introduction This note has two goal 1 Introducing linear algebra vectors and matrices and 2 showing how to work with these concepts in i 2 Vectors 21 Vectors A column vector is a list of numbers stacked on top of each other eg 2 a l 3 A row vector is a list of numbers written one after the other eigi b 21 3 In both cases the list is ordered iiei 213 a 1 2 3 We make the following convention In what follows all vectors are column vectors unless otherwise stated However writing column vectors takes up more space than row vectorsi There fore we shall frequently write vectors as row vectors but with the understand ing that it really is a column vector A general nevector has the form where the ais are numbers and this vector shall be written a a1i ani A graphical representation of 27vectors is shown Figure 1 Note that row and Figure 1 Two 2vectors column vectors are drawn the same way gtalt c1 3 2 gt21 1132 The vector a is in R printed in row format77 but can really be regarded as a column vector cfri the convention abovei 22 Transpose of vectors Transposing a vector means turning a column row vector into a row column vector The transpose is denoted by T7 1 T 1 3 132 0g 1327 3 2 2 Example 1 D Hence transposing twice takes us back to Where we started a aTT gt ta I 1 2 3 1 1 3 2 23 Multiplying a vector by a number If a is a vector and a is a number then aa is the vector aal aa aa aan See Figure 2 Example 2 l 7 7 3 21 2 14 D gt 7 a l 1 7 21 14 Figure 2 Multiplication of a vector by a number 24 Sum of vectors Let a and b be nevectorsl The sum a b is the nevector a1 171 a1bi a2 1 2 a2b2 ab l ba an bn anbn See Figure 3 and 4 Only vectors of the same dimension can be added liHEH EEHEl Example 3 Figure 3 Addition of vectors Figure 4 Addition of vectors and multiplication by a number gtalt c1 3 2 gtblt c2 8 9 gtab 1 3 11 11 25 Inner product of vectors Let a alp i i 7 an and b 121111127 The inner product of a and b is aba1b1anbn Note7 that the product is a number 7 not a vector gt suma b l 1 44 26 The length norm of a vector The length or norm of a vector a is n Hall vaa Ea 11 gt sqrtsuma 21 1 3741657 27 The Oivector and livector The OVector livector is a vector With 0 1 on all entries The vector livector is frequently Written simply as 0 l or as 0 17 to emphasize that its length n gt rep0 5 I 1OOOOO gt rep1 5 I 111111 28 Orthogonal perpendicular vectors TWO vectors v1 and v2 are orthogonal if their inner product is zero7 Written vllvg vlv20 gt v1 lt Cl 1 gt v2 lt c1 1 gt sumv1 v2 l1o 3 Matrices 31 Matrices An T X 5 matrix A reads an T times 5 matrix is a table With T Tows 0g 5 columns all alg i i 0410 agl 0422 i i i 0420 A 0471 0472 i i i a Note that one can regard A as consisting of 5 columns vectors put after each other Aa1a2ac gt A lt matrixc1 3 2 2 8 9 ncol 3 gt A 1 2 3 1 2 8 2 3 2 9 Note that the numbers 13 2289 are read into the matrix columnibyi column To get the numbers read in rowibyirow gt A2 lt matrixc1 3 2 2 8 9 ncol 3 byrow T gt A2 1 2 3 1 3 2 2 2 8 9 32 Multiplying a matrix With a number For a number a and a matrix A7 the product 1A is the matrix obtained by multiplying each element in A by a Example4 12 714 7 3 8 2156 2 9 14 63 D gt7A 1 2 3 1 7 14 5 2 21 14 63 33 Transpose of matrices A matrix is transposed by interchanging rows and columns and is denoted by T77 Example 5 meow Doom Note that if A is an 7 X 5 matrix then AT is a c X 7 matrix gt tA 1 2 1 3 34 Sum of matrices Let A and B be T X 5 matrices The sum A B is the T X 5 matrix obtained by adding A and B elementWise Only matrices With the same dimensions can be added Example 6 1 2 5 4 6 6 3 8 8 2 11 10 2 9 3 7 5 16 gt B lt matrixc5 8 3 4 2 7 ncol 3 byrow T gt A B 1 2 3 1 6 10 11 2 7 4 16 35 Multiplication of a matrix and a vector Let A be an T X 5 matrix and let I be a c dimensional column vector The product Al is the T X 1 matrix an a12 u ale 171 alibi a12112 39 39 39 aicbc a21 a22 u We 112 a21111 a22112 39 39 39 2ch Ab l l l an W2 u aTc be ale1 ar2112 39 39 39 ach0 Example 7 1 2 5 1 5 28 21 3 8 8 3588 79 2 9 25 98 82 D gt A a 1 1 23 2 27 Note the difference to gtAa 1 2 3 1 1 4 2 2 9 2 18 Figure out yourself What goes on 36 Multiplication of matrices Let A be an T X cmatrix and B acgtlt t matrix7 ie E b12122 bti The product AB is the T X t matrix given by ABAb1b2btAb1Ab2Abt Example8 1 2 1 2 1 2 3 3 38 38 2 9 2 9 2 9 1528 1422 21 8 3588 3482 79 28 2598 2492 82 26 D Note that the product AB can only be formed if the number of rows in B and the number of columns in A are the same In that case7 A and B are said to be conformei In general AB and BA are not identical A MNEMONIC FOR MATRIX MULTIPLICATION is Z 12 218 38g 7928 29 8226 gt A lt matrixc1 3 2 2 8 9 ncol 2 gt B lt matrixc5 8 4 2 ncol 2 gt A 3939 B 1 2 21 8 2 79 28 3 82 26 37 Vectors as matrices One can regard a column vector of length T as an T X 1 matrix and a row vector of length 5 as a 1 X 5 matrix 38 Some special matrices 7 An n x n matrix is a SQUARE MATRIX 7 A matrix A is SYMMETRIC if A AT 7 A matrix With 0 on all entries is the OiMATRIX and is often Written simply as 0 7 A matrix consisting of 1s in all entries is of Written J 7 A square matrix With 0 on all off7diagonal entries and elements d1 d2 I I I dn on the diagonal a DIAGONAL MATRIX and is often Written diagd1 d2 I I I dn 7 A diagonal matrix With 1s on the diagonal is called the IDENTITY MATRIX and is denoted I The identity matrix satis es that IA AI A Omatrix and lmatrix gt matrix0 nrow 2 ncol 3 1 2 3 1 O O O 2 O O O gt matrix1 nrow 2 ncol 3 1 2 3 1 1 1 1 2 1 1 1 Diagonal matrix and identity matrix gt diagc1 2 3 1 2 3 1 O O 2 O 2 O 3 O O 3 gt diag1 3 1 2 3 1 O O 2 O 1 O 3 O O 1 Note What happens When diag is applied to a matrix gt diagdiagc1 2 3 I 1123 l gt diagA I 118 39 Inverse of matrices In general the inverse of an n X n matrix A is the matrix B Which is also n X n Which When multiplied With A gives the identity matrix I That is AB BA I One says that B is As inverse and Writes B A ll Likewise A is Bs inverse Example 9 Let 1 3 72 15 Al241Bl17051 NOWABBAIsoBA 1l D Example 10 If A is a 1 X 1 matrix ile a number for example A 4 then A 1 14 D Some facts about inverse matrices are 7 Only square matrices can have an inverse but not all square matrices have an inverse 7 When the inverse exists it is unique 7 Finding the inverse of a large matrix A is numerically complicated but computers do it for us 1 In Section 7 the issue of matrix inversion is discussed in more detail Finding the inverse of a matrix in R is done using the solve function gt A lt matrixc1 3 2 4 ncol 2 byrow T gt11 1 2 1 1 3 2 2 4 gt B lt solveA gtB 1 2 1 2 15 2 1 O5 gtA B 1 2 1 1 o 2 o 1 310 Solving systems of linear equations Example 11 Matrices are closely related to systems of linear equations Con sider the two equations 11 312 7 211 412 10 The system can be written in matrix form iH15 Since A lA I and since I I we have 7 1 7 72 1 5 7 7 1 I A b l 1 70 5 10 2 A geometrical approach to solving these equations is as follows lsolate 12 in the equations 7 l l 4 2 z 777x 1 7 77x 2 3 3 1 2 0 4 1 These two lines are shown in Figure 5 from which it can be seen that the solution is 11 112 2i Figure 5 Solving two equations with two unknowns From the Figure it follows that there are 3 possible cases of solutions to the system 1 Exactly one solution 7 when the lines intersect in one point 2 No solutions 7 when the lines are parallel but not identical 3 ln nitely many solutions 7 when the lines coincide gt A lt matrixc1 2 3 4 ncol 2 gt b lt c7 10 gt x lt solveA 3939 b gt X 311 Trace Missing 312 Determinant Missing 313 Some additional rules for matrix operations For matrices A7 B and C Whose dimension match appropriately the following rules apply 14T ATBT ABT BTAT ABC ABAC AB AC ye B 0 ln genereal AB BA AI IA A If a is a number then aAB AaB 314 Details on inverse matrices 3141 Inverse of a 2 X 2 matrix It is easy nd the inverse for a 2 X 2 matrix When a b A l c d i 1 d 7b 117 A 7ad7b67c a under the assumption that abi be 0 The number abi be is called the determinant of A7 sometimes Written If A 07 then A has no inverse then the inverse is 3142 Inverse of diagonal matrices Finding the inverse of a diagonal matrix is easy Let A diaga1 a2 an Where all ai 0 Then the inverse is 1 1 77 a1 a2 1 17 A idzag 7 If one ai 0 then A 1 does not exist 3143 Generalized inverse Not all square matrices have an inverse However all square matrices have an in nite number of generalized inverses A generalized inverse of a square matrix A is a matrix A satisfying that AA A A For many practical problems it suf ce to nd a generalized inverse 13 3144 Inverting an n X n matrix In the following we will illustrate one frequently applied methopd for matrix inver sion The method is called Gauss7Seidels method an many computer programs including solve use variants of the method for nding the inverse of an n X n matrix Consider the matrix A gt A lt matrixc2 2 3 3 5 9 5 6 7 ncol 3 gt A 1 2 3 2 3 5 2 2 5 6 3 3 9 7 We want to nd the matrix B A I To start we append to A the identity matrix and call the result AB gt AB lt cbindA diagc1 1 1 gt AB 1 2 3 4 5 6 2 2 5 6 O 1 O 3 3 9 7 O O 1 On a matrix we allow ourselves to do the following three operations sometimes called elementary operations as often as we want 1 Multiply a row by a nonizero constant 2 Multiply a row by a nonizero constant and add the result to another row 3 Interchange two rows The aim is to perform such operations on AB in a way such that one ends up with a 3 X 6 matrix which has the identity matrix in the three leftmost columns The three rightmost columns will then contain B A Recall that writing eig AB1 extracts the enire rst row of AB C First we make sure that AB1 1 1 Then we subtract a constant times the rst row from the second to obtain that AB 2 1 0 and similarly for the third row gt AB1 lt AB1AB11 gt AB2 lt AB2 1 2 AB1 gt AB3 lt mm 1 3 AB1 gt AB 1 2 3 4 5 6 1 15 25 05 O O 2 O 20 10 10 1 O 3 O 45 O5 15 O 1 Next we ensure that AB 2 2 1 Afterwards we subtract a constant times the second row from the third to obtain that AB 3 2 0 gt AB2 lt AB2 AB2 2 gtmBJlt mamp45BDJ Now we rescale the third row such that AB 33 1 gt ms lt AB3AB331 gt AB 1 2 3 4 6 1 1 1 5 25 05000000 00000000 00000000 2 0 10 05 05000000 05000000 00000000 3 0 00 10 02727273 08181818 03636364 Then AB has zeros below the main diagonal We then work our way up to obtain that AB has zeros above the main diagonal gtmmJlt BMQ5BBJ gt AB1 lt AB1 25 AB3 gt AB 1 2 3 4 5 6 1 1 15 0 11818182 204545455 09090909 2 0 10 0 03636364 009090909 01818182 3 0 00 1 02727273 081818182 03636364 gt AB1 lt AB1 15 AB2 gt AB 4 5 6 17272727 218181818 06363636 2 0 1 0 03636364 009090909 01818182 3 0 0 1 02727273 081818182 03636364 1 2 3 1 0 Now we extract the three rightmost columns of AB into the matrix B We claim that B is the inverse of A7 and this can be veri ed by a simple matrix multiplication lt AB 46 gt B gt A B 1 2 3 1000000e00 3330669e16 1110223e16 4440892e16 1000000e00 2220446e16 2220446e16 9992007e16 1000000e00 rw rw rw m M H 4 So7 apart from rounding errors7 the product is the identity matrix7 and hence B A li This example illustrates that numerical precision and rounding errors is an important issue when making computer programs 15 4 Least squares Consider the table of pairs Ii belowi x 1 00 2 00 3 00 4 00 500 y 3 70 4 20 4 90 5 70 600 A plot of yi against 11 is shown in Figure 6 Figure 6 Regression The plot in Figure 6 suggests an approximately linear relationship between y and 1 ie 9139 o iri fOFi 17 uy5 Writing this in matrix form gives 91 1 I1 92 I 60 J m X y z 2 l 51 95 1 15 The rst question is Can we nd a vector 6 such that y X6 The answer is clearly no7 because that would require the points to lie exactly on a straight line A more modest question is Can we nd a vector 6 such that X6 is in a sense as close to y as possible The answer is yes The task is to nd 6 such that the length of the vector 6 y 7 X6 is as small as possible The solution is 3XTX 1XTy Igt Y I 137 42 49 57 60 r v cu L4 D D D D H mpmeD N gt betahat lt solvetX 3939 X 3939 tX 3939 y gt betahat 1 307 x 061 5 A neat little exercise 7 from a bird s perspective On a sunny day7 two tables are standing in an English country gardeni On each table birds of unknown species are sitting haVing the time of their lives A bird from the rst table says to those on the second table Hi 7 if one of you come to our table then there will be the same number of us on each table Yeah right 7 says a bird from the second table7 but if one of you comes to our table7 then we will be twice as many on our table as on yours77i Question How many birds are on each table More speci cally7 Write up two equations with two unknownsi Solve these equations using the methods you have learned from linear algebra Simply nding the solution by trialiandierror is considered cheatingi

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

#### "I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

#### "Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.