1. Matrix Rank
Total Page:16
File Type:pdf, Size:1020Kb
L. Vandenberghe ECE133B (Spring 2020) 1. Matrix rank • subspaces, dimension, rank • QR factorization with pivoting • properties of matrix rank • low-rank matrices • pseudo-inverse 1.1 Subspace a nonempty subset V of Rm is a subspace if αx + βy 2 V for all vectors x; y 2 V and scalars α; β • all linear combinations of elements of V are in V • V is nonempty and closed under scalar multiplication and vector addition Examples • f0g, Rm • the span of a set S ⊆ Rm: all linear combinations of elements of S span¹Sº = fβ1a1 + ··· + βkak j a1;:::; ak 2 S; β1; : : : ; βk 2 Rg if S = fa1;:::; ang is a finite set, we write span¹Sº = span¹a1;:::; anº (the span of the empty set is defined as f0g) Matrix rank 1.2 Operations on subspaces three common operations on subspaces (V and W are subspaces) • intersection: V\W = fx j x 2 V; x 2 Wg • sum: V + W = fx + y j x 2 V; y 2 Wg if V\W = f0g this is called the direct sum and written as V ⊕ W • orthogonal complement: V? = fx j yT x = 0 for all y 2 Vg the result of each of the three operations is a subspace Matrix rank 1.3 Range of a matrix × T T suppose A is an m n matrix with columns a1;:::; an and rows b1;:::; bm: 2 bT 3 6 :1 7 A = a1 ··· an = 6 : 7 6 7 6 bT 7 4 m 5 Range (column space): the span of the column vectors (a subspace of Rm) range¹Aº = span¹a1;:::; anº n = fx1a1 + ··· + xnan j x 2 R g = fAx j x 2 Rng the range of AT is called the row space of A (a subspace of Rn): T range¹A º = span¹b1;:::; bmº m = fy1b1 + ··· + ymbm j y 2 R g = fAT y j y 2 Rmg Matrix rank 1.4 Nullspace of a matrix × T T suppose A is an m n matrix with columns a1;:::; an and rows b1;:::; bm: 2 bT 3 6 :1 7 A = a1 ··· an = 6 : 7 6 7 6 bT 7 4 m 5 Nullspace: the orthogonal complement of the row space (a subspace of Rn) null¹Aº = range¹ATº? n T T = fx 2 R j b1 x = ··· = bmx = 0g = fx 2 Rn j Ax = 0g the nullspace of AT is the orthogonal complement of range¹Aº (a subspace of Rm) null¹ATº = range¹Aº? m T T = fy 2 R j a1 y = ··· = an y = 0g = fy 2 Rm j AT y = 0g Matrix rank 1.5 Exercise • directed graph with m vertices, n arcs (directed edges) • node–arc incidence matrix is m × n matrix A with 8 1 if arc j enters node i ><> Aij = −1 if arc j leaves node i > 0 otherwise : 3 2 3 2 −1 −1 0 1 0 3 6 7 6 1 0 −1 0 0 7 1 4 5 A = 6 7 6 0 0 1 −1 −1 7 6 7 6 0 1 0 0 1 7 4 5 2 1 4 describe in words the subspaces null¹Aº and range¹ATº Matrix rank 1.6 Linearly independent vectors vectors a1,..., an are linearly independent if x1a1 + x2a2 + ··· + xnan = 0 =) x1 = x2 = ··· = xn = 0 • the zero vector cannot be written as a nontrivial linear combination of a1,..., an • no vector ai is a linear combination of the other vectors • in matrix–vector notation: Ax = 0 holds only if x = 0, where A = a1 a2 ··· an • linear (in)dependence is a property of the set of vectors fa1;:::; ang (by convention, the empty set is linearly independent) recall from 133A: if a1;:::; an are linearly independent m-vectors, then n ≤ m Matrix rank 1.7 Basis of a subspace fv1;:::; vk g is a basis for the subspace V if two conditions are satisfied 1. V = span¹v1;:::; vkº 2. v1,..., vk are linearly independent • condition 1 means that every x 2 V can be expressed as x = β1v1 + ··· + βkvk • condition 2 means that the coefficients β1,..., βk are unique: x = β1v1 + ··· + βkvk =) ¹β1 − γ1ºv1 + ··· + ¹βk − γkºvk = 0 x = γ1v1 + ··· + γkvk =) β1 = γ1; : : : ; βk = γk Matrix rank 1.8 Dimension of a subspace • every basis of a subspace V contains the same number of vectors • this number is called the dimension of V (notation: dim¹Vº) Proof: let fv1;:::; vk g be a basis of V containing k vectors and define B = v1 ··· vk • suppose a1;:::; an are linearly independent vectors in V • each ai can be expressed as a linear combination of the basis vectors: a1 = Bx1; a2 = Bx2;:::; an = Bxn • the k-vectors x1;:::; xn are linearly independent: β1x1 + ··· + βnxn = 0 =) B¹β1x1 + ··· + βnxnº = β1a1 + ··· + βnan = 0 =) β1 = ··· = βn = 0 • therefore n ≤ k; this shows that no basis can contain more than k vectors Matrix rank 1.9 Completing a basis • suppose fv1;:::; vj g ⊂ V is a linearly independent set (possibly empty) • then there exists a basis of V of the form fv1;:::; vj; vj+1;:::; vk g we complete the basis by adding the vectors vj+1,..., vk Proof • if fv1;:::; vj g is not already a basis, its span is not V • then there exist vectors in V that are not linear combinations of v1,..., vj • choose one of those vectors, call it vj+1, and add it to the set • the set fv1;:::; vj+1g is a linearly independent subset of V with j + 1 elements • repeat this process until it terminates • it terminates because a linearly independent set in Rm has at most m elements Consequence: every subspace of Rm has a basis Matrix rank 1.10 Rank of a matrix Rank: the rank of a matrix is the dimension of its range rank¹Aº = dim¹range¹Aºº this is also the maximal number of linearly independent columns Example: a 4 × 4 matrix with rank 3 2 1 −1 3 1 3 6 7 6 −1 2 0 0 7 A = a1 a2 a3 a4 = 6 7 6 1 −1 3 0 7 6 7 6 −1 2 0 1 7 4 5 • fa1g is linearly independent (a1 is not zero) • fa1; a2g is linearly independent • fa1; a2; a3g is linearly dependent: a3 = 6a1 + 3a2 • fa1; a2; a4g is a basis for range¹Aº: linearly independent and spans range¹Aº Matrix rank 1.11 Rank-r matrices in factored form we will often encounter matrices in the product form A = BC, where • B is m × r with linearly independent columns • C is r × n with linearly independent rows the matrix A has rank r • range¹Aº ⊆ range¹Bº: each column of A is a linear combination of columns of B • range¹Bº ⊆ range¹Aº: y = Bx =) y = B¹CDºx = A¹Dxº where D is a right inverse of C (for example, D = Cy) • therefore range¹Aº = range¹Bº and rank¹Aº = rank¹Bº • since the columns of B are linearly independent, rank¹Bº = r Matrix rank 1.12 Exercises Exercise 1 V and W are subspaces in Rm; show that dim¹V + Wº + dim¹V \ Wº = dim¹Vº + dim¹Wº Exercise 2 • A and B are matrices with the same number of rows; find a matrix C with range¹Cº = range¹Aº + range¹Bº • A and B are matrices with the same number of columns; find a matrix C with null¹Cº = null¹Aº \ null¹Bº Matrix rank 1.13 Outline • subspaces, dimension, rank • QR factorization with pivoting • properties of matrix rank • low-rank matrices • pseudo-inverse QR factorization A is an m × n matrix with linearly independent columns (hence, m ≥ n) QR factorization A = QR • R is n × n, upper triangular, with positive diagonal elements • Q is m × n with orthonormal columns (QTQ = I) • several algorithms, including Gram–Schmidt algorithm Full QR factorization (QR decomposition) R A = Q Q˜ 0 • R is n × n, upper triangular, with positive diagonal elements • Q Q˜ is orthogonal: square with orthonormal columns • several algorithms, including Householder triangularization Matrix rank 1.14 QR factorization with column pivoting A is an m × n matrix (may be wide or have linearly dependent columns) QR factorization with column pivoting (column reordering) A = QRP • Q is m × r with orthonormal columns • R is r × n, leading r × r submatrix is upper triangular with positive diagonal: 2 R11 R12 ··· R1r R1;r+1 ··· R1n 3 6 7 6 0 R22 ··· R2r R2;r+1 ··· R2n 7 R = 6 : : : : : : 7 6 : : : : : : : 7 6 7 6 0 0 ··· Rrr Rr;r+1 ··· Rrn 7 4 5 • can be chosen to satisfy R11 ≥ R22 ≥ · · · ≥ Rrr > 0 • P is an n × n permutation matrix • r is the rank of A: apply the result on page 1.27 with B = Q, C = RP Matrix rank 1.15 Interpretation • columns of APT = QR are the columns of A in a different order • the columns are divided in two groups: T AP = Aˆ1 Aˆ2 = Q R1 R2 Aˆ1 is m × r, R1 is r × r • Aˆ1 = QR1 is m × r with linearly independent columns: ˆ −1 T ˆ A1x = QR1x = 0 =) R1 Q A1x = x = 0 • Aˆ2 = QR2 is m × ¹n − rº: columns are linear combinations of columns of Aˆ1 ˆ ˆ −1 A2 = QR2 = A1R1 R2 the factorization provides two useful bases for range¹Aº • columns of Q are an orthonormal basis • columns of Aˆ1 are a basis selected from the columns of A Matrix rank 1.16 Computing the pivoted QR factorization we first describe the modified Gram–Schmidt algorithm • a variation of the standard Gram–Schmidt algorithm for QR factorization A = QR of a matrix A with linearly independent columns • has better numerical properties than the standard Gram–Schmidt algorithm we then extend the modified GS method to the pivoted QR factorization Matrix rank 1.17 Modified Gram–Schmidt algorithm computes QR factorization of an m × n matrix A with linearly independent columns 2 R11 R12 ··· R1n 3 6 7 6 0 R22 ··· R2n 7 a1 a2 ··· an = q1 q2 ··· qn 6 : : : : 7 6 : : : : : 7 6 7 6 0 0 ··· Rnn 7 4 5 • after k steps, the algorithm has computed a partial factorization 2 R ··· R R ··· R 3 6 11 1k 1;k+1 1n 7 6 : : : : : : : : : : 7 ··· 6 7 A = q1 qk Bk 6 0 ··· R R ··· R 7 6 kk k;k+1 kn 7 6 7 6 0 I 7 4 5 where Bk has size m × ¹n − kº with columns orthogonal to q1,..., qk • we start the algorithm with B0 = A Matrix rank 1.18 Modified Gram–Schmidt update careful inspection of the update at step k shows that " # Rkk Rk;¹k+1º:n Bk−1 = qk Bk 0 I partition Bk−1 as Bk−1 = b Bˆ with b the first column and Bˆ of size m × ¹n − kº: b = qk Rkk; Bˆ = qk Rk;¹k+1º:n + Bk • from the first equation, and the required properties kqk k = 1 and Rkk > 0: 1 Rkk = kbk; qk = b Rkk • T from the second equation, and the requirement that qk Bk = 0: T ˆ ˆ Rk;¹k+1º:n = qk B; Bk = B − qk Rk;¹k+1º:n Matrix rank 1.19 Summary: modified Gram–Schmidt algorithm Algorithm define B0 = A and repeat for k = 1 to n: • compute Rkk = kbk and qk = ¹1/Rkkºb where b is the first column of Bk−1 • compute T ˆ ˆ Rk;k+1 ··· Rkn = qk B; Bk = B −