Chapter 6: Linear Transformations and Projections
Sections ΒΆ Summary ΒΆ A function T : R d β R n T: \mathbb{R}^d \to \mathbb{R}^n T : R d β R n is a linear transformation if it satisfies both properties:
T ( x β + y β ) = T ( x β ) + T ( y β ) T(\vec x + \vec y) = T(\vec x) + T(\vec y) T ( x + y β ) = T ( x ) + T ( y β ) T ( c x β ) = c T ( x β ) T(c\vec x) = cT(\vec x) T ( c x ) = c T ( x ) Matrix representation: every linear transformation has the form
T ( x β ) = A x β T(\vec x) = A\vec x T ( x ) = A x Linear transformations send 0 β \vec 0 0 to 0 β \vec 0 0 .
A x β + b β A\vec x + \vec b A x + b is affine ; it is not linear when b β β 0 β \vec b \ne \vec 0 b ξ = 0 .
A 2 Γ 2 2 \times 2 2 Γ 2 matrix maps the unit square to the parallelogram created by its columns. For example,
A = [ 2 1 1 2 ] A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} A = [ 2 1 β 1 2 β ] Composition: A B x β AB\vec x A B x applies B B B first, then A A A .
Counterclockwise rotation by ΞΈ \theta ΞΈ :
R ( ΞΈ ) = [ cos β‘ ΞΈ β sin β‘ ΞΈ sin β‘ ΞΈ cos β‘ ΞΈ ] R(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} R ( ΞΈ ) = [ cos ΞΈ sin ΞΈ β β sin ΞΈ cos ΞΈ β ] Determinant of a 2 Γ 2 2 \times 2 2 Γ 2 matrix:
det β‘ ( [ a b c d ] ) = β£ a b c d β£ = a d β b c \det\left(\begin{bmatrix} a & b \\ c & d \end{bmatrix}\right) = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc det ( [ a c β b d β ] ) = β£ β£ β a c β b d β β£ β£ β = a d β b c Determinant of a 3 Γ 3 3 \times 3 3 Γ 3 matrix:
det β‘ ( [ a b c d e f g h i ] ) = β£ a b c d e f g h i β£ \det\left(\begin{bmatrix} {\color{#3d81f6} a} & {\color{#3d81f6} b} & {\color{#3d81f6} c} \\ {\color{orange} d} & {\color{#d81a60}e } & {\color{#004d40}f } \\ {\color{orange} g} & {\color{#d81a60}h } & {\color{#004d40}i } \end{bmatrix}\right) = \begin{vmatrix} {\color{#3d81f6} a} & {\color{#3d81f6} b} & {\color{#3d81f6} c} \\ {\color{orange} d} & {\color{#d81a60}e } & {\color{#004d40}f } \\ {\color{orange} g} & {\color{#d81a60}h } & {\color{#004d40}i } \end{vmatrix} det β β β β£ β‘ β a d g β b e h β c f i β β¦ β€ β β β β = β£ β£ β a d g β b e h β c f i β β£ β£ β β£ a b c d e f g h i β£ = a β£ e f h i β£ β b β£ d f g i β£ + c β£ d e g h β£ \begin{vmatrix} {\color{#3d81f6} a} & {\color{#3d81f6} b} & {\color{#3d81f6} c} \\ {\color{orange} d} & {\color{#d81a60}e } & {\color{#004d40}f } \\ {\color{orange} g} & {\color{#d81a60}h } & {\color{#004d40}i } \end{vmatrix} = {\color{#3d81f6} a} \begin{vmatrix} {\color{#d81a60}e } & {\color{#004d40}f } \\ {\color{#d81a60}h } & {\color{#004d40}i } \end{vmatrix} - {\color{#3d81f6} b} \begin{vmatrix} {\color{orange} d} & {\color{#004d40}f } \\ {\color{orange} g} & {\color{#004d40}i } \end{vmatrix} + {\color{#3d81f6} c} \begin{vmatrix} {\color{orange} d} & {\color{#d81a60}e } \\ {\color{orange} g} & {\color{#d81a60}h } \end{vmatrix} β£ β£ β a d g β b e h β c f i β β£ β£ β = a β£ β£ β e h β f i β β£ β£ β β b β£ β£ β d g β f i β β£ β£ β + c β£ β£ β d g β e h β β£ β£ β Geometric interpretation: det β‘ ( A ) \det(A) det ( A ) is the signed area (volume) that the unit square (cube) maps to.
det β‘ ( A ) = 0 \det(A) = 0 det ( A ) = 0 iff the columns of A A A are dependent.
Determinant of a transpose:
det β‘ ( A T ) = det β‘ ( A ) \det(A^T) = \det(A) det ( A T ) = det ( A ) Determinant of a product:
det β‘ ( A B ) = det β‘ ( A ) det β‘ ( B ) \det(AB) = \det(A)\det(B) det ( A B ) = det ( A ) det ( B ) Scaling an n Γ n n \times n n Γ n matrix:
det β‘ ( c A ) = c n det β‘ ( A ) \det(cA) = c^n\det(A) det ( c A ) = c n det ( A ) Swapping two columns or two rows flips the sign of the determinant.
An orthogonal matrix Q Q Q has det β‘ ( Q ) = Β± 1 \det(Q) = \pm 1 det ( Q ) = Β± 1 .
6.2 Inverses ΒΆ Inverse: for a square matrix A A A , its inverse satisfies
A A β 1 = A β 1 A = I AA^{-1} = A^{-1}A = I A A β 1 = A β 1 A = I For an n Γ n n \times n n Γ n matrix A A A , the following are equivalent:
A A A is invertible.
rank ( A ) = n \text{rank}(A) = n rank ( A ) = n .
The columns (and rows) of A A A are linearly independent.
nullsp ( A ) = { 0 β } \text{nullsp}(A) = \{\vec 0\} nullsp ( A ) = { 0 } .
det β‘ ( A ) β 0 \det(A) \ne 0 det ( A ) ξ = 0 .
A x β = b β A\vec x = \vec b A x = b has exactly one solution for every b β β R n \vec b \in \mathbb{R}^n b β R n .
Inverse of a 2 Γ 2 2 \times 2 2 Γ 2 matrix , when a d β b c β 0 ad - bc \ne 0 a d β b c ξ = 0 :
[ a b c d ] β 1 = 1 a d β b c [ d β b β c a ] \begin{bmatrix} a & b \\ c & d \end{bmatrix}^{-1} = \frac{1}{ad - bc}\begin{bmatrix} d & -b \\ -c & a \end{bmatrix} [ a c β b d β ] β 1 = a d β b c 1 β [ d β c β β b a β ] Inverse of a product: the order reverses.
( A B ) β 1 = B β 1 A β 1 (AB)^{-1} = B^{-1}A^{-1} ( A B ) β 1 = B β 1 A β 1 Inverse of a transpose:
( A T ) β 1 = ( A β 1 ) T (A^T)^{-1} = (A^{-1})^T ( A T ) β 1 = ( A β 1 ) T Inverse of an orthogonal matrix: since Q T Q = Q Q T = I Q^TQ = QQ^T = I Q T Q = Q Q T = I ,
Q β 1 = Q T Q^{-1} = Q^T Q β 1 = Q T Because rank ( X T X ) = rank ( X ) \text{rank}(X^TX) = \text{rank}(X) rank ( X T X ) = rank ( X ) , for the d Γ d d \times d d Γ d matrix X T X X^TX X T X to be invertible we need rank ( X T X ) = d \text{rank}(X^TX) = d rank ( X T X ) = d , meaning rank ( X ) = d \text{rank}(X) = d rank ( X ) = d , meaning all d d d of X X X βs columns are linearly independent.
6.3 Projecting onto the Column Space ΒΆ For X β R n Γ d X \in \mathbb{R}^{n \times d} X β R n Γ d and y β β R n \vec y \in \mathbb{R}^n y β β R n , the w β \vec w w that minimizes β₯ y β β X w β β₯ 2 \lVert \vec y - X\vec w \rVert^2 β₯ y β β X w β₯ 2 makes the error vector orthogonal to colsp ( X ) \text{colsp}(X) colsp ( X ) .
Error vector:
e β = y β β X w β β \vec e = \vec y - X\vec w^* e = y β β X w β Orthogonality condition:
X T e β = 0 β X^T\vec e = \vec 0 X T e = 0 Normal equations: a system of d d d equations in d d d unknowns (the entries of w β β \vec w^* w β ).
X T X w β β = X T y β X^TX\vec w^* = X^T\vec y X T X w β = X T y β Unique solution , when rank ( X ) = d \text{rank}(X) = d rank ( X ) = d :
w β β = ( X T X ) β 1 X T y β \vec w^* = (X^TX)^{-1}X^T\vec y w β = ( X T X ) β 1 X T y β Projection of y β \vec y y β onto colsp ( X ) \text{colsp}(X) colsp ( X ) :
p β = X w β β \vec p = X\vec w^* p β = X w β The error vector belongs to nullsp ( X T ) \text{nullsp}(X^T) nullsp ( X T ) .
If 1 β β colsp ( X ) \vec 1 \in \text{colsp}(X) 1 β colsp ( X ) , the errors sum to 0.
6.4 The Complete Solution to the Normal Equations ΒΆ The normal equations always have at least one solution; they may have exactly one solution or infinitely many.
Complete solution: when X X X has linearly dependent columns, there are infinitely many solutions to X T X w β β = X T y β X^TX\vec w^* = X^T\vec y X T X w β = X T y β , all with the same p β \vec p p β :
w β = w β s + n β , n β β nullsp ( X ) \vec w = \vec w_s + \vec n, \qquad \vec n \in \text{nullsp}(X) w = w s β + n , n β nullsp ( X ) To find one solution w β s \vec w_s w s β , solve without the dependent columns, then put 0 in their slots.
Projection matrix:
With linearly independent columns, the n Γ n n \times n n Γ n matrix is
P = X ( X T X ) β 1 X T P = X(X^TX)^{-1}X^T P = X ( X T X ) β 1 X T Applying the projection matrix:
p β = P y β \vec p = P\vec y p β = P y β Symmetry: P T = P P^T = P P T = P .
Idempotence: P 2 = P P^2 = P P 2 = P .
Projection preserves the columns of X X X : P X = X PX = X PX = X .
Rank: rank ( P ) = rank ( X ) \text{rank}(P) = \text{rank}(X) rank ( P ) = rank ( X ) .
A projection matrix is invertible only when P = I P = I P = I .
Rotation matrices are orthogonal and have determinant 1.
Reflection across the hyperplane normal to a unit vector u β \vec u u : the matrix is orthogonal and has determinant -1.
I β 2 u β u β T I - 2\vec u\vec u^T I β 2 u u T 6.5 The Gram-Schmidt Process ΒΆ Gram-Schmidt turns linearly independent vectors into orthonormal vectors with the same span.
Remove projections onto the previously constructed vectors:
Q β i = v β i β β j = 1 i β 1 v β i β
Q β j Q β j β
Q β j β Q β j \vec Q_i = \vec v_i - \sum_{j=1}^{i-1} \frac{\vec v_i \cdot \vec Q_j}{\vec Q_j \cdot \vec Q_j}\,\vec Q_j Q β i β = v i β β j = 1 β i β 1 β Q β j β β
Q β j β v i β β
Q β j β β Q β j β Project onto the new Q β j \vec Q_j Q β j β βs.
Normalize:
q β i = Q β i β₯ Q β i β₯ \vec q_i = \frac{\vec Q_i}{\lVert \vec Q_i \rVert} q β i β = β₯ Q β i β β₯ Q β i β β With the q β i \vec q_i q β i β βs as columns, Q Q Q has orthonormal columns : Q T Q = I Q^TQ = I Q T Q = I .
If X X X has orthonormal columns, the normal equations X T X w β β = X T y β X^TX\vec w^* = X^T\vec y X T X w β = X T y β reduce to
w β β = X T y β \vec w^* = X^T\vec y w β = X T y β