Difference between revisions of "Matrix Algebra and Matrix Multiplication"
(Created page with "==Matrix Operations== ===Adding and subtracting matrices=== In order to add or subtract two matrices, they must be of the same dimension; that is, the two matrices must have t...") |
|||
(14 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
a_{21} + b_{21} & a_{22} + b_{22} & a_{23} + b_{23}\\ | a_{21} + b_{21} & a_{22} + b_{22} & a_{23} + b_{23}\\ | ||
a_{31} + b_{31} & a_{32} + b_{32} & a_{33} + b_{33} | a_{31} + b_{31} & a_{32} + b_{32} & a_{33} + b_{33} | ||
+ | \end{bmatrix} | ||
+ | </math> | ||
+ | |||
+ | |||
+ | <math>\begin{bmatrix} | ||
+ | 1 & 2 & 3\\ | ||
+ | 0 & 1 & 2\\ | ||
+ | 0 & 0 & 1 | ||
+ | \end{bmatrix} + | ||
+ | \begin{bmatrix} | ||
+ | 5 & 2 & 1\\ | ||
+ | 3 & 3 & 1\\ | ||
+ | 4 & 2 & 0 | ||
+ | \end{bmatrix} = | ||
+ | \begin{bmatrix} | ||
+ | 1 + 5 & 2 + 2 & 3 + 1\\ | ||
+ | 0 + 3 & 1 + 3 & 2 + 1\\ | ||
+ | 0 + 4 & 0 + 2 & 1 + 0 | ||
+ | \end{bmatrix} = | ||
+ | \begin{bmatrix} | ||
+ | 6 & 4 & 4\\ | ||
+ | 3 & 4 & 3\\ | ||
+ | 4 & 2 & 1 | ||
\end{bmatrix} | \end{bmatrix} | ||
</math> | </math> | ||
===Multiplying matrices by scalars=== | ===Multiplying matrices by scalars=== | ||
+ | When multiplying a matrix by a scalar (or number), all we need to do is multiply each entry of the matrix by the scalar. For example: | ||
+ | |||
+ | <math>3\begin{bmatrix} | ||
+ | 1 & 2 & 3\\ | ||
+ | 0 & 1 & 2\\ | ||
+ | 0 & 0 & 1 | ||
+ | \end{bmatrix} = | ||
+ | \begin{bmatrix} | ||
+ | 3 & 6 & 9\\ | ||
+ | 0 & 3 & 6\\ | ||
+ | 0 & 0 & 3 | ||
+ | \end{bmatrix} | ||
+ | </math> | ||
+ | |||
+ | <math>-\frac{1}{2}\begin{bmatrix} | ||
+ | 2 & -4 & 8\\ | ||
+ | -2 & 1 & -6\\ | ||
+ | 0 & 0 & 7 | ||
+ | \end{bmatrix} = | ||
+ | \begin{bmatrix} | ||
+ | -1 & 2 & -4\\ | ||
+ | 1 & -\frac{1}{2} & 3\\ | ||
+ | 0 & 0 & -\frac{7}{2} | ||
+ | \end{bmatrix} | ||
+ | </math> | ||
===Multiplying matrices=== | ===Multiplying matrices=== | ||
+ | Matrix multiplication is not commutative; that is, for most matrices <math> A </math> and <math> B </math>, <math> AB \neq BA </math>. Two matrices can only be multiplied together if the number of columns in the first matrix equals the number of rows in the second matrix. For example, we can take the product of a 3-by-2 matrix times a 2-by-5 matrix, but not a 3-by-2 matrix times a 3-by-2 matrix. The product of two matrices has the same number of rows as the first matrix and the same number of columns as the second matrix. For example, a 2-by-3 matrix times a 3-by-2 matrix will result in a 2-by-2 matrix. | ||
+ | |||
+ | The product of two 3-by-3 matrices is | ||
+ | <math>\begin{bmatrix} | ||
+ | a_{11} & a_{12} & a_{13}\\ | ||
+ | a_{21} & a_{22} & a_{23}\\ | ||
+ | a_{31} & a_{32} & a_{33} | ||
+ | \end{bmatrix} | ||
+ | \begin{bmatrix} | ||
+ | b_{11} & b_{12} & b_{13}\\ | ||
+ | b_{21} & b_{22} & b_{23}\\ | ||
+ | b_{31} & b_{32} & b_{33} | ||
+ | \end{bmatrix} = | ||
+ | \begin{bmatrix} | ||
+ | c_{11} & c_{12} & c_{13}\\ | ||
+ | c_{21} & c_{22} & c_{23}\\ | ||
+ | c_{31} & c_{32} & c_{33} | ||
+ | \end{bmatrix} | ||
+ | </math> | ||
+ | |||
+ | where <math>c_{ij}</math> is the dot product of the i-th row of the first matrix and the j-th column of the second matrix; that is, <math>c_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + a_{i3}b_{3j}</math>. | ||
+ | |||
+ | Here is a 2-by-2 example of matrix multiplication: | ||
+ | |||
+ | <math>\begin{bmatrix} | ||
+ | 1 & 2\\ | ||
+ | 3 & 4 | ||
+ | \end{bmatrix} | ||
+ | \begin{bmatrix} | ||
+ | 5 & 6\\ | ||
+ | 7 & 8 | ||
+ | \end{bmatrix} = | ||
+ | \begin{bmatrix} | ||
+ | 1(5) + 2(7) & 1(6) + 2(8)\\ | ||
+ | 3(5) + 4(7) & 3(6) + 4(8) | ||
+ | \end{bmatrix} = | ||
+ | \begin{bmatrix} | ||
+ | 5 + 14 & 6 + 16\\ | ||
+ | 15 + 28 & 18 + 32 | ||
+ | \end{bmatrix} | ||
+ | \begin{bmatrix} | ||
+ | 19 & 22\\ | ||
+ | 43 & 50 | ||
+ | \end{bmatrix} | ||
+ | </math> | ||
+ | |||
+ | Note that there is no "matrix division". Rather, we multiply one matrix by the inverse of another (for example, <math> AB^{-1} </math>, NOT <math> A/B </math>) to obtain a "quotient" from two matrices. | ||
+ | |||
+ | ==Inverse of an n-by-n matrix== | ||
+ | An n-by-n matrix A is the inverse of n-by-n matrix B (and B the inverse of A) if BA = AB = I, | ||
+ | where I is an identity matrix. | ||
+ | |||
+ | The inverse of an n-by-n matrix can be calculated by creating an n-by-2n matrix which has the original matrix on the left and the identity matrix on the right. Row reduce this matrix and the right half will be the inverse. If the matrix does not row reduce completely (i.e., a row is formed with all zeroes as its entries), it does not have an inverse. | ||
+ | |||
+ | === Example 1=== | ||
+ | Let <math> \mathrm{A} = \begin{bmatrix} | ||
+ | 1 & 4 & 4\\ | ||
+ | 2 & 5 & 8\\ | ||
+ | 3 & 6 & 9 | ||
+ | \end{bmatrix}</math> | ||
+ | |||
+ | We begin by expanding and partitioning A to include the identity matrix, and then proceed to row reduce A until we reach the identity matrix on the left-hand side. | ||
+ | |||
+ | :<math> | ||
+ | \begin{bmatrix} | ||
+ | 1 & 4 & 4 & \big| & 1 & 0 &0\\ | ||
+ | 2 & 5 & 8 & \big| & 0 & 1 &0\\ | ||
+ | 3 & 6 & 9 & \big| & 0 & 0 &1 | ||
+ | \end{bmatrix} | ||
+ | |||
+ | \rightsquigarrow | ||
+ | |||
+ | \begin{bmatrix} | ||
+ | 1 & 4 & 4 & \big| & 1 & 0 &0\\ | ||
+ | 0 & -3 & 0 & \big| & -2 & 1 &0\\ | ||
+ | 0 & -6 & -3 & \big| & -3 & 0 &1 | ||
+ | \end{bmatrix} | ||
+ | |||
+ | \rightsquigarrow | ||
+ | |||
+ | \begin{bmatrix} | ||
+ | 1 & 4 & 4 & \big| & 1 & 0 &0\\ | ||
+ | 0 & 1 & 0 & \big| & 2/3 & -1/3 &0\\ | ||
+ | 0 & -6 & -3 & \big| & -3 & 0 &1 | ||
+ | \end{bmatrix} | ||
+ | |||
+ | \rightsquigarrow | ||
+ | |||
+ | </math> | ||
+ | |||
+ | |||
+ | :<math> | ||
+ | |||
+ | \begin{bmatrix} | ||
+ | 1 & 0 & 4 & \big| & -5/3 & 4/3 &0\\ | ||
+ | 0 & 1 & 0 & \big| & 2/3 & -1/3 &0\\ | ||
+ | 0 & 0 & -3 & \big| & 1 & -2 &1 | ||
+ | \end{bmatrix} | ||
+ | |||
+ | \rightsquigarrow | ||
+ | |||
+ | \begin{bmatrix} | ||
+ | 1 & 0 & 4 & \big| & -5/3 & 4/3 &0\\ | ||
+ | 0 & 1 & 0 & \big| & 2/3 & -1/3 &0\\ | ||
+ | 0 & 0 & 1 & \big| & -1/3 & 2/3 &-1/3 | ||
+ | \end{bmatrix} | ||
+ | |||
+ | \rightsquigarrow | ||
+ | |||
+ | \begin{bmatrix} | ||
+ | 1 & 0 & 0 & \big| & -1/3 & -4/3 &4/3\\ | ||
+ | 0 & 1 & 0 & \big| & 2/3 & -1/3 &0\\ | ||
+ | 0 & 0 & 1 & \big| & -1/3 & 2/3 &-1/3 | ||
+ | \end{bmatrix} | ||
+ | |||
+ | |||
+ | </math> | ||
+ | <br><br> | ||
+ | The matrix <math> \mathrm{B} = \begin{bmatrix} | ||
+ | -1/3 & -4/3 & 4/3\\ | ||
+ | 2/3 & -1/3 & 0\\ | ||
+ | -1/3 & 2/3 & -1/3 | ||
+ | \end{bmatrix} | ||
+ | </math> is then the inverse of the original matrix A. | ||
+ | |||
+ | |||
+ | ==Inverse of a Linear Transformation== | ||
+ | We now consider how to represent the inverse of a linear map. We start by recalling some facts about function | ||
+ | inverses. Some functions have no inverse, or have an inverse on the left side | ||
+ | or right side only. | ||
+ | |||
+ | ===Definitions=== | ||
+ | Where | ||
+ | <math> \pi:\mathbb{R}^3\to \mathbb{R}^2 </math> is the projection map | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} x \\ y \\ z \end{pmatrix} | ||
+ | \mapsto | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | and <math> \eta:\mathbb{R}^2\to \mathbb{R}^3 </math> is the embedding | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | \mapsto | ||
+ | \begin{pmatrix} x \\ y \\ 0 \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | the composition <math>\pi\circ \eta</math> is the identity map on <math>\mathbb{R}^2</math>. | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | \stackrel{\eta}{\longmapsto} | ||
+ | \begin{pmatrix} x \\ y \\ 0 \end{pmatrix} | ||
+ | \stackrel{\pi}{\longmapsto} | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | We say <math>\pi</math> is a '''left inverse map''' | ||
+ | of <math>\eta</math> or, what is the same thing, | ||
+ | that <math>\eta</math> is a '''right inverse map''' | ||
+ | of <math>\pi</math>. | ||
+ | However, composition in the other order <math>\eta\circ \pi</math> | ||
+ | doesn't give the identity map— here is a vector that is not | ||
+ | sent to itself under <math>\eta\circ \pi</math>. | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix} | ||
+ | \stackrel{\pi}{\longmapsto} | ||
+ | \begin{pmatrix} 0 \\ 0 \end{pmatrix} | ||
+ | \stackrel{\eta}{\longmapsto} | ||
+ | \begin{pmatrix} 0 \\ 0 \\ 0 \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | In fact, the projection | ||
+ | <math>\pi</math> has no left inverse at all. | ||
+ | For, if <math>f</math> were to be a left inverse of <math>\pi</math> | ||
+ | then we would have | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} x \\ y \\ z \end{pmatrix} | ||
+ | \stackrel{\pi}{\longmapsto} | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | \stackrel{f}{\longmapsto} | ||
+ | \begin{pmatrix} x \\ y \\ z \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | for all of the infinitely many <math>z</math>'s. But no function <math>f</math> can send a single argument to more than one value. | ||
+ | |||
+ | (An example of a function with no inverse on either side | ||
+ | is the zero transformation on <math>\mathbb{R}^2</math>.) | ||
+ | |||
+ | Some functions have a '''two-sided inverse map''', another function that is the inverse of the first, both from the left and from the right. For instance, the map given by <math>\vec{v}\mapsto 2\cdot \vec{v}</math> has the two-sided inverse <math>\vec{v}\mapsto (1/2)\cdot\vec{v}</math>. | ||
+ | In this subsection we will focus on two-sided inverses. The appendix shows that a function has a two-sided inverse if and only if it is both one-to-one and onto. The appendix also shows that if a function <math>f</math> has a two-sided inverse then it is unique, and so it is called "the" inverse, and is denoted <math>f^{-1}</math>. So our purpose in this subsection is, where a linear map <math>h</math> has an inverse, to find the relationship between <math>{\rm Rep}_{B,D}(h)</math> and <math>{\rm Rep}_{D,B}(h^{-1})</math>. | ||
+ | |||
+ | A matrix <math> G </math> is a '''left inverse matrix''' of the matrix <math> H </math> if <math> GH </math> is the identity matrix. It is a '''right inverse matrix''' if <math> HG </math> is the identity. A matrix <math>H</math> with a two-sided inverse is an '''invertible matrix'''. That two-sided inverse is called '''the inverse matrix''' and is denoted <math> H^{-1} </math>. | ||
+ | |||
+ | Because of the correspondence between linear maps and matrices, statements about map inverses translate into statements about matrix inverses. | ||
+ | |||
+ | ===Lemmas and Theorems=== | ||
+ | * If a matrix has both a left inverse and a right inverse then the two are equal. | ||
+ | |||
+ | * A matrix is invertible if and only if it is nonsingular. | ||
+ | ** Proof: ''(For both results.)'' Given a matrix <math>H</math>, fix spaces of appropriate dimension for the domain and codomain. Fix bases for these spaces. With respect to these bases, <math>H</math> represents a map <math>h</math>. The statements are true about the map and therefore they are true about the matrix. | ||
+ | |||
+ | * A product of invertible matrices is invertible— if <math> G </math> and <math> H </math> are invertible and if <math> GH </math> is defined then <math> GH </math> is invertible and <math> (GH)^{-1}=H^{-1}G^{-1} </math>. | ||
+ | ** Proof: ''(This is just like the prior proof except that it requires two maps.)'' Fix appropriate spaces and bases and consider the represented maps <math> h </math> and <math> g </math>. Note that <math> h^{-1}g^{-1} </math> is a two-sided map inverse of <math> gh </math> since <math> (h^{-1}g^{-1})(gh) = h^{-1}(\mbox{id})h = h^{-1}h =\mbox{id} </math> and <math> (gh)(h^{-1}g^{-1}) = g(\mbox{id})g^{-1} = gg^{-1} = \mbox{id} </math>. This equality is reflected in the matrices representing the maps, as required. | ||
+ | |||
+ | |||
+ | Here is the arrow diagram giving the relationship | ||
+ | between map inverses and matrix inverses. | ||
+ | It is a special case | ||
+ | of the diagram for function composition and matrix multiplication. | ||
+ | |||
+ | <center> | ||
+ | [[Image:Linalg_matinv_arrow.png|x200px]] | ||
+ | </center> | ||
+ | |||
+ | Beyond its place in our general program of | ||
+ | seeing how to represent map operations, | ||
+ | another reason for our interest in inverses comes from solving | ||
+ | linear systems. | ||
+ | A linear system is equivalent to a matrix equation, as here. | ||
+ | |||
+ | :<math> | ||
+ | \begin{array}{*{2}{rc}r} | ||
+ | x_1 &+ &x_2 &= &3 \\ | ||
+ | 2x_1 &- &x_2 &= &2 | ||
+ | \end{array} | ||
+ | \quad\Longleftrightarrow\quad | ||
+ | \begin{pmatrix} | ||
+ | 1 &1 \\ | ||
+ | 2 &-1 | ||
+ | \end{pmatrix} | ||
+ | \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} | ||
+ | = | ||
+ | \begin{pmatrix} 3 \\ 2 \end{pmatrix} | ||
+ | \qquad\qquad (*)</math> | ||
+ | |||
+ | By fixing spaces and bases (e.g., <math>\mathbb{R}^2, \mathbb{R}^2 </math> and <math>\mathcal{E}_2,\mathcal{E}_2</math>), | ||
+ | we take the matrix <math>H</math> to represent some map <math>h</math>. | ||
+ | Then solving the system is the same as | ||
+ | asking: what domain vector <math>\vec{x}</math> is mapped by <math>h</math> to the result | ||
+ | <math>\vec{d}\,</math>? | ||
+ | If we could invert <math>h</math> then we could solve the system | ||
+ | by multiplying <math>{\rm Rep}_{D,B}(h^{-1})\cdot{\rm Rep}_{D}(\vec{d})</math> | ||
+ | to get <math>{\rm Rep}_{B}(\vec{x})</math>. | ||
+ | |||
+ | ===Example 2=== | ||
+ | We can find a left inverse for the matrix just given | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} | ||
+ | m &n \\ | ||
+ | p &q | ||
+ | \end{pmatrix} | ||
+ | \begin{pmatrix} | ||
+ | 1 &1 \\ | ||
+ | 2 &-1 | ||
+ | \end{pmatrix} | ||
+ | = | ||
+ | \begin{pmatrix} | ||
+ | 1 &0 \\ | ||
+ | 0 &1 | ||
+ | \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | by using Gauss' method to solve the resulting linear system. | ||
+ | |||
+ | :<math> | ||
+ | \begin{array}{*{4}{rc}r} | ||
+ | m &+ &2n & & & & &= &1 \\ | ||
+ | m &- &n & & & & &= &0 \\ | ||
+ | & & & &p &+ &2q &= &0 \\ | ||
+ | & & & &p &- &q &= &1 | ||
+ | \end{array} | ||
+ | </math> | ||
+ | |||
+ | Answer: <math> m=1/3 </math>, <math> n=1/3 </math>, <math> p=2/3 </math>, and <math> q=-1/3 </math>. | ||
+ | This matrix is actually the two-sided inverse of <math>H</math>, | ||
+ | as can easily be checked. | ||
+ | With it we can solve the system (<math>*</math>) above by | ||
+ | applying the inverse. | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | =\begin{pmatrix} | ||
+ | 1/3 &1/3 \\ | ||
+ | 2/3 &-1/3 | ||
+ | \end{pmatrix} | ||
+ | \begin{pmatrix} 3 \\ 2 \end{pmatrix} | ||
+ | =\begin{pmatrix} 5/3 \\ 4/3 \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | |||
+ | ====Remark==== | ||
+ | Why solve systems this way, when Gauss' method takes less arithmetic (this assertion can be made precise by counting the number of arithmetic operations, as computer algorithm designers do)? Beyond its conceptual appeal of fitting into our program of discovering how to represent the various map operations, solving linear systems by using the matrix inverse has at least two advantages. | ||
+ | |||
+ | First, once the work of finding an inverse has been done, solving a system with the same coefficients but different constants is easy and fast: if we change the entries on the right of the system (<math>*</math>) then we get a related problem | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} | ||
+ | 1 &1 \\ | ||
+ | 2 &-1 | ||
+ | \end{pmatrix} | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | = | ||
+ | \begin{pmatrix} 5 \\ 1 \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | with a related solution method. | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} x \\ y \end{pmatrix} | ||
+ | = | ||
+ | \begin{pmatrix} | ||
+ | 1/3 &1/3 \\ | ||
+ | 2/3 &-1/3 | ||
+ | \end{pmatrix} | ||
+ | \begin{pmatrix} 5 \\ 1 \end{pmatrix} | ||
+ | = | ||
+ | \begin{pmatrix} 2 \\ 3 \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | In applications, solving many systems having the same matrix of | ||
+ | coefficients is common. | ||
+ | |||
+ | Another advantage of inverses is that we can | ||
+ | explore a system's sensitivity to changes in the constants. | ||
+ | For example, tweaking the <math>3</math> on the right of the system (<math>*</math>) to | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} | ||
+ | 1 &1 \\ | ||
+ | 2 &-1 | ||
+ | \end{pmatrix} | ||
+ | \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} | ||
+ | = | ||
+ | \begin{pmatrix} 3.01 \\ 2 \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | can be solved with the inverse. | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} | ||
+ | 1/3 &1/3 \\ | ||
+ | 2/3 &-1/3 | ||
+ | \end{pmatrix} | ||
+ | \begin{pmatrix} 3.01 \\ 2 \end{pmatrix} | ||
+ | = | ||
+ | \begin{pmatrix} (1/3)(3.01)+(1/3)(2) \\ (2/3)(3.01)-(1/3)(2) \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | to show that <math> x_1 </math> changes by <math> 1/3 </math> of the tweak while <math> x_2 </math> moves by <math> 2/3 </math> of that tweak. This sort of analysis is used, for example, to decide how accurately data must be specified in a linear model to ensure that the solution has a desired accuracy. | ||
+ | }} | ||
+ | |||
+ | We finish by describing the computational procedure | ||
+ | usually used to find the inverse matrix. | ||
+ | |||
+ | * A matrix is invertible if and only if it can be written as the product of elementary reduction matrices. The inverse can be computed by applying to the identity matrix the same row steps, in the same order, as are used to Gauss-Jordan reduce the invertible matrix. | ||
+ | ** Proof: A matrix <math>H</math> is invertible if and only if it is nonsingular and thus Gauss-Jordan reduces to the identity. This reduction can be done with elementary matrices | ||
+ | :::<math> R_{r}\cdot R_{r-1}\cdot\dots R_{1}\cdot H=I </math>. | ||
+ | :::This equation gives the two halves of the result. | ||
+ | |||
+ | :::First, elementary matrices are invertible and their inverses are also elementary. Applying <math>R_r^{-1}</math> to the left of both sides of that equation, then <math>R_{r-1}^{-1}</math>, etc., gives <math>H</math> as the product of elementary matrices <math>H=R_1^{-1}\cdots R_r^{-1}\cdot I</math> (the <math>I</math> is here to cover the trivial <math>r=0</math> case). | ||
+ | |||
+ | :::Second, matrix inverses are unique and so comparison of the above equation with <math>H^{-1}H=I</math> shows that <math>H^{-1}=R_r\cdot R_{r-1}\dots R_1\cdot I</math>. Therefore, applying <math>R_1</math> to the identity, followed by <math>R_2</math>, etc., yields the inverse of <math>H</math>. | ||
+ | |||
+ | ===Example 3=== | ||
+ | To find the inverse of | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} | ||
+ | 1 & 1 \\ | ||
+ | 2 & -1 | ||
+ | \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | we do Gauss-Jordan reduction, meanwhile performing the same operations on | ||
+ | the identity. | ||
+ | For clerical convenience we write the matrix and the identity side-by-side, | ||
+ | and do the reduction steps together. | ||
+ | |||
+ | :<math>\begin{array}{rcl} | ||
+ | \left(\begin{array}{cc|cc} | ||
+ | 1 &1 &1 &0 \\ | ||
+ | 2 &-1 &0 &1 | ||
+ | \end{array}\right) | ||
+ | &\xrightarrow[]{-2\rho_1+\rho_2} | ||
+ | &\left(\begin{array}{cc|cc} | ||
+ | 1 &1 &1 &0 \\ | ||
+ | 0 &-3 &-2 &1 | ||
+ | \end{array}\right) \\ | ||
+ | &\xrightarrow[]{-1/3\rho_2} | ||
+ | &\left(\begin{array}{cc|cc} | ||
+ | 1 &1 &1 &0 \\ | ||
+ | 0 &1 &2/3 &-1/3 | ||
+ | \end{array}\right) \\ | ||
+ | &\xrightarrow[]{-\rho_2+\rho_1} | ||
+ | &\left(\begin{array}{cc|cc} | ||
+ | 1 &0 &1/3 &1/3 \\ | ||
+ | 0 &1 &2/3 &-1/3 | ||
+ | \end{array}\right) | ||
+ | \end{array} | ||
+ | </math> | ||
+ | This calculation has found the inverse. | ||
+ | |||
+ | :<math> | ||
+ | \begin{pmatrix} | ||
+ | 1 & 1 \\ | ||
+ | 2 & -1 | ||
+ | \end{pmatrix}^{-1} | ||
+ | = | ||
+ | \begin{pmatrix} | ||
+ | 1/3 &1/3 \\ | ||
+ | 2/3 &-1/3 | ||
+ | \end{pmatrix} | ||
+ | </math> | ||
+ | |||
+ | ===Example 4=== | ||
+ | This one happens to start with a row swap. | ||
+ | |||
+ | :<math>\begin{array}{rcl} | ||
+ | \left(\begin{array}{ccc|ccc} | ||
+ | 0 &3 &-1 &1 &0 &0 \\ | ||
+ | 1 &0 &1 &0 &1 &0 \\ | ||
+ | 1 &-1 &0 &0 &0 &1 | ||
+ | \end{array}\right) | ||
+ | &\xrightarrow[]{\rho_1\leftrightarrow\rho_2} | ||
+ | & \left(\begin{array}{ccc|ccc} | ||
+ | 1 &0 &1 &0 &1 &0 \\ | ||
+ | 0 &3 &-1 &1 &0 &0 \\ | ||
+ | 1 &-1 &0 &0 &0 &1 | ||
+ | \end{array}\right) \\ | ||
+ | &\xrightarrow[]{-\rho_1+\rho_3} | ||
+ | & \left(\begin{array}{ccc|ccc} | ||
+ | 1 &0 &1 &0 &1 &0 \\ | ||
+ | 0 &3 &-1 &1 &0 &0 \\ | ||
+ | 0 &-1 &-1 &0 &-1 &1 | ||
+ | \end{array}\right) \\ | ||
+ | &\vdots \\ | ||
+ | &\xrightarrow[]{} | ||
+ | & \left(\begin{array}{ccc|ccc} | ||
+ | 1 &0 &0 &1/4 &1/4 &3/4 \\ | ||
+ | 0 &1 &0 &1/4 &1/4 &-1/4 \\ | ||
+ | 0 &0 &1 &-1/4 &3/4 &-3/4 | ||
+ | \end{array}\right) | ||
+ | \end{array} | ||
+ | </math> | ||
+ | |||
+ | ===Example 5=== | ||
+ | A non-invertible matrix is detected by the fact that the left half won't | ||
+ | reduce to the identity. | ||
+ | |||
+ | :<math> | ||
+ | \left(\begin{array}{cc|cc} | ||
+ | 1 &1 &1 &0 \\ | ||
+ | 2 &2 &0 &1 | ||
+ | \end{array}\right) | ||
+ | \xrightarrow[]{-2\rho_1+\rho_2} | ||
+ | \left(\begin{array}{cc|cc} | ||
+ | 1 &1 &1 &0 \\ | ||
+ | 0 &0 &-2 &1 | ||
+ | \end{array}\right) | ||
+ | </math> | ||
+ | |||
+ | This procedure will find the inverse of a general <math>n \! \times \! n</math> matrix. | ||
+ | The <math>2 \! \times \! 2</math> case is handy. | ||
Line 30: | Line 547: | ||
* [https://www.khanacademy.org/math/algebra-home/alg-matrices/alg-multiplying-matrices-by-scalars/v/scalar-multiplication Multiplying Matrices by Scalars], Khan Academy | * [https://www.khanacademy.org/math/algebra-home/alg-matrices/alg-multiplying-matrices-by-scalars/v/scalar-multiplication Multiplying Matrices by Scalars], Khan Academy | ||
* [https://www.khanacademy.org/math/algebra-home/alg-matrices/alg-multiplying-matrices-by-matrices/v/matrix-multiplication-intro Matrix Multiplication], Khan Academy | * [https://www.khanacademy.org/math/algebra-home/alg-matrices/alg-multiplying-matrices-by-matrices/v/matrix-multiplication-intro Matrix Multiplication], Khan Academy | ||
+ | * [https://openstax.org/books/college-algebra/pages/7-5-matrices-and-matrix-operations Matrices and Matrix Operations], OpenStax | ||
+ | * [https://www.youtube.com/watch?v=0L90Kkn90J8 Multiplying a 2-by-3 Matrix and 3-by-2 Matrix], patrickJMT | ||
+ | |||
+ | ==Licensing== | ||
+ | Content obtained and/or adapted from: | ||
+ | * [https://en.wikibooks.org/wiki/Linear_Algebra/Inverses Inverses, Wikibooks: Linear Algebra] under a CC BY-SA license | ||
+ | * [https://en.wikibooks.org/wiki/Linear_Algebra/The_Inverse_of_a_Matrix The Inverse of a Matrix, Wikibooks: Linear Algebra] under a CC BY-SA license |
Latest revision as of 07:30, 3 November 2021
Contents
Matrix Operations
Adding and subtracting matrices
In order to add or subtract two matrices, they must be of the same dimension; that is, the two matrices must have the same number of rows and the same number of columns. To add two matrices together, we simply need to add every entry in one matrix to the entry in the same row and same column in the other matrix. For example:
Multiplying matrices by scalars
When multiplying a matrix by a scalar (or number), all we need to do is multiply each entry of the matrix by the scalar. For example:
Multiplying matrices
Matrix multiplication is not commutative; that is, for most matrices and , . Two matrices can only be multiplied together if the number of columns in the first matrix equals the number of rows in the second matrix. For example, we can take the product of a 3-by-2 matrix times a 2-by-5 matrix, but not a 3-by-2 matrix times a 3-by-2 matrix. The product of two matrices has the same number of rows as the first matrix and the same number of columns as the second matrix. For example, a 2-by-3 matrix times a 3-by-2 matrix will result in a 2-by-2 matrix.
The product of two 3-by-3 matrices is
where is the dot product of the i-th row of the first matrix and the j-th column of the second matrix; that is, .
Here is a 2-by-2 example of matrix multiplication:
Note that there is no "matrix division". Rather, we multiply one matrix by the inverse of another (for example, , NOT ) to obtain a "quotient" from two matrices.
Inverse of an n-by-n matrix
An n-by-n matrix A is the inverse of n-by-n matrix B (and B the inverse of A) if BA = AB = I, where I is an identity matrix.
The inverse of an n-by-n matrix can be calculated by creating an n-by-2n matrix which has the original matrix on the left and the identity matrix on the right. Row reduce this matrix and the right half will be the inverse. If the matrix does not row reduce completely (i.e., a row is formed with all zeroes as its entries), it does not have an inverse.
Example 1
Let
We begin by expanding and partitioning A to include the identity matrix, and then proceed to row reduce A until we reach the identity matrix on the left-hand side.
The matrix is then the inverse of the original matrix A.
Inverse of a Linear Transformation
We now consider how to represent the inverse of a linear map. We start by recalling some facts about function inverses. Some functions have no inverse, or have an inverse on the left side or right side only.
Definitions
Where is the projection map
and is the embedding
the composition is the identity map on .
We say is a left inverse map of or, what is the same thing, that is a right inverse map of . However, composition in the other order doesn't give the identity map— here is a vector that is not sent to itself under .
In fact, the projection has no left inverse at all. For, if were to be a left inverse of then we would have
for all of the infinitely many 's. But no function can send a single argument to more than one value.
(An example of a function with no inverse on either side is the zero transformation on .)
Some functions have a two-sided inverse map, another function that is the inverse of the first, both from the left and from the right. For instance, the map given by has the two-sided inverse . In this subsection we will focus on two-sided inverses. The appendix shows that a function has a two-sided inverse if and only if it is both one-to-one and onto. The appendix also shows that if a function has a two-sided inverse then it is unique, and so it is called "the" inverse, and is denoted . So our purpose in this subsection is, where a linear map has an inverse, to find the relationship between and .
A matrix is a left inverse matrix of the matrix if is the identity matrix. It is a right inverse matrix if is the identity. A matrix with a two-sided inverse is an invertible matrix. That two-sided inverse is called the inverse matrix and is denoted .
Because of the correspondence between linear maps and matrices, statements about map inverses translate into statements about matrix inverses.
Lemmas and Theorems
- If a matrix has both a left inverse and a right inverse then the two are equal.
- A matrix is invertible if and only if it is nonsingular.
- Proof: (For both results.) Given a matrix , fix spaces of appropriate dimension for the domain and codomain. Fix bases for these spaces. With respect to these bases, represents a map . The statements are true about the map and therefore they are true about the matrix.
- A product of invertible matrices is invertible— if and are invertible and if is defined then is invertible and .
- Proof: (This is just like the prior proof except that it requires two maps.) Fix appropriate spaces and bases and consider the represented maps and . Note that is a two-sided map inverse of since and . This equality is reflected in the matrices representing the maps, as required.
Here is the arrow diagram giving the relationship
between map inverses and matrix inverses.
It is a special case
of the diagram for function composition and matrix multiplication.
Beyond its place in our general program of seeing how to represent map operations, another reason for our interest in inverses comes from solving linear systems. A linear system is equivalent to a matrix equation, as here.
By fixing spaces and bases (e.g., and ), we take the matrix to represent some map . Then solving the system is the same as asking: what domain vector is mapped by to the result ? If we could invert then we could solve the system by multiplying to get .
Example 2
We can find a left inverse for the matrix just given
by using Gauss' method to solve the resulting linear system.
Answer: , , , and . This matrix is actually the two-sided inverse of , as can easily be checked. With it we can solve the system () above by applying the inverse.
Remark
Why solve systems this way, when Gauss' method takes less arithmetic (this assertion can be made precise by counting the number of arithmetic operations, as computer algorithm designers do)? Beyond its conceptual appeal of fitting into our program of discovering how to represent the various map operations, solving linear systems by using the matrix inverse has at least two advantages.
First, once the work of finding an inverse has been done, solving a system with the same coefficients but different constants is easy and fast: if we change the entries on the right of the system () then we get a related problem
with a related solution method.
In applications, solving many systems having the same matrix of coefficients is common.
Another advantage of inverses is that we can explore a system's sensitivity to changes in the constants. For example, tweaking the on the right of the system () to
can be solved with the inverse.
to show that changes by of the tweak while moves by of that tweak. This sort of analysis is used, for example, to decide how accurately data must be specified in a linear model to ensure that the solution has a desired accuracy. }}
We finish by describing the computational procedure usually used to find the inverse matrix.
- A matrix is invertible if and only if it can be written as the product of elementary reduction matrices. The inverse can be computed by applying to the identity matrix the same row steps, in the same order, as are used to Gauss-Jordan reduce the invertible matrix.
- Proof: A matrix is invertible if and only if it is nonsingular and thus Gauss-Jordan reduces to the identity. This reduction can be done with elementary matrices
- .
- This equation gives the two halves of the result.
- First, elementary matrices are invertible and their inverses are also elementary. Applying to the left of both sides of that equation, then , etc., gives as the product of elementary matrices (the is here to cover the trivial case).
- Second, matrix inverses are unique and so comparison of the above equation with shows that . Therefore, applying to the identity, followed by , etc., yields the inverse of .
Example 3
To find the inverse of
we do Gauss-Jordan reduction, meanwhile performing the same operations on the identity. For clerical convenience we write the matrix and the identity side-by-side, and do the reduction steps together.
This calculation has found the inverse.
Example 4
This one happens to start with a row swap.
Example 5
A non-invertible matrix is detected by the fact that the left half won't reduce to the identity.
This procedure will find the inverse of a general matrix. The case is handy.
Resources
- Matrix Addition and Subtraction, Khan Academy
- Multiplying Matrices by Scalars, Khan Academy
- Matrix Multiplication, Khan Academy
- Matrices and Matrix Operations, OpenStax
- Multiplying a 2-by-3 Matrix and 3-by-2 Matrix, patrickJMT
Licensing
Content obtained and/or adapted from:
- Inverses, Wikibooks: Linear Algebra under a CC BY-SA license
- The Inverse of a Matrix, Wikibooks: Linear Algebra under a CC BY-SA license