Matrix Algebra Review
Matrix Algebra Review
Introduction
This is the matrix review for A Student’s Guide to Vectors and Tensors
(SGVT). It is not meant to be a thorough introduction to the theory and
practice of matrix algebra, but rather a review of the matrix concepts
you should understand when learning about vectors and tensors.
A matrix is defined as an array of numbers. Some authors restrict the
term “matrix” to refer only to square arrays of real numbers, but in com-
mon usage a matrix is a rectangular (m x n) array of complex numbers
or “elements,” where “m” represents the number of rows, “n” represents
the number of columns, and “complex” means that the numbers may be
purely real, purely imaginary, or mixed. Thus
8
0
3 −2
A= B= −2 C = 9 15 3 −8 12 −2
1 0 1
5
and
5 − 2i
3i
1 0 0
0 15 0 0
D=
−4i
E= 0 1 0 F =
2 + 8i 0 0
0 0 1
12 i−1
are all matrices. In these examples, matrix A has “dimensions” or “or-
der” (rows x columns) of 2x2, B of 5x1, C of 1x6, D of 4x2, E of 3x3,
and F of 2x2.
2 Matrix Algebra Review
If both m and n for a matrix are equal to one, that matrix is called
a scalar (because it’s just a single value), and if either (but not both)
of m and n are one, that matrix may be called a vector. So in the
examples shown above, B and C are vectors; in some texts you’ll see
B called a column vector and C called a row vector. A square matrix
(that is, a matrix with m=n) with ones on the diagonal and zeroes in
all off-diagonal elements (such as matrix E above) is called the “unit”
or “identity” matrix, and a matrix with all elements equal to zero (such
as matrix F above) is called the “null” or “zero” matrix.
Two matrices are said to be equal only if they have the same number
of rows as well as the same number of columns and if every element in
one matrix is equal in value to the corresponding element in the other
matrix. Matrices are usually denoted using uppercase letters or bold font,
often surrounded by square brackets (such as [A]), and the elements are
often written using lowercase letters with subscripts. So you may see the
elements of matrix [A] written as aij , although some authors use Aij or
[A]ij to refer to the elements of A (but be careful to note that Aij may
also refer to the “Matrix of Cofactors” of matrix A, which you can read
about in Section E of this document).
So does terminology such as “row vector” mean that matrices, vectors,
and tensors are the same thing? Not really. It’s certainly true that the
vectors and tensors in SGVT are often represented using matrices, but
it’s important to remember what those matrices stand for. Those arrays
of values represent the components of vectors and tensors, and those
components have meaning only when associated with the basis vectors
of a particular coordinate system. Since the basis vectors are not always
shown, it’s convenient to think of the matrix as representing the vector
or tensor itself, and that’s fine as long as you remember that the actual
vector or tensor has existence independent of any coordinate system.
Matrices may be added only if both the row dimension (m) and their
column dimension (n) are equal (such matrices are said to be “of the
same order”). The addition is accomplished simply by adding each el-
ement of one matrix to the corresponding element of the other matrix.
For example:
5 2 −3 1 2 3
+ =
−3 0 0 4 −3 4
Matrix Algebra Review 3
or in general
a11 a12 b11 b12 a11 + b11 a12 + b12
+ = .
a21 a22 b21 b22 a21 + b21 a22 + b22
Note that the result is a matrix of the same order as the matrices being
added. Note also that matrix addition is commutative, so [A]+[B]=[B]+[A].
Multiplication of a matrix by a scalar is straightforward; you simply
multiply each element of the matrix by the scalar. Thus
3 −2 9 −6
3A = 3 =
1 0 3 0
and generally
a11 a12 ka11 ka12
kA = k =
a21 a22 ka21 ka22
You can use the rules for addition of matrices and scalar multiplication
to see that subtraction of matrices is accomplished simply by subtracting
the corresponding elements. Thus [A]-[B]=[A]+(-1)[B]. So if
a11 a12
A=
a21 a22
and
b11 b12
B=
b21 b22
then
a11 + (−1)b11 a12 + (−1)b12 a11 − b11 a12 − b12
A−B = = .
a21 + (−1)b21 a22 + (−1)b22 a21 − b21 a22 − b22
Just as for addition, subtraction of matrices only works for matrices of
the same order.
B) Matrix multiplication
There are several different ways to multiply matrices; the most common
and most relevant to the vector and tensor concepts in SGVT is to
multiply two matrices (call them A and B) by multiplying the elements
of each row in A by the elements of each column of B and then summing
the results. So if matrix A is given by
a11 a12 a13
a21 a22 a23
4 Matrix Algebra Review
a11 b11 + a12 b21 + a13 b31 a11 b12 + a12 b22 + a13 b32 a11 b13 + a12 b23 + a13 b33
= .
a21 b11 + a22 b21 + a23 b31 a21 b12 + a22 b22 + a23 b32 a21 b13 + a22 b23 + a23 b33
Sum products
Multiply first row
by first column Place result in first row
and first column
{
b11 ( ) ( )
a11 a12 a13 a11b11+ a12b21+ a13b31 ( ) ( )
x b21 ( ) ( ) =
( ) ( ) ( ) ( ) ( ) ( )
b31 ( ) ( )
The next step is to multiply the elements of the first row of A by the
elements of the second column of B, summing the products, and placing
the sum in the first row and second column of the result matrix, as
shown in Figure ??.
After multiplying the first row of A by the third column of B and placing
the sum in the first row and third column of the result matrix, the
same procedure is done with the second row of A - those elements are
multiplied by the first column of B, summed, and placed in the second
Matrix Algebra Review 5
Sum products
Multiply first row
by second column
Place result in first row
and second column
{
( ) b12 ( )
a11 a12 a13 ( ) a11b12+ a12b22+ a13b32 ( )
x ( ) b22 ( ) =
( ) ( ) ( ) ( ) ( ) ( )
( ) b32 ( )
b11 ( ) ( ) ( ) ( ) ( )
( ) ( ) ( )
x b21 ( ) ( ) =
a21 a22 a23 a21b11+ a22b21+ a23b31 ( ) ( )
b31 ( ) ( )
Place result in second row
{
row and first column of the result matrix, as shown in Figure ??.
Notice that the matrix that results from multiplying a 2x3 matrix (A)
by a 3x3 matrix (B) is a 2x3 matrix - the result has the number of rows
of the first matrix and the number of columns of the second matrix. You
should also note that this type of matrix multiplication only works when
the number of columns of the first matrix (3 in the case of A) equals the
number of rows of the second matrix (also 3 in the case of B).
To understand why matrices are multiplied in this way, consider the
sorting of five types of toy marbles (Bowlers, Cat’s Eyes, Steelies, Aggies,
and Commons) into four sizes of package (Small, Medium, Large, and
Extra Large). The number of each type of marble in each size package
6 Matrix Algebra Review
Small package 1 3 2 5 4
Medium package 2 5 3 7 6
Large package 5 10 5 12 10
Extra Large package 10 15 12 16 14
This array of numbers can be put into a matrix - call it “P” the package
matrix:
1 3 2 5 4
2 5 3 7 6
P = 5 10 5 12 10
10 15 12 16 14
Now imagine three containers (Cans, Boxes, and Crates) with different
numbers of packages in each type:
Can 10 8 5 2
Box 15 12 7 3
Crate 40 25 15 10
Put this array into a matrix called “C” the container matrix:
10 8 5 2
C = 15 12 7 3
40 25 15 10
If you wish to find the number of each type of marble in each type of
container, you could do it like this:
Bowlers per Can = 10 small packages per can × 1 Bowler per small
package
+ 8 medium packages per can × 2 Bowlers per medium package
+ 5 large packages per can × 5 Bowlers per large package
+ 2 extra-large packages per can × 10 Bowlers per extra-large package
Matrix Algebra Review 7
Likewise, you can find the number of Cat’s Eyes per can using
Cat’s Eyes per Can=10 small packages×3 Cat’s Eyes per small package
+ 8 medium packages × 5 Cat’s Eyes per medium package
+ 5 large packages × 10 Cat’s Eyes per large package
+ 2 extra-large packages × 15 Cat’s Eyes per extra-large package
= (10)(3)+(8)(5)+(5)(10)+(2)(15)= 150 Cat’s Eyes per Can
And if you wished to find the number of Bowlers per Box, you could use
In addition to showing why the rows of the first matrix are multi-
plied by the columns of the second matrix, this example also illustrates
the point made earlier: when you multiply two matrices, the number of
columns in the first matrix must equal the number of rows in the sec-
8 Matrix Algebra Review
you get a scalar when you multiply a row vector by a column vector
(sometimes called the “inner product” of the matrices) and a matrix
when you multiply a column vector by a row vector (sometimes called
the “outer product” of the matrices), the process is exactly the same in
both cases.
Although matrix multiplication is not commutative (so AB is not nec-
essarily equal to BA), matrix multiplication is associative and distribu-
tive over addition, so for matrices A, B, and C
(AB)C = A(BC)
and
A(B + C) = AB + AC
as long as you remember not to reverse the order of any of the products.
You may be wondering if there’s ever a need to multiply each element
of one matrix by the corresponding element of an equal-size matrix.
There certainly is (for example, when applying a two-dimensional fil-
ter function to an image). This process is called “element-by-element”
or “entrywise” matrix multiplication and the result is sometimes called
the “Hadamard product.” In MATLAB, such multiplication is denoted
A.*B, where the decimal point before the multiplication symbol signifies
element-by-element multiplication.
So (Aij )T = Aji ; notice that the indices have been switched. The trans-
pose of the product of two matrices is equal to the transpose of each
10 Matrix Algebra Review
a a23
Cofactor of (a12 ) = (−1)(1+2) 21 = (−1)(a21 a33 − a31 a23 )
a31 a33
and
a a13
Cofactor of (a22 ) = (−1)(2+2) 11 = (1)(a11 a33 − a31 a13 ).
a31 a33
With cofactors in hand, the determinant of a 3x3 matrix is straight-
forward to find. Simply pick one row or column, and multiply each of
the elements of that row or column by its cofactor and sum the results.
So, for example, if you choose to use the first row of the 3x3 matrix A,
the determinant is given by
|A| = a11 (Cofactor of a11 ) + a12 (Cofactor of a12 ) + a13 (Cofactor of a13 ).
or
|A| = a11 (1)(a22 a33 −a32 a23 )+a12 (−1)(a21 a33 −a31 a23 )+a13 (1)(a21 a32 −a31 a22 ).
The value of the determinant would have been the same if you had used
a different row (or any of the columns) of matrix A, as long as you
multiply each element in your selected row or column by its cofactor
and sum the results.
The same approach can be used to find the determinant of 4x4 and
higher-order matrices; you just have to expand each of the determinants
using elements and cofactors until you get down to the 2x2 level. Of
course, the calculation becomes a bit tedious, so it’s worth your time to
learn to find determinants using a program like MATLAB.
Some useful characteristics of determinants are that the determinant
of the transpose of a matrix equals the determinant of the matrix (so
|AT | = |A|) and the determinant of the product of two matrices is the
same as the determinant of the reverse product (so |AB| = |BA|) pro-
vided that the dimensions of A and B allow both of these products to
be made.
You may also find it useful to know that if a matrix has two identical
Matrix Algebra Review 13
E) Inverse of a matrix
where A, X, and B are all matrices. If you wish to find matrix X from
this equation, here’s one thing you definitely cannot do:
AX B
=
A A
B
X=
A
because this type of division does not work for matrices.
What you can do to find X is this: you can try to find a matrix A−1
(called the “inverse” or “reciprocal” of A) with the following property:
A−1 A = I
where I represents the identity matrix (ones on the diagonal and zeroes
everywhere else). Now you can find X rather easily:
AX = B
−1
A (AX) = A−1 B
−1
(A A)X = A−1 B
IX = A−1 B
X = A−1 B
14 Matrix Algebra Review
2x + 5y − z = 12
−3x − 3y + z = −1
x + y = 1.
or
a11 a12 a13 x1 b1
a21 a22 a23 × x2 = b2 .
a31 a32 a33 x3 b3
and
x1
x = x2
x3
and
b1
b = b2
b3
then the system of equations can be written as a single matrix equation:
Ax = b
x = A−1 b.
The reason that the word “sometimes” appears in the previous sentence
is that there are several conditions which will prevent this approach from
succeeding. For example, the system of equations may be inconsistent -
that is, there may be no set of values for x1 , x2 , x3 that satisfy all three
equations. In that case, you will not be able to find the inverse of A
because it will be a singular matrix. And if matrix b equals zero, you
have a system of homogeneous linear equations, which means there will
be only the trivial solution (x1 = x2 = x3 = 0) if A is non-singular or
an infinite number of solutions if A is singular.
In cases for which A is non-singular and b does not equal zero, you
can find the values of x1 , x2 , and x3 by finding the inverse of matrix
A and multiplying that inverse by matrix b, or you can use Cramer’s
Rule. In that approach, the first unknown (x1 in this case) is found by
replacing the values in the first column of the coefficient matrix (A) with
the elements of matrix b and dividing the determinant of that matrix by
the determinant of A. Here’s how that looks:
b1 a12 a13
b2 a22 a23
b a
32 a33
3
x1 = .
a11 a12 a13
a21 a22 a23
a
31 a32 a33
Likewise, to find the second unknown (x2 in this case), replace the values
Matrix Algebra Review 17
x1 x
x = x2 = y
x3 z
and
b1 12
b = b2 = −1 .
b3 1
Hence
12 5 −1
−1 −3 1
1 1 0
x = x1 =
2 5 −1
−3 −3 1
1 1 0
18 Matrix Algebra Review
so
12[(−3)(0) − (1)(1)] + 5(−1)[(−1)(0) − (1)(1)] − 1[(−1)(1) − (1)(−3)]
x=
2[(−3)(0) − (1)(1)] + 5(−1)[(−3)(0) − (1)(1)] − 1[(−3)(1) − (1)(−3)]
−12 + 5 − 2
= = −3.
−2 + 5 − 0
Proceeding in the same way for y and z gives
2
12 −1
−3 −1 1
1 1 0
y = x2 =
2
5 −1
−3 −3 1
1 1 0
so
−2 + 12 + 2
y= =4
−2 + 5 − 0
and
2 5 12
−3 −3 −1
1 1 1
z = x3 =
2 5 −1
−3 −3 1
1 1 0
so
−4 + 10 + 0
z= = 2.
−2 + 5 − 0
Ax − λ(Ix) = 0
or
(A − λI)x = 0.
|A − λI| = 0.
or
a11 − λ a12 a13
a21
a22 − λ a23 = 0.
a
31 a32 a33 − λ
This expands to
Finding the roots of this polynomial provides the eigenvalues (λ) for
matrix A, and substituting those values back into the matrix equation
Ax = λx allows you to find eigenvectors corresponding to each eigen-
value. The process of finding the roots is less daunting than it may
20 Matrix Algebra Review
appear, as you can see by considering the following example. For the
3x3 matrix A given by
4 −2 −2
A = −7 5 8
5 −1 −4
the characteristic equation is
4−λ −2 −2
−7 5 −λ 8 =0
5 −1 −4 − λ
or
(4 − λ)[(5 − λ)(−4 − λ) − (−1)(8)]
− 2(−1)[(−7)(−4 − λ) − (5)(8)]
− 2[(−7)(−1) − (5)(5 − λ)] = 0.
Multiplying through and subtracting within the square brackets makes
this
(4 − λ)(λ2 − λ − 12) + 2(7λ − 12) − 2(5λ − 18) = 0
or
−λ3 + 5λ2 + 12λ − 36 = 0.
Finding the roots of a polynomial like this is probably best left to a
computer, but if you’re lucky enough to have a polynomial with integer
roots, you know that each root must be a factor of the term not involving
λ (36 in this case). So (+/-) 2,3,4,6,9,12,and 18 are possibilities, and it
turns out that +2 works just fine:
−(2)3 + 5(22 ) + 12(2) − 36 = −8 + 20 + 24 − 36 = 0.
So you know that one root of the characteristic equation (and hence one
eigenvalue) must be +2. That means you can divide a factor of (λ − 2)
out of the equation and try to see other roots in the remainder. That
division yields this:
−λ3 + 5λ2 + 12λ − 36
= −λ2 + 3λ + 18.
(λ − 2)
The roots remaining polynomial on the right-hand side of this equation
are +6 and -3, so you now have
−λ3 + 5λ2 + 12λ − 36 = (λ − 2)(6 − λ)(λ + 3) = 0.
Matrix Algebra Review 21
So matrix A has three distinct eigenvalues with values +6, -3, and +2;
these are the factors by which matrix A scales its eigenvectors. You
could find the eigenvectors of A by plugging each of the eigenvalues
back into the characteristic equation for A, but as long as you can find
N distinct eigenvalues for an NxN matrix, you can be sure that A can
be diagonalized simply by constructing a new diagonal matrix with the
eigenvalues as the diagonal elements. So in this case, the diagonal matrix
(call it A0 ) associated with matrix A is
6 0 0
A0 = 0 −3 0 .
0 0 2
Ae = λ1 e
Af = λ2 f
Ag = λ3 g
which is
a11 e1 + a12 e2 + a13 e3 a11 f1 + a12 f2 + a13 f3 a11 g1 + a12 g2 + a13 g3
AE = a21 e1 + a22 e2 + a23 e3 a21 f1 + a22 f2 + a23 f3 a21 g1 + a22 g2 + a23 g3
a31 e1 + a32 e2 + a33 e3 a31 f1 + a32 f2 + a33 f3 a31 g1 + a32 g2 + a33 g3
References
Riley, K., Hobson, M.P., and Bence, S.J. Mathematical Methods for
Physics and Engineering, Cambridge 2006.