Documente Academic
Documente Profesional
Documente Cultură
∗
Linear Algebra: Matrices
Louis Scharf
This work is produced by The Connexions Project and licensed under the
Creative Commons Attribution License †
note: This module is part of the collection, A First Course in Electrical and Computer Engineer-
ing. The LaTeX source les for this collection were created using an optical character recognition
technology, and because of this process there may be more errors than usual. Please contact us if
The word matrix dates at least to the thirteenth century, when it was used to describe the rectangular
copper tray, or matrix, that held individual leaden letters that were packed into the matrix to form a page
of composed text. Each letter in the matrix, call it aij , occupied a unique position (ij) in the matrix. In
modern day mathematical parlance, a matrix is a collection of numbers arranged in a two-dimensional array
(a rectangle). We indicate a matrix with a boldfaced capital letter and the constituent elements with double
Figure 1: Matrix
In this equation A is an mxn matrix, meaning that A hasm horizontal rows and n vertical columns.
As an extension of the previously used notation, we write A ∈ Rmxn to show that A is a matrix of size
th th
mxn with aij ∈ R. The scalar element aij is located in the matrix at the i row and the j column. For
example, a23 is located in the second row and the third column as illustrated in Figure 1.
The main diagonal of any matrix consists of the elements aii . (The two subscripts are equal.) The main
diagonal runs southeast from the top left corner of the matrix, but it does not end in the lower right corner
http://cnx.org/content/m21457/1.6/
Connexions module: m21457 2
The transpose of a matrix A ∈ Rm×n is another matrix B whose element in row j and column i is
bji = aij for 1 ≤ i ≤ m and 1 ≤ j ≤ n. We write B = AT to indicate that B is the transpose of A. In
MATLAB, transpose is denoted by A'. A more intuitive way of describing the transpose operation is to say
that it ips the matrix about its main diagonal so that rows become columns and columns become rows.
Exercise 1
2 1
If A ∈ Rm×n , then AT ∈ ? . Find the transpose of the matrix A=
5 .
4
_
7 9
Matrix Addition and Scalar Multiplication. Two matrices of the same size (in both dimensions) may
be added or subtracted in the same way as vectors, by adding or subtracting the corresponding elements.
The equation C = A±B means that for each i and j, cij = aij ± bij . Scalar multiplication of a matrix
ax11 ax12 ax13 ... ax1n
ax ax22 ax23 ... ax2n
21
aX = ax31
ax32 ax33 ... .
ax3n (1)
123 123 123 123
axml axm2 axm3 ... axmn
Matrix Multiplication. A vector can be considered a matrix with only one column. Thus we intentionally
blur the distinction between Rn×1 and R .
n Also a matrix can be viewed as a collection of vectors, each
a11 al2 a1n
| | |
a21
a a
22 2n
A=
al a2 =
... an .
(2)
| | |
| | |
am1 am2 amn
In the transpose operation, columns become rows and vice versa. The transpose of an n×1 matrix, a
x1
x
2 T
x= ; x = [x1 x2 xn ] . (3)
|
xn
Now we can dene matrix-matrix multiplication in terms of inner products of vectors. Let's begin with
matrices A ∈ Rm×n and B ∈ Rn×p . To nd the product AB, rst divide each matrix into column vectors
http://cnx.org/content/m21457/1.6/
Connexions module: m21457 3
Figure 2
Thus ai is the ith column of A and αjT is the j th row of A. For matrix multiplication to be dened, the
width of the rst matrix must match the length of the second one so that all rows αiT and columns bi have
the same number of elements n. The matrix product, C= AB, is an m×p matrix dened by its elements
as cij = (αi , bj ). In words, each element of the product matrix, cij , is the inner product of the ith row of the
th
rst matrix and the j column of the second matrix.
For n-vectors x and y, the matrix product xT y takes on a special signicance. The product is, of course,
a 1×1 matrix (a scalar). The special signicance is that xT y is the inner product of x and y:
Figure 3
Thus the notation xT y is often used in place of (x, y). Recall from Demo 1 from "Linear Algebra: Other
Norms"
1
that MATLAB uses x'*y to denote inner product.
Another special case of matrix multiplication is the outer product. Like the inner product, it involves
http://cnx.org/content/m21457/1.6/
Connexions module: m21457 4
Figure 4
In the outer product, the inner products that dene its elements are between one-dimensional row vectors
0 −2 1 −3
1 −1 2
a. A= , B = 4 2 2 ;
0
3 0 5
2 −2 3 1
1 0 1 2 3 4
b. A= , B = ;
0 1 5 6 7 8
1 −1 −1 0 3 6
c. A = 1 −1 1 , B = 1 4
7
.
1 1 1 2 5 8
There are several other equivalent ways to dene matrix multiplication, and a careful study of the following
discussion should improve your understanding of matrix multiplication. Consider A ∈ Rm×n , B ∈ Rn×p ,
m×p
and C = AB so that C∈R . In pictures, we have
h pi hni p
m C =m A n. (4)
B
n
cij = (αi , bj ) = Σ aik bkj . (5)
k=1
In pictures,
http://cnx.org/content/m21457/1.6/
Connexions module: m21457 5
Figure 5
You will prove in Exercise 3 (Exercise ) that we can also represent C on a column basis:
n
cj = Σ ak bkj . (6)
k=1
Figure 6
Finally, C can be represented as a sum of matrices, each matrix being an outer product:
n
C = Σ ai βiT (7)
i=1
Figure 7
http://cnx.org/content/m21457/1.6/
Connexions module: m21457 6
Example 1
Let
1 2 1
1 2 1 3
2
2 1
A=
2 1 2 , B =
4 .
(8)
1 3 2
3 3 2 1
2 1 1
Using the rst method of matrix multiplication, on an entry-by-entry basis, we have
4
cij = Σ aik bkj (9)
k=1
or
(1 · 1 + 2 · 2 + 1 · 1 + 3 · 2) (1 · 2 + 2 · 2 + 1 · 3 + 3 · 1) (1 · 1 + 2 · 1 + 1 · 2 + 3 · 1)
C=
(2 · 1 + 1 · 2 + 2 · 1 + 4 · 2) (2 · 2 + 1 · 2 + 2 · 3 + 4 · 1) (2 · 1 + 1 · 1 + 2 · 2 + 4.1) (10)
(3 · 1 + 3 · 2 + 2 · 1 + 1 · 2) (3 · 2 + 3 · 2 + 2 · 3 + 1 · 1) (3 · 1 + 3 · 1 + 2 · 2 + 1 · 1)
or
12 12 8
C=
14 16 .
11 (11)
13 l9 l1
On a column basis,
4
cj = Σ ak bkj (12)
k=1
1 2 1 3 1 2 1 3
2 1 + 1 2 + 2 1 + 4 2; c2 = 2 2 + 1 2 + 2 3 + 4 1; c3 =
c1 =
3 3 2 1 3 3 2 1
1 2 1 3
2 1 + 1 1 + 2 2 + 4 1.
3 3 2 1
Collecting terms together, we have
C = [c1 c2 c3 ]
(1 · 1 + 2 · 2 + 1 · 1 + 3 · 2) (1 · 2 + 2 · 2 + 1 · 3 + 3 · 1) (1 · 1 + 2 · 1 + 1 · 2 + 3 · 1)
(13)
C=
(2 · 1 + 1 · 2 + 2 · 1 + 4 · 2) (2 · 2 + 1 · 2 + 2 · 3 + 4 · 1) (2 · 1 + 1 · 1 + 2 · 2 + 4.1)
(3 · 1 + 3 · 2 + 2 · 1 + 1 · 2) (3 · 2 + 3 · 2 + 2 · 3 + 1 · 1) (3 · 1 + 3 · 1 + 2 · 2 + 1 · 1)
On a matrix-by-matrix basis,
4
C = Σ ai βiT (14)
i=1
http://cnx.org/content/m21457/1.6/
Connexions module: m21457 7
C = [123] [121] + [213] [221] + [132] + [122] [132] + [341] [111] (15)
1·1 1·2 1·1 2·2 2·2 2·1 1·1 1·3 1·2 3·2 3·1 3·1
=
2·1 2·2
2·1 + 1·2 1·2 1·1 + 2·1 2·3 2·2 + 4·2 4·1 4·1
(16)
3·1 3·2 3·1 3·2 3·2 3·1 2·1 2·3 2·2 1·2 1·1 1·1
(1 · 1 + 2 · 2 + 1 · 1 + 3 · 2) (1 · 2 + 2 · 2 + 1 · 3 + 3 · 1) (1 · 1 + 2 · 1 + 1 · 2 + 3 · 1)
C=
(2 · 1 + 1 · 2 + 2 · 1 + 4 · 2) (2 · 2 + 1 · 2 + 2 · 3 + 4 · 1) (2 · 1 + 1 · 1 + 2 · 2 + 4.1) (17)
(3 · 1 + 3 · 2 + 2 · 1 + 1 · 2) (3 · 2 + 3 · 2 + 2 · 3 + 1 · 1) (3 · 1 + 3 · 1 + 2 · 2 + 1 · 1)
as we had in each of the other cases. Thus we see that the methods are equivalent-simply dierent
Exercise 3
Prove that Equations 9 (5), 11 (6), and 13 (7) are equivalent denitions of matrix multiplication.
That is, if C = AB where A ∈ Rm×n and B ∈ Rn×p , show that the matrix-matrix product can
also be dened by
n
X
cij = aik bkj , (18)
k=1
n
X
cj = ak bkj . (19)
k=1
Show that the matrix C may also be written as the
"sum of outer products"
n
X
C= ak βkT . (20)
k=1
T
a. AT = A.
b. AB = BA when n = p and m = q . Is matrix multiplication commutative?
c. A (B + C) = AB + AC when n = p = r and q = s. Is matrix multiplication distributive over
addition?
d. ( AB T = B T AT when n = p.
e. (AB) C = A (BC) when n = p and q = r. Is matrix multiplication associative?
Example 2: Rotation
2
We know from the chapter on complex numbers that a complex number z1 = x1 + jy1 may be
z2 = ejθ z1 . (21)
http://cnx.org/content/m21457/1.6/
Connexions module: m21457 8
x2 cosθ −sinθ x1
z2 = = . (23)
y2 sinθ cosθ y1
cosθ −sinθ
We call the matrix R (θ) = a rotation matrix.
sinθ cosθ
Exercise 5
Let R (θ) denote a 2×2 rotation matrix. Prove and interpret the following two properties:
a. RT (θ) = R (−θ);
1 0
b. RT (θ) R (θ) = R (θ) RT (θ) = .
0 1
http://cnx.org/content/m21457/1.6/