BetaFree coursewareRewritten from MIT OpenCourseWareCC BY-NC-SA 4.0
Open CosmologyPhysics & cosmology, from high school to a graduate year

Matrix multiplication and inverse matrices

Matrix multiplication can be seen in several ways, all giving the same answer. The (i, j) entry of AB is row i of A times column j of B, a sum over k of a_ik b_kj, which needs A to be m × n and B n × p, giving m × p. Each column of AB is A times a column of B, so a combination of the columns of A; each row of AB is a row of A times B, a combination of the rows of B. AB is also the sum of (column k of A)(row k of B), and each such column times row is a full matrix whose rows all lie on one line. Matrices can also be multiplied by blocks. A square matrix A is invertible if some A⁻¹ gives A⁻¹A = I = AA⁻¹. It is not invertible if Ax = 0 for some nonzero x, as for [1 3; 2 6] with x = (3, −1). Gauss–Jordan finds A⁻¹ by eliminating on [A I] until the left half is I; the right half is then A⁻¹, because EA = I means E = A⁻¹.

You need this first

Full reading path (7 pages)
  1. Vectors (8.01)
  2. Vectors and the dot product (18.02)
  3. Determinants and the cross product (18.02)
  4. Planes through three points, and matrices (18.02)
  5. Equations of planes and square systems (18.02)
  6. The geometry of linear equations (18.06)
  7. Elimination with matrices (18.06)
On this page · 5 sections
  1. Entry by entry
  2. By columns, by rows, by columns times rows
  3. Inverses
  4. Gauss–Jordan
  5. Summary

Matrices have been multiplied already; this lecture states the rules, in several ways that all give the same answer and are all important, and then turns to inverses (transcript, p. 1). It continues elimination with matrices.

Entry by entry#

In AB=CAB = C, the entry c34c_{34} in row 3, column 4 comes from row 3 of AA and column 4 of BB: a dot product (transcript, pp. 1–2), which in index notation is (pp. 2–3)

Entry of a product
c34=a31b14+a32b24+⋯=∑k=1na3k bk4c_{34} = a_{31}b_{14} + a_{32}b_{24} + \cdots = \sum_{k=1}^{n} a_{3k}\,b_{k4}
In words

c sub 34 equals a sub 31 b sub 14 plus a sub 32 b sub 24 plus and so on equals the sum from k equals 1 to n of a sub 3k b sub k4

For the product to exist, the number of columns of AA must match the number of rows of BB (p. 3):

Shapes
(m×n)(n×p)=m×p(m \times n)(n \times p) = m \times p
In words

(m times n)(n times p) equals m times p

By columns, by rows, by columns times rows#

Columns (pp. 4–6). Think of BB as pp columns side by side. AA times column jj of BB is column jj of CC, so every column of ABAB is a combination of the columns of AA, with the coefficients taken from BB (pp. 5–6).

Rows (p. 6). Likewise, row ii of AA times BB is row ii of CC: every row of ABAB is a combination of the rows of BB (p. 6).

Columns times rows (pp. 7–9). A row times a column is a number; a column times a row is a full matrix (p. 7). For example (pp. 7–8)

Column times row
(234)(16)=(212318424)\begin{pmatrix} 2 \\ 3 \\ 4 \end{pmatrix}\begin{pmatrix} 1 & 6 \end{pmatrix} = \begin{pmatrix} 2 & 12 \\ 3 & 18 \\ 4 & 24 \end{pmatrix}
In words

2; 3; 4 1 6 equals 2 12; 3 18; 4 24

a very special matrix: its columns are multiples of (2,3,4)(2, 3, 4), its rows multiples of (1,6)(1, 6) (p. 8). Its row space, the combinations of its rows, is just the line through (1,6)(1, 6), and its column space the line through (2,3,4)(2, 3, 4): a minimal matrix (pp. 9–10). The fourth way to multiply is then (p. 8)

Sum of columns times rows
AB=∑k=1n(column k of A)(row k of B)AB = \sum_{k=1}^{n} (\text{column } k \text{ of } A)(\text{row } k \text{ of } B)
In words

capital A capital B equals the sum from k equals 1 to n of ( column k of capital A )( row k of capital B )

Blocks (pp. 10–11). Cut AA and BB into blocks that match, for example four 10×1010 \times 10 blocks each of a 20×2020 \times 20 matrix. The blocks multiply like entries, block rows times block columns (p. 11):

Block multiplication
(A1A2A3A4)(B1B2B3B4)=(A1B1+A2B3⋯⋯⋯)\begin{pmatrix} A_1 & A_2 \\ A_3 & A_4 \end{pmatrix}\begin{pmatrix} B_1 & B_2 \\ B_3 & B_4 \end{pmatrix} = \begin{pmatrix} A_1B_1 + A_2B_3 & \cdots \\ \cdots & \cdots \end{pmatrix}
In words

capital A one capital A two; capital A three capital A four capital B one capital B two; capital B three capital B sub 4 equals capital A one capital B one plus capital A two capital B three and so on; and so on and so on

All these ways do the same multiplications, just grouped differently (p. 11).

Inverses#

For a square matrix, the key question is whether it is invertible (transcript, pp. 11–12). If it is (pp. 11–12),

Inverse
A−1A=I=AA−1A^{-1}A = I = AA^{-1}
In words

capital A to the power minus 1 capital A equals capital I equals capital A capital A to the power minus 1

For square matrices a left inverse is automatically a right inverse, a fact that is not easy to prove; rectangular matrices will be different (p. 12). Invertible matrices are also called non-singular (p. 12).

A singular matrix (pp. 12–16). Take A=(1326)A = \begin{pmatrix} 1 & 3 \\ 2 & 6 \end{pmatrix}. Its determinant is 0, but Strang gives other reasons, all of them important (pp. 13–14). The columns of any product ABAB are combinations of the columns of AA, which lie on one line, so (1,0)(1, 0), the first column of II, cannot be reached (p. 14). The reason Strang likes best (pp. 14–16):

A nonzero solution of Ax = 0
(1326)(3−1)=(00)\begin{pmatrix} 1 & 3 \\ 2 & 6 \end{pmatrix}\begin{pmatrix} 3 \\ -1 \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \end{pmatrix}
In words

1 3; 2 6 3; minus 1 equals 0; 0

Three of column 1 minus one of column 2 is the zero column. If A−1A^{-1} existed, multiplying Ax=0Ax = 0 by it would give x=0x = 0; but xx is not 0 (pp. 15–16). A square matrix with Ax=0Ax = 0 for some nonzero xx has no inverse (p. 16).

Gauss–Jordan#

Take the invertible A=(1327)A = \begin{pmatrix} 1 & 3 \\ 2 & 7 \end{pmatrix}: its columns point in different directions (transcript, p. 17). Finding A−1A^{-1} is solving systems: AA times column jj of A−1A^{-1} is column jj of II (p. 18). Here, two systems with right-hand sides (1,0)(1, 0) and (0,1)(0, 1) (pp. 18–19). Jordan's idea is to solve them together: augment AA by both columns, that is by II, and eliminate (pp. 19–20). Subtract 2 times row 1 from row 2; then, going upwards, which Gauss would not do, subtract 3 times row 2 from row 1 (pp. 21–22):

Gauss–Jordan
(13102701)→(131001−21)→(107−301−21)\left(\begin{array}{cccc} 1 & 3 & 1 & 0 \\ 2 & 7 & 0 & 1 \end{array}\right) \to \left(\begin{array}{cccc} 1 & 3 & 1 & 0 \\ 0 & 1 & -2 & 1 \end{array}\right) \to \left(\begin{array}{cccc} 1 & 0 & 7 & -3 \\ 0 & 1 & -2 & 1 \end{array}\right)
In words

( c c c c 1 3 1 0; 2 7 0 1 ) goes to ( c c c c 1 3 1 0; 0 1 minus 2 1 ) goes to ( c c c c 1 0 7 minus 3; 0 1 minus 2 1 )

The left half is now II, and the right half is A−1=(7−3−21)A^{-1} = \begin{pmatrix} 7 & -3 \\ -2 & 1 \end{pmatrix}; check: 7−6=17 - 6 = 1, 21−21=021 - 21 = 0, −2+2=0-2 + 2 = 0, −6+7=1-6 + 7 = 1 (p. 22).

Why it works (pp. 23–24). All the elimination steps together are one matrix EE, the product of the elimination matrices (dividing a row by its pivot is a multiplication by a diagonal matrix, so it belongs to EE too). It turned AA into II, so EA=IEA = I, which says E=A−1E = A^{-1}; and on the right it turned II into EI=A−1EI = A^{-1} (p. 24):

Why Gauss–Jordan gives the inverse
E [A    I]=[EA    E]=[I    A−1]E\,[A\;\; I] = [EA\;\; E] = [I\;\; A^{-1}]
In words

E ( capital A capital I ) equals ( E capital A E ) equals ( capital I capital A to the power minus 1 )

Worked example

Products and inverses

(a) For A=(1201)A = \begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix} and B=(3114)B = \begin{pmatrix} 3 & 1 \\ 1 & 4 \end{pmatrix}, compute ABAB by entries and as a sum of columns times rows. (b) Invert (2513)\begin{pmatrix} 2 & 5 \\ 1 & 3 \end{pmatrix} by Gauss–Jordan. (c) Show that (2436)\begin{pmatrix} 2 & 4 \\ 3 & 6 \end{pmatrix} is not invertible.

(a) Two ways

By entries: AB=(3+21+814)=(5914)AB = \begin{pmatrix} 3 + 2 & 1 + 8 \\ 1 & 4 \end{pmatrix} = \begin{pmatrix} 5 & 9 \\ 1 & 4 \end{pmatrix}. As a sum: (10)(31)+(21)(14)=(3100)+(2814)\begin{pmatrix} 1 \\ 0 \end{pmatrix}\begin{pmatrix} 3 & 1 \end{pmatrix} + \begin{pmatrix} 2 \\ 1 \end{pmatrix}\begin{pmatrix} 1 & 4 \end{pmatrix} = \begin{pmatrix} 3 & 1 \\ 0 & 0 \end{pmatrix} + \begin{pmatrix} 2 & 8 \\ 1 & 4 \end{pmatrix}, the same.

(b) Gauss–Jordan

From (25101301)\left(\begin{array}{cccc} 2 & 5 & 1 & 0 \\ 1 & 3 & 0 & 1 \end{array}\right), subtract 12\frac{1}{2} of row 1 from row 2: (0,12)(0, \frac{1}{2}) on the left and (−12,1)(-\frac{1}{2}, 1) on the right. Subtract 10 times the new row 2 from row 1: (2,0)(2, 0) and (6,−10)(6, -10). Divide the rows by the pivots 2 and 12\frac{1}{2}: A−1=(3−5−12)A^{-1} = \begin{pmatrix} 3 & -5 \\ -1 & 2 \end{pmatrix}. Check: 2⋅3+5⋅(−1)=12\cdot3 + 5\cdot(-1) = 1.

(c) A singular matrix

x=(2,−1)x = (2, -1) gives 2(23)−(46)=02\begin{pmatrix} 2 \\ 3 \end{pmatrix} - \begin{pmatrix} 4 \\ 6 \end{pmatrix} = 0, so there is no inverse.

Summary#

  • (AB)ij(AB)_{ij} = row ii of AA · column jj of BB; shapes (m×n)(n×p)=m×p(m \times n)(n \times p) = m \times p.
  • Columns of ABAB combine columns of AA; rows of ABAB combine rows of BB; ABAB is a sum of columns times rows; blocks multiply like entries.
  • A−1A=I=AA−1A^{-1}A = I = AA^{-1}; no inverse if Ax=0Ax = 0 for some x≠0x \ne 0.
  • Gauss–Jordan: eliminate [A   I][A\;\,I] to [I   A−1][I\;\,A^{-1}].

Symbols on this page

Show the 33 symbols used here
≠\neq not equal.
Is not equal to. Say it: “is not equal to”.
→\to arrow.
Goes to (tends to), or becomes. Say it: “goes to”.
×\times times.
Times (multiplication). Between two vectors: the cross product. Say it: “times”.
⋅\cdot dot.
Times (multiplication). Between two vectors: the dot product. Say it: “times”.
∑\sum sum.
Sum: add up the terms over the range written below and above. Say it: “the sum of”.
cc c.
An entry of the product C. Say it: “c”.
kk k.
The summation index running along a row of A and down a column of B. Say it: “k”.
xx x.
A vector with Ax = 0. Say it: “x”.
ii i.
A row index. Say it: “i”.
jj j.
A column index. Say it: “j”.
nn n.
The number of columns of A (and rows of B). Say it: “n”.
mm m.
The number of rows of A. Say it: “m”.
AA A.
A matrix (m × n); later a square matrix to invert. Say it: “capital A”.
BB B.
A second matrix (n × p). Say it: “capital B”.
CC C.
The product AB. Say it: “capital C”.
pp p.
The number of columns of B. Say it: “p”.
EE E.
The product of all elimination steps; EA = I makes E = A⁻¹. Say it: “E”.
II I.
The identity matrix. Say it: “capital I”.
A1A_{1} A 1.
The top-left block of A. Say it: “capital A one”.
A2A_{2} A 2.
The top-right block of A. Say it: “capital A two”.
A3A_{3} A 3.
The bottom-left block of A. Say it: “capital A three”.
A4A_{4} A 4.
The bottom-right block of A. Say it: “capital A four”.
B1B_{1} B 1.
The top-left block of B. Say it: “capital B one”.
B2B_{2} B 2.
The top-right block of B. Say it: “capital B two”.
B3B_{3} B 3.
The bottom-left block of B. Say it: “capital B three”.
c34c_{34} c sub 34.
The entry of C = AB in row 3, column 4. Say it: “c sub 34”.
a31a_{31} a sub 31.
The entry of A in row 3, column 1. Say it: “a sub 31”.
b14b_{14} b sub 14.
The entry of B in row 1, column 4. Say it: “b sub 14”.
a32a_{32} a sub 32.
The entry of A in row 3, column 2. Say it: “a sub 32”.
b24b_{24} b sub 24.
The entry of B in row 2, column 4. Say it: “b sub 24”.
a3ka_{3k} a sub 3k.
The entry of A in row 3, column k. Say it: “a sub 3k”.
bk4b_{k4} b sub k4.
The entry of B in row k, column 4. Say it: “b sub k4”.
B4B_{4} B sub 4.
The bottom-right block of B. Say it: “capital B sub 4”.

Tap or click a symbol in a formula to see the same explanation. All symbols: symbols and notation.

Words on this page

Show the 20 words used here

New here

row space.
All the vectors that can be made by combining the rows of a matrix; it is the column space of its transpose.
column space.
All the vectors made by combining the columns of a matrix; Ax = b can be solved exactly when b lies in it.

Also used

matrix.
A rectangular table of numbers, which acts on vectors to give new ones and so describes a linear change of coordinates. Explained in Planes through three points, and matrices.
inverse.
The thing that undoes another: a matrix times its inverse gives the identity matrix, as a function followed by its inverse gives back the start. Explained in Planes through three points, and matrices.
p..
Page, in a reference to a source; pp. means pages, as in pp. 3–5.
elimination.
Solving equations by subtracting multiples of one from another until each unknown can be found in turn. Explained in The geometry of linear equations.
dot product.
A way of multiplying two vectors that gives a number: multiply matching components and add, or lengths times the cosine of the angle between them. Explained in Vectors and the dot product.
invertible.
Of a square matrix or operator: having an inverse that undoes it; for a matrix this happens exactly when its determinant is not zero. Explained in The geometry of linear equations.
left inverse.
An operator S that undoes T: applying T and then S gives back every vector unchanged, so ST is the identity. Explained in Left and right inverses; the pseudoinverse.
right inverse.
An operator S such that applying S and then T gives back every vector unchanged, so TS is the identity. Explained in Left and right inverses; the pseudoinverse.
non-singular.
Of a square matrix: invertible, with a determinant that is not zero. Explained in The geometry of linear equations.
singular.
Of a square matrix: having no inverse, because its determinant is zero and some nonzero vector is sent to zero. Explained in The geometry of linear equations.
determinant.
A single number worked out from a square array of numbers (a matrix), which measures how the matrix stretches areas or volumes. Explained in Determinants and the cross product.
elimination matrix.
A matrix that carries out one step of elimination, subtracting a multiple of one row from another, when it multiplies a matrix. Explained in Elimination with matrices.
pivot.
In elimination, the first nonzero number in a row, used to clear out the entries below it. Explained in Positive definite matrices and minima.
diagonal.
In a square matrix, the entries running from the top left corner to the bottom right; a diagonal matrix has zeros everywhere else. Explained in The four fundamental subspaces.
Gauss–Jordan.
A method that continues elimination upwards as well as downwards until the matrix becomes the identity, which finds the inverse. Explained in The four fundamental subspaces.

Academic

transcript.
A written record of exactly what was said in a recorded lecture, word for word.
notation.
A system of symbols used to write ideas down briefly, such as dy/dx for a derivative.
likewise.
In the same way; similarly.

Tap or click a word, here or in the text, for its meaning in this lesson. All words: the glossary. How many words are marked in the text: Reading options (the “Aa” button).

Where this leads

In cosmology

31 more cosmology pages that build on this

Pages that build on this

Practise

Check your understanding

  1. If AA is 3×23 \times 2 and BB is 2×52 \times 5, what shape is ABAB?
  2. The columns of ABAB are combinations of…
  3. Why is (1326)\begin{pmatrix} 1 & 3 \\ 2 & 6 \end{pmatrix} not invertible?
0 of 3 answered

Flashcards

1 / 3