Matrix Calculations: Kernels & Images, Matrix Multiplication

Similar documents
NOTES ON LINEAR TRANSFORMATIONS

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix.

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

Similarity and Diagonalization. Similar Matrices

T ( a i x i ) = a i T (x i ).

Linear Maps. Isaiah Lankham, Bruno Nachtergaele, Anne Schilling (February 5, 2007)

Au = = = 3u. Aw = = = 2w. so the action of A on u and w is very easy to picture: it simply amounts to a stretching by 3 and 2, respectively.

A =

Lecture Notes 2: Matrices as Systems of Linear Equations

Lecture 2 Matrix Operations

Mathematics Course 111: Algebra I Part IV: Vector Spaces

Methods for Finding Bases

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

Solution to Homework 2

Linear Algebra Notes for Marsden and Tromba Vector Calculus

Systems of Linear Equations

Matrix Representations of Linear Transformations and Changes of Coordinates

MA106 Linear Algebra lecture notes

( ) which must be a vector

Name: Section Registered In:

Orthogonal Diagonalization of Symmetric Matrices

by the matrix A results in a vector which is a reflection of the given

Solutions to Math 51 First Exam January 29, 2015

Linear Algebra Notes

LS.6 Solution Matrices

Solving Systems of Linear Equations

Notes on Determinant

University of Lille I PC first year list of exercises n 7. Review

Math 312 Homework 1 Solutions

1 VECTOR SPACES AND SUBSPACES

160 CHAPTER 4. VECTOR SPACES

Section Inner Products and Norms

5.5. Solving linear systems by the elimination method

1 Introduction to Matrices

1.2 Solving a System of Linear Equations

Linearly Independent Sets and Linearly Dependent Sets

THE DIMENSION OF A VECTOR SPACE

1 Sets and Set Notation.

MATH APPLIED MATRIX THEORY

1 Solving LPs: The Simplex Algorithm of George Dantzig

Inner Product Spaces

MATH1231 Algebra, 2015 Chapter 7: Linear maps

A linear combination is a sum of scalars times quantities. Such expressions arise quite frequently and have the form

Chapter 7. Matrices. Definition. An m n matrix is an array of numbers set out in m rows and n columns. Examples. (

MAT188H1S Lec0101 Burbulla

Recall that two vectors in are perpendicular or orthogonal provided that their dot

5 Homogeneous systems

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

These axioms must hold for all vectors ū, v, and w in V and all scalars c and d.

8 Square matrices continued: Determinants

5. Linear algebra I: dimension

MAT 200, Midterm Exam Solution. a. (5 points) Compute the determinant of the matrix A =

Lecture 3: Finding integer solutions to systems of linear equations

Vector and Matrix Norms

Section 5.3. Section 5.3. u m ] l jj. = l jj u j + + l mj u m. v j = [ u 1 u j. l mj

v w is orthogonal to both v and w. the three vectors v, w and v w form a right-handed set of vectors.

Vector Spaces 4.4 Spanning and Independence

Lectures notes on orthogonal matrices (with exercises) Linear Algebra II - Spring 2004 by D. Klain

MATH 423 Linear Algebra II Lecture 38: Generalized eigenvectors. Jordan canonical form (continued).

Section 8.2 Solving a System of Equations Using Matrices (Guassian Elimination)

BANACH AND HILBERT SPACE REVIEW

Math 215 HW #6 Solutions

1.5 SOLUTION SETS OF LINEAR SYSTEMS

Notes on Orthogonal and Symmetric Matrices MENU, Winter 2013

Polynomial Invariants

Linear Programming. March 14, 2014

1 Determinants and the Solvability of Linear Systems

4.5 Linear Dependence and Linear Independence

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix multiplication).

Solving Systems of Linear Equations Using Matrices

10.2 ITERATIVE METHODS FOR SOLVING LINEAR SYSTEMS. The Jacobi Method

Inner products on R n, and more

Linear Algebra Review. Vectors

MATH2210 Notebook 1 Fall Semester 2016/ MATH2210 Notebook Solving Systems of Linear Equations... 3

Examination paper for TMA4115 Matematikk 3

MAT 242 Test 2 SOLUTIONS, FORM T

Chapter 6. Orthogonality

DERIVATIVES AS MATRICES; CHAIN RULE

Linear Algebra I. Ronald van Luijk, 2012

Row Echelon Form and Reduced Row Echelon Form

Solving Linear Systems, Continued and The Inverse of a Matrix

3. INNER PRODUCT SPACES

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

Introduction to Matrix Algebra

DETERMINANTS TERRY A. LORING

Introduction to Matrices

Matrix Differentiation

5. Orthogonal matrices

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

Direct Methods for Solving Linear Systems. Matrix Factorization

4: EIGENVALUES, EIGENVECTORS, DIAGONALIZATION

Matrix Algebra. Some Basic Matrix Laws. Before reading the text or the following notes glance at the following list of basic matrix algebra laws.

CITY UNIVERSITY LONDON. BEng Degree in Computer Systems Engineering Part II BSc Degree in Computer Systems Engineering Part III PART 2 EXAMINATION

[1] Diagonal factorization

Reduced echelon form: Add the following conditions to conditions 1, 2, and 3 above:

Lecture notes on linear algebra

ISOMETRIES OF R n KEITH CONRAD

Transcription:

Matrix Calculations: Kernels & Images, Matrix Multiplication A. Kissinger (and H. Geuvers) Institute for Computing and Information Sciences Intelligent Systems Version: spring 2016 A. Kissinger Version: spring 2016 Matrix Calculations 1 / 43

Outline Matrix multiplication Matrix multiplication A. Kissinger Version: spring 2016 Matrix Calculations 2 / 43

From last time Matrix multiplication Vector spaces V, W,... are special kinds of sets whose elements are called vectors. Vectors can be added together, or multiplied by a real number, For v, w V, a R: v + w V a v V The simplest examples are: R n := {(a 1,..., a n ) a i R} Linear maps are special kinds of functions which satisfy two properties: f (v + w) = f (v) + f (w) f (a v) = a f (v) A. Kissinger Version: spring 2016 Matrix Calculations 3 / 43

From last time Matrix multiplication Whereas there exist LOTS of functions between the sets V and W......there actually aren t that many linear maps: Theorem For every linear map f : R n R m, there exists an m n matrix A where: f (v) = A v (where is the matrix multiplication of A and a vector v) More generally, every linear map f : V W is representable as a matrix, but you have to fix a basis for V and W first: {v 1,..., v m } V {w 1,..., w n } W...whereas in R n there is an obvious choice: {(1, 0,..., 0), (0, 1,..., 0),..., (0,..., 0, 1)} R n A. Kissinger Version: spring 2016 Matrix Calculations 4 / 43

Matrix-vector multiplication For a matrix A and a vector v, w := A v is the vector whose i-th row is the dot product of the i-th row of A with v: a 11 a 1n.. a m1 a mn v 1.. v n = a 11 v 1 +... + a 1n v n. a m1 v 1 +... + a mn v n i.e. w i := a 11 v 1 +... + a 1n v n = n a ij v j. j=1 A. Kissinger Version: spring 2016 Matrix Calculations 5 / 43

Example: systems of equations a 11 x 1 + + a 1n x n = b 1.. a m1 x 1 + + a mn x n = b m A x = b a 11 a 1n x 1.. a m1 a mn x n = b 1. b n a 11 x 1 + + a 1n x n = 0... a m1 x 1 + + a mn x n = 0 A x = 0 a 11 a 1n... a m1 a mn x 1. x n = 0. 0 A. Kissinger Version: spring 2016 Matrix Calculations 6 / 43

Matrix multiplication Consider linear maps g, f represented by matrices A, B: g(v) = A v f (w) = B w Can we find a matrix C that represents their composition? Let s try: g(f (v)) = C v g(f (v)) = g(b v) = A (B v) ( ) = (A B) v (where step ( ) is currently wishful thinking ) Great! Let C := A B. But we don t know what means for two matrices yet... A. Kissinger Version: spring 2016 Matrix Calculations 8 / 43

Matrix multiplication Solution: generalise from A v A vector is a matrix with one column: The number in the i-th row and the first column of A v is the dot product of the i-th row of A with the first column of v. So for matrices A, B: The number in the i-th row and the j-th column of A B is the dot product of the i-th row of A with the j-th column of B. A. Kissinger Version: spring 2016 Matrix Calculations 9 / 43

Matrix multiplication For A an m n matrix, B an n p matrix: is an m p matrix... a i1 A B = C.. b j1.... a in.... = c ij.. b jn....... n c ij = a ik b kj k=1 A. Kissinger Version: spring 2016 Matrix Calculations 10 / 43

Special case: vectors Matrix multiplication For A an m n matrix, B an n 1 matrix: A b = c is an m 1 matrix... a i1.. a in.. b 11.. b n1 =. c i1. n c i1 = a ik b k1 k=1 A. Kissinger Version: spring 2016 Matrix Calculations 11 / 43

Matrix composition Matrix multiplication Theorem Matrix composition is associative: (A B) C = A (B C) Proof. Let X := (A B) C. This is a matrix with entries: x ip = k a ik b kp Then, the matrix entries of X C are: x ip c pj = ( ) a ik b kp c pk = p p kp k a ik b kp c pk (because sums can always be pulled outside, and combined) A. Kissinger Version: spring 2016 Matrix Calculations 12 / 43

Associativity of matrix composition Proof (cont d). Now, let Y := B C. This has matrix entries: y kj = p b kp c pj Then, the matrix entries of A Y are: a ik y kj = ( a ik k k p ) b kp c pj = a ik b kp c pk kp...which is the same as before! So: (A B) C = X C = A Y = A (B C) So we can drop those pesky parentheses: A B C := (A B) C = A (B C) A. Kissinger Version: spring 2016 Matrix Calculations 13 / 43

Matrix product and composition Corollary The composition of linear maps is given by matrix product. Proof. Let g(w) = A w and f (v) = B v. Then: g(f (v)) = g(b v) = A B v No wishful thinking necessary! A. Kissinger Version: spring 2016 Matrix Calculations 14 / 43

Example 1 Matrix multiplication Consider the following two linear maps, and their associated matrices: R 3 f R 2 R 2 g R 2 f (x 1, x 2, x 3 ) = (x 1 x 2, x 2 + x 3 ) g(y 1, y 2 ) = (2y 1 y 2, 3y 2 ) ( ) ( ) 1 1 0 2 1 M f = M 0 1 1 g = 0 3 We can compute the composition directly: (g f )(x 1, x 2, x 3 ) = g ( f (x 1, x 2, x 3 ) ) So: = g(x 1 x 2, x 2 + x 3 ) = ( 2(x 1 x 2 ) (x 2 + x 3 ), 3(x 2 + x 3 ) ) = ( 2x 1 3x 2 x 3, 3x 2 + 3x 3 ) ( ) 2 3 1 M g f = 0 3 3...which is just the product of the matrices: M g f = M g M f A. Kissinger Version: spring 2016 Matrix Calculations 15 / 43

Note: matrix composition is not commutative In general, A B B A ( ) 1 0 For instance: Take A = and B = 0 1 ( ) ( ) 1 0 0 1 A B = ( 0 1 1 0 ) 1 0 + 0 1 1 1 + 0 0 = 0 0 + 1 1 0 1 + 1 0 B A = = ( ) ( ) 0 1 1 0 ( 1 0 0 1 ) 0 1 + 1 0 0 0 + 1 1 1 1 + 0 0 1 0 + 0 1 ( ) 0 1. Then: 1 0 = = ( ) 0 1 1 0 ( 0 ) 1 1 0 A. Kissinger Version: spring 2016 Matrix Calculations 16 / 43

But it is... Matrix multiplication...associative, as we ve already seen: A B C := (A B) C = A (B C) It also has a unit given by the identity matrix I : A I = I A = A where: 1 0 0 0 1 0 I :=....... 0 0 1 A. Kissinger Version: spring 2016 Matrix Calculations 17 / 43

Example: political swingers, part I We take an extremely crude view on politics and distinguish only left and right wing political supporters We study changes in political views, per year Suppose we observe, for each year: 80% of lefties remain lefties and 20% become righties 90% of righties remain righties, and 10% become lefties Questions... start with a population L = 100, R = 150, and compute the number of lefties and righties after one year; similarly, after 2 years, and 3 years,... Find a convenient way to represent these computations. A. Kissinger Version: spring 2016 Matrix Calculations 18 / 43

Political swingers, part II So if we start with a population L = 100, R = 150, then after one year we have: lefties: 0.8 100 + 0.1 150 = 80 + 15 = 95 righties: 0.2 100 + 0.9 150 = 20 + 135 = 155 Two observations: this looks like a matrix-vector multiplication long-term developments can be calculated via iterated matrices A. Kissinger Version: spring 2016 Matrix Calculations 19 / 43

Political swingers, part III We can write the political transition ( matrix ) as 0.8 0.1 P = 0.2 0.9 ( ( ) L 100 If =, then after one year we have: R) 150 ( ) ( ) ( ) 100 0.8 0.1 100 P = 150 ( 0.2 0.9 150 ) 0.8 100 + 0.1 150 = = 0.2 100 + 0.9 150 After two ( years ) we have: ( ) 95 0.8 0.1 P = 155 0.2 0.9 = ( 95 155 ) ( 0.8 95 + 0.1 155 0.2 95 + 0.9 155 ) = ( ) 95 155 ( ) 91.5 158.5 A. Kissinger Version: spring 2016 Matrix Calculations 20 / 43

Political swingers, part IV The situation after two years is obtained as: ( ) ( ) ( ) ( ) L 0.8 0.1 0.8 0.1 L P P = R 0.2 0.9 0.2 0.9 R }{{} ( do this multiplication first ) ( ) 0.8 0.8 + 0.1 0.2 0.8 0.1 + 0.1 0.9 L = 0.2 0.8 + 0.9 0.2 0.2 0.1 + 0.9 0.9 R ( ) ( ) 0.66 0.17 L = 0.34 0.83 R The situation after n years is described by the n-fold iterated matrix: P n = P } P {{ P} n times A. Kissinger Version: spring 2016 Matrix Calculations 21 / 43

Political swingers, part V Interpret the following iterations: ( ) 0.66 0.17 P 2 = P P = ( 0.34 0.83 ) ( ) 0.8 0.1 0.66 0.17 P 3 = P P P = ( 0.2 0.9 ) 0.34 0.83 0.562 0.219 = ( 0.438 0.781 ) ( ) 0.8 0.1 0.562 0.219 P 4 = P P P P = ( 0.2 0.9 0.438 ) 0.781 0.4934 0.2533 = 0.5066 0.7467 Etc. Does this stabilise? We ll talk about fixed points later on... A. Kissinger Version: spring 2016 Matrix Calculations 22 / 43

Solving equations the old fashioned way... We now know that systems of equations look like this: A x = b The goal is to solve for x, in terms of A and b. Here comes some more wishful thinking: x = 1 A b Well, we can t really divide by a matrix, but if we are lucky, we can find another matrix called A 1 which acts like 1 A. A. Kissinger Version: spring 2016 Matrix Calculations 24 / 43

Inverse Matrix multiplication Definition The inverse of a matrix A is another matrix A 1 such that: A 1 A = A A 1 = I Not all matrices have inverses, but when they do, we are happy, because: A x = b = A 1 A x = A 1 b = x = A 1 b So, how do we compute the inverse of a matrix? A. Kissinger Version: spring 2016 Matrix Calculations 25 / 43

Remember me? Matrix multiplication A. Kissinger Version: spring 2016 Matrix Calculations 26 / 43

Gaussian elimination as matrix multiplication Each step of Gaussian elimination can be represented by a matrix multiplication: A A A := G A For instance, multiplying the i-th row by c is given by: G (Ri :=cr i ) A where G (Ri :=cr i ) is just like the identity matrix, but g ii = c. Exercise. What are the other Gaussian elimination matrices? G (Ri R j ) G (Ri :=R i +cr j ) A. Kissinger Version: spring 2016 Matrix Calculations 27 / 43

Reduction to Echelon form The idea: treat A as a coefficient matrix, and compute its reduced Echelon form If the Echelon form of A has n pivots, then its reduced Echelon form is the identity matrix: A A 1 A 2 A p = I Now, we can use our Gauss matrices to remember what we did: A 1 := G 1 A A 2 := G 2 G 1 A A p := G p G 1 A = I A. Kissinger Version: spring 2016 Matrix Calculations 28 / 43

Computing the inverse A ha! G p G 1 A = I = A 1 = G p G 1 So all we have to do is construct p different matrices and multiply them all together! Since I already have plans for this afternoon, lets take a shortcut: Theorem For C a matrix and (A B) an augmented matrix: C (A B) = (C A C B) A. Kissinger Version: spring 2016 Matrix Calculations 29 / 43

Computing the inverse Since Gaussian elimination is just multiplying by a certain matrix on the left... A G A...doing Gaussian elimination (for A) on an augmented matrix applies G to both parts: So, if G = A 1 : (A B) (G A G B) (A B) (A 1 A A 1 B) = (I A 1 B) A. Kissinger Version: spring 2016 Matrix Calculations 30 / 43

Computing the inverse We already (secretly) used this trick to solve: A x = b = x = A 1 b Here, we are only interested in the vector A 1 b Which is exactly what Gaussian elimination on the augmented matrix gives us: (A b) (I A 1 b) To get the entire matrix, we just need to choose something clever to the right of the line Like this: (A I ) (I A 1 I ) = (I A 1 ) A. Kissinger Version: spring 2016 Matrix Calculations 31 / 43

Computing the inverse: example For example, we compute the inverse of: ( ) 1 1 A := 1 2 as follows: ( ) 1 1 1 0 1 2 0 1 ( ) 1 1 1 0 0 1 1 1 ( 1 0 2 1 0 1 1 1 ) So: A 1 := ( 2 ) 1 1 1 A. Kissinger Version: spring 2016 Matrix Calculations 32 / 43

Computing the inverse: non-example Unlike transpose, not every matrix has an inverse. For example, if we try to compute the inverse for: ( ) 1 1 B := 1 1 we have: ( ) 1 1 1 0 1 1 0 1 ( ) 1 1 1 0 0 0 1 1 We don t have enough pivots to continue reducing. So B does not have an inverse. A. Kissinger Version: spring 2016 Matrix Calculations 33 / 43

Subspace definition Matrix multiplication Definition A subset S V of a vector space V is called a (linear) subspace if S is closed under addition and scalar multiplication: 0 S v, v S implies v + v S v S and a R implies a v S. Note A subspace S V is a vector space itself, and thus also has a basis. Also S has its own dimension, where dim(s) dim(v ). A. Kissinger Version: spring 2016 Matrix Calculations 35 / 43

Subspace examples Matrix multiplication 1 Earlier we saw that the subset of solutions of a system of equations is closed under addition and (scalar) multiplication, and thus is a linear subspace. 2 The diagonal D = {(x, x) x R} R 2 is a linear subspace: if (x 1, x 1 ), (x 2, x 2 ) D, then also (x 1, x 1 ) + (x 2, x 2 ) = (x 1 + x 2, x 1 + x 2 ) D if (x, x) D and a R, also a (x, x) = (a x, a x) D Also: D has a single vector as basis, for example (1, 1) thus, D has dimension 1 A. Kissinger Version: spring 2016 Matrix Calculations 36 / 43

Basis for subspaces Matrix multiplication Let the space V have dimension n, and a subspace S V dimension p, where p n. Then: any set of > p vectors in S is linearly dependent any set of < p vectors in S does not span S any set of p independent vectors in S is a basis for S any set of p vectors that spans S is a basis for S A. Kissinger Version: spring 2016 Matrix Calculations 37 / 43

: definitions Definition Let f : V W be a linear map the kernel of f is the subset of V given by: ker(f ) = {v V f (v) = 0} the image of f is the subset of W given by: Example im(f ) = {f (v) v V } Consider the function f : R 2 R 2 given by f (x, y) = (x, 0) the kernel is {(x, y) R 2 f (x, y) = (0, 0)}, which is {(0, y) y R}, i.e. the y-axis. the image is the x-axis {(x, 0) x R} A. Kissinger Version: spring 2016 Matrix Calculations 38 / 43

Kernels and images are subspaces Theorem For a linear map f : V W, ker(f ) = {v f (v) = 0} V is a linear subspace im(f ) = {f (v) v V } W is a linear subspace. Proof: We check two cases (do the others yourself!) Closure of ker(f ) under addition: if v, v ker(f ), then f (v) = 0 and f (v ) = 0. By linearity of f, f (v + v ) = f (v) + f (v ) = 0 + 0 = 0, so v + v ker(f ). Closure of im(f ) under scalar multiplication: Assume w im(f ), say w = f (v), and a R. Again by linearity: a w = a f (v) = f (a v), so a w im(f ). A. Kissinger Version: spring 2016 Matrix Calculations 39 / 43

Injectivity and surjectivity A linear map f : V W is surjective: w v.f (v) = w if and only if im(f ) = W. A linear map f : V W is injective: f (v) = f (w) = v = w if and only if ker(f ) = 0. A. Kissinger Version: spring 2016 Matrix Calculations 40 / 43

The kernel as solution space With this kernel (and image) terminology we can connect some previous concepts. Theorem Suppose a linear map f : V W has matrix A. Then: v ker(f ) f (v) = 0 A v = 0 v solves a system of homogeneous equations Moreover, the dimension of the kernel dim(ker(f )) is the same as the number of basic solutions of A, that is the number of columns without pivots in the echelon form of A. A. Kissinger Version: spring 2016 Matrix Calculations 41 / 43

We can learn a lot about a matrix......by looking at its columns. Suppose a linear map f is represented by a matrix A with columns {v 1,..., v n }: f (w) = v 1 v n w Then, dim(im(f )) is the dimension of the space spanned by {v 1,..., v n }...which is the same as the number of pivots in A A. Kissinger Version: spring 2016 Matrix Calculations 42 / 43

Kernel-image-dimension theorem (aka. rank-nullity) Theorem For a linear map f : V W one has: dim(ker(f )) + dim(im(f )) = dim(v ) Proof: Let A be a matrix that represents f. It has dim(v ) columns. dim(im(f )) of those are pivots, and the rest correspond to basic solutions to A x = 0, which give a basis for ker(f ). A. Kissinger Version: spring 2016 Matrix Calculations 43 / 43