Lec 6 Ginverse
Lec 6 Ginverse
Lec 6 Ginverse
• Pseudoinverse
Recall
... that a square matrix A ∈ Rn×n is invertible if there exists a square matrix
B of the same size such that
AB = BA = I
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 3/43
Generalized inverse and pseudoinverse
Remark. For any invertible matrix A ∈ Rn×n and any vector b ∈ Rn , the linear
system Ax = b has a unique solution x∗ = A−1 b.
A\b % recommended
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 4/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 5/43
Generalized inverse and pseudoinverse
More motivation
In many practical tasks such as multiple linear regression, the least squares
problem arises naturally:
If A has full column rank (i.e., rank(A) = n ≤ m), then the above problem has
a unique solution
x∗ = (AT A)−1 AT b
We want to better understand the matrices:
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 6/43
Generalized inverse and pseudoinverse
Generalized inverse
Def 0.1. Let A ∈ Rm×n be any matrix. We call the matrix G ∈ Rn×m a
generalized inverse of A if it satisfies
AGA = A
Remark. If A is square and invertible, then it has one and only one generalized
inverse which must coincide with the ordinary inverse A−1 . To see this, first
observe that A−1 apparently satisfies the definition and thus is a generalized
inverse. Conversely, if A has a generalized inverse G, then from the equation
AGA = A we get
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 7/43
Generalized inverse and pseudoinverse
Remark. For a general matrix A ∈ Rm×n , its generalized inverse always exists
but might not be unique.
1×2
" # example, let A = [1, 2] ∈ R . Its generalized inverse is a matrix G =
For
x
∈ R2×1 satisfying
y
" #
x
[1, 2] = A = AGA = [1, 2] [1, 2] = (x + 2y) · [1, 2].
y
" #
x
This shows that any G = ∈ R2×1 with x + 2y = 1 is a generalized inverse
y
" # " #
1 3
of A, e.g., G = or G = .
0 −1
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 8/43
Generalized inverse and pseudoinverse
The following theorem indicates a way to find the generalized inverse of any
matrix.
" #
A11 A12
Theorem 0.1. Let A = ∈ Rm×n be a matrix of rank r, and
A21 A22
" #
−1
A 11 O
A11 ∈ Rr×r . If A11 is invertible, then G = ∈ Rn×m is a generalized
O O
inverse of A.
Remark. Any matrix A ∈ Rm×n with rank r can be rearranged through row
and column permutations to have the above partitioned form with an invertible
r × r submatrix in the top-left corner. This theorem essentially establishes the
existence of a generalized inverse for any matrix.
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 9/43
Generalized inverse and pseudoinverse
Remark. We skip the proof but illustrate the theorem with an example:
1 2 3
A = 4 5 6
7 8 9
Since rank(A) = 2 and the top-left 2 × 2 block is invertible, we can easily find a
generalized inverse
− 53 2
3 0
G = 43 − 13 0
0 0 0
To verify:
1 2 3 −5 2
0 1 2 3 1 2 3
43 3
AGA = 4 5 6 3 − 13 0 4 5 6 = 4 5 6 = A
7 8 9 0 0 0 7 8 9 7 8 9
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 10/43
Generalized inverse and pseudoinverse
The generalized inverse can also be used to find a solution to a consistent linear
system (i.e., there exists at least a solution).
Theorem 0.2. Consider the linear system Ax = b. Suppose b ∈ Col(A) such that
the system is consistent. Let G be a generalized inverse of A, i.e., AGA = A.
Then x∗ = Gb is a particular solution to the system.
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 11/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 12/43
Generalized inverse and pseudoinverse
Projection matrices
Def 0.2. A square matrix P is called a projection matrix if P = P2 .
Example 0.2. The following are some projection matrices (but not all):
1 0 0 1 0 0
I, 0 1 0 , 0 0 0 , O
0 0 0 0 0 0
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 13/43
Generalized inverse and pseudoinverse
• A projection matrix keeps all points from its range (when applied to them)
in their original places. To see this, let v ∈ Range(P). Then there exists
some x ∈ Rn such that v = Px. It follows that
Pv = P(Px) = P2 x = Px = v.
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 14/43
Generalized inverse and pseudoinverse
(GA)(GA) = GA
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 15/43
Generalized inverse and pseudoinverse
Remark. AG and A must have the same column space. To see this,
(1) For any y ∈ Col(AG), there exists some x ∈ Rm such that y = (AG)x. It
follows that y = A(Gx) ∈ Col(A). This shows that Col(AG) ⊆ Col(A).
(2) For any y ∈ Col(A), there exists some x ∈ Rn such that y = Ax. Write
y = (AGA)x = (AG)(Ax). This shows that y ∈ Col(AG). Thus,
Col(A) ⊆ Col(AG).
Similarly, we can show that GA is a projection matrix onto the row space of A.
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 16/43
Generalized inverse and pseudoinverse
We have
1 2 3 − 53 2
3 0 1 0 0
AG = 4 5 6 43 − 13 0 = 0 1 0
7 8 9 0 0 0 −1 2 0
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 17/43
Generalized inverse and pseudoinverse
Pseudoinverse
Briefly speaking, the matrix pseudoinverse is a generalized inverse with more
constraints.
Def 0.3. Let A ∈ Rm×n . We call the matrix B ∈ Rn×m the pseudoinverse of
A if it satisfies all four conditions below:
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 18/43
Generalized inverse and pseudoinverse
Remark.
• It can be shown that for any matrix A ∈ Rm×n , the pseudoinverse always
exists and is unique. We denote the pseudoinverse of A as A† .
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 19/43
Generalized inverse and pseudoinverse
Example 0.4. Consider A = [1, 2] ∈ R1×2 again. We showed that any matrix
G = (x, y)T ∈ R2×1 with x + 2y = 1 is a generalized inverse of A:
" #
x
[1, 2] = A = AGA = [1, 2] [1, 2] = (x + 2y) · [1, 2].
y
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 20/43
Generalized inverse and pseudoinverse
Solving the two equations together gives that x = 15 , y = 25 . Thus, the pseudoin-
verse of A is h iT
A† = 15 52 .
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 21/43
Generalized inverse and pseudoinverse
GAG = G
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 22/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 23/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 24/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 25/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 26/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 27/43
Generalized inverse and pseudoinverse
Theorem 0.5. Let A ∈ Rm×n be any tall matrix with full column rank (i.e.,
rank(A) = n ≤ m). Then the pseudoinverse of A is
A† = (AT A)−1 AT .
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 28/43
Generalized inverse and pseudoinverse
Remark. The theorem implies that for any tall matrix A ∈ Rm×n with full column
rank (i.e., rank(A) = n ≤ m), the following is an orthogonal projection matrix
(onto the column space of A):
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 29/43
Generalized inverse and pseudoinverse
Solution: Observe that this matrix has full column rank (i.e., 2). We first
compute
! 1 −1 !
T 1 0 1 2 −1
X X= 0 1 =
−1 1 0 −1 2
1 0
It follows that
! ! !
† T −1 T 1 2 1 1 0 1 1 1 1 2
X = (X X) X = =
3 1 2 −1 1 0 3 −1 2 1
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 30/43
Generalized inverse and pseudoinverse
Theorem 0.6. Let A ∈ Rm×n be a diagonal matrix, i.e., all of its entries are zero
except some of those along its diagonal. Then the pseudoinverse of A is another
diagonal matrix B ∈ Rn×m such that
(
1
, if aii 6= 0
bii = aii
0, if aii = 0
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 31/43
Generalized inverse and pseudoinverse
Then
" # 0 0 0
0 0
AB = and BA = 0 1 0
0 1
0 0 0
both of which are symmetric. Furthermore,
" #" # " #
0 0 0 0 0 0 0 0
ABA = = =A
0 1 0 3 0 0 3 0
0 0 0 0 0 0 0
BAB = 0 1 0 0 31 = 0 13 = B.
0 0 0 0 0 0 0
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 32/43
Generalized inverse and pseudoinverse
Theorem 0.7. Let A ∈ Rm×n be any matrix. Suppose its full SVD is A = UΣVT .
Then the pseudoinverse of A is
A† = VΣ† UT
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 33/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 34/43
Generalized inverse and pseudoinverse
pinv(A, T OL) treats all singular values of A that are less than T OL as
zero. By default, T OL = max(size(A)) ∗ eps(norm(A)).
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 35/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 36/43
Generalized inverse and pseudoinverse
In general, a vector x that solves the system may not exist, or if one does exist,
it may not be unique.
In either case, we seek a least squares solution instead by solving the following
least squares problem
minn kAx − bk
x∈R
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 37/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 38/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 39/43
Generalized inverse and pseudoinverse
It follows that
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 40/43
Generalized inverse and pseudoinverse
Summary
• Generalized inverse G ∈ Rn×m for a matrix A ∈ Rm×n :
– Definition: AGA = A
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 41/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 42/43
Generalized inverse and pseudoinverse
Dr. Guangliang Chen | Mathematics & Statistics, San José State University 43/43