Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

6 Matrices

A matrix is a square or rectangular array of numbers, for instance


A=
1 2
3 4[ ]
is a two-row, two-column matrix. The numbers are called the elements of the matrix.

We have seen that vectors represent shapes. Matrices are important because computers use
them to manipulate vectors. Changes in the shapes, and interactions between shapes
represented by vectors, are achieved by applying matrices to the vectors. We say that the
matrix transforms the vector.

Square Matrices

Square matrices are particularly important because they encode information about how things
change or transform. Every square matrix has a special number calculated from its elements,
called the determinant of the matrix. The determinant encodes information about changes of
scale. By swapping rows for columns, we find the transpose AT of the matrix. And by a lot of
arithmetic, we can find the inverse A-1 (if it has one). These are useful in performing matrix
operations (see below).

Finding the Determinant

This is easy for a 22 matrix. If the matrix is

[ ac bd ]
Then its determinant can be remembered as adbc (Anno Domini minus Before Christ). For
example, for A,

| A|=ad −bc=1 ×4−3 × 2=4−6=−2


For a 33 matrix it’s not so easy. If the matrix is

[ ]
a b c
d e f
g h i

Then its determinant is;

a× |eh fi|−b ×|dg fi|+a ×|dg eh|


¿ a × ( e ×i−f ×h )−b × ( d ×i−f × g )+ c × ( d × h−e × g ) .

Let’s dissect this. a, b, c are the elements from the first row. The 22 determinants matched
with these are formed from the elements in the other two columns, below the first row- these
are called the cofactors of the element. Visually;
An example should assist . Take the 33 matrix

[ ]
2 3 5
M= 4 2 1
2 3 4

Then think of dividing the matrix this way;

And from this we get

2× |23 14|−3×|42 14|+ 5×|42 32|


¿ 2 × ( 2 × 4−1 ×3 )−3 × ( 4 × 4−1× 2 )+ 5× ( 4 × 3−2 ×2 )

¿ 2 × ( 8−3 )−3 × ( 16−2 ) +5 × (12−4 )

¿ 2 × ( 5 ) −3× ( 14 ) +5 × ( 8 )

¿ 10−42+40

¿8

Exercise 1. Find the determinants of the following matrices.

[ ] [ ]
−2 4 5 −2 4 7
A=
[ ] [
4 2
3 1
, B=
−5 7
4 11 ]
, D= 3 2 1 , E= 3 −5 1
1 4 4 −1 2 2
Finding the Transpose

This not difficult. The transpose of a matrix swaps rows for columns and vice-versa. So, for
A,

A =
T
[12 34 ]
And for M,

[ ]
2 4 2
−T
M =3 2 3
5 1 4

In order to find the inverse, we need information on identity matrices and row operations.

Identity Matrices

A square matrix with 1s on its main diagonal and 0s everywhere else is an identity matrix,
symbol I. For instance,

I 2=
[ 10 01]
is the identity matrix for the set of 22 matrices,

[ ]
1 0 0
I 3= 0 1 0
0 0 1

That for the set of 33 matrices, and so on.

When a square matrix is multiplied by the identity matrix for its set, the result is the same
matrix. It’s like when you multiply a number by 1, you always get the same number.
Similarly, when you multiply a matrix by its inverse (if it has one) you always get the
identity matrix- it’s like dividing a number by itself, you always get 1 (see below for
multiplication of matrices).

Finding the Inverse

Inverse of a 22 Matrix

The inverse A1 of a 22 matrix A can be found in three steps. Take the matrix to be
A=
a b
c d [ ]
1. Swap a and d
2. Multiply b and c by 1
3. Divide throughout by the determinant of A.

Example
A=
[ 83 62]
Has determinant
8 ×2−6 ×3=16−12=4
Hence the inverse is
−1
A =
[
1 2 −6
4 −3 8 ]
¿
[ 2 /4 −6 /4
−3 /4 8 /4 ]
¿
[ 1/2 −3/2
−3 /4 2 ]
Matrices of Size 33 and Above

We can use the identity matrix to get the inverse of a matrix. It takes some arithmetic called
row operations. The three row operations are;

1. You can multiply or divide any row by some number


2. You can add any two rows together
3. You can subtract any row from any other row

If you take any matrix, you can use row operations to change it into its identity matrix. If you
keep a record of the row operations you did, you can apply these to the identity matrix and
the result will be the inverse. We will just perform the row operations on A and its identity
side by side. In every step, we’re aiming to find zeroes and ones. It’s really one of those
things you get good at by practicing.

[ 13 24] [ 10 01] start with A and its identity matrix

[ 33 64] [ 30 01] multiply row 1 by 3


[ 30 -26 ] [ -33 01] take row 1 away from row 2
[ 30 66] [39 −30 ] multiply row 2 by -3
[ 30 06] [−69 −33 ] take row two away from row 1
[ 10 01] [3−2/2 −1/2 1
] divide row 1 by 3 and row two by 6
For 33 matrices, it’s not more complicated, just more long-winded.
[ ] [ ]
2 3 5 1 0 0
4 2 1 0 1 0 start with M and its identity matrix
2 3 4 0 0 1

[ ] [ ]
2 3 5 1 0 0
4 2 1 0 1 0 take row 1 away from row 3
0 0 −1 −1 0 1

[ ][ ]
2 3 5 1 0 0
0 −4 −9 −2 1 0 take 2× row 1 away from row 2
0 0 −1 −1 0 1

[ ] [ ]
2 3 0 −4 0 5
take 9 × row 3 away from row 2
0 −4 0 7 1 −9
add 5 × row 3 to row 1
0 0 −1 −1 0 1

[ ] [ ]
2 −1 0 3 1 −4
0 −4 0 7 1 −9 add row 2 to row 1
0 0 −1 −1 0 1

[ ] [ ]
2 −1 0 3 1 −4
divide row 2 by -4
0 1 0 −7/ 4 −1/4 9 /4
divide row 3 by -1
0 0 1 1 0 −1

[ ] [ ]
2 0 0 5/4 3 /4 −7 /4
0 1 0 −7/ 4 −1/4 9 /4 add row 2 to row 1
0 0 1 1 0 −1

[ ] [ ]
1 0 0 5 /8 3/8 −7 /8
0 1 0 −7/ 4 −1/4 9/4 divide row 1 by 2
0 0 1 1 0 −1

Important Rule: Matrices have an inverse only if their determinant is non zero.

Exercise 2. Find the inverses of the following matrices.

[ ] [ ]
−2 4 5 −2 4 7
A=
[ ] [
4 2
3 1
, B=
−5 7
4 11 ], D= 3 2 1 ,
1 4 4
E= 3 −5 1
−1 2 2

Orthogonal Matrices

These are matrices whose inverse is the same as their transpose, which makes them very easy
to work out.

Matrix Operations

Matrices are important because computers use them to encode information about shapes.
Changes in shape, and interactions between shapes, are achieved by changing the numbers.
But to write accurate programs, the rules by which matrix numbers change, called matrix
operations, must be learned by the programmer.

Adding and Subtracting Matrices

Any two matrices can be added or subtracted if they have the same number of rows and
columns.

Matrix A plus matrix B (A+B) is the matrix of the sums of their elements. For example, if
B=
4 3
2 1 [ ]
then

[ ][ ][
1 2 4 3 1+ 4 2+3
3 4 2 1
+ =
3+2 4 +1
=
5 5
5 5
. ][ ]
Matrix A minus matrix B (A-B) is the matrix of the differences of their elements. For
example,

A−B=
[13 24 ]−[ 42 31]=[1−4
3−2 4−1 1 ][
2−3 −3 −1
=
3 ]
Exercise 3. Find A+B, D+E.

[ ] [ ]
−2 4 5 −2 4 7
A=
[ ] [
4 2
3 1
, B=
−5 7
4 11 ]
, D= 3 2 1 , E= 3 −5 1
1 4 4 −1 2 2

Multiplying a matrix by a Scalar

A scalar (an ordinary number) multiplies a matrix by multiplying all the elements inside the
matrix. For example,

3 A=3
[ 13 24]=[ 33 ×1
×3
3×2
3×4
=
][
3 6
9 12
. ]
Multiplying Two Matrices Together

Is altogether trickier. First, you can only multiply AB if A has the same number of columns
as B does rows. That is, MOMS ACE BRA;
Matrices Only Multiply Should A’s Columns Equal B’s Rows.
(Actually!)

To multiply AB, multiply every row of A into every column of B.

AB= [ ][ ]
1 2 4 3
3 4 2 1
=
[ [1 2] 4

[3 4]
[ 2]
[ 42 ]
[1 2] 3

[3 4]
[ 1]
[ 31] ]
¿
[31×× 44++24 ×2
×2
1× 3+2× 1
3 ×3+ 4 ×1
=
][
4+ 4 3+ 2
12+8 9+ 4
=
8 5
20 13 ][ ]
MATRICES might help; Multiply Any Two Row Into Column, Evaluate Sum. But practice
is best.
A surprising thing about matrices is that multiplication is non-commutative. That is, AB
does not have to equal BA.

BA= [ ][ ]
4 3 1 2
2 1 3 4
=
[ [4 3] 1

[2 1]
[ 3]
[ 13]
[4 3] 2

[2 1]
[ 4]
[ 24 ] ]
¿
[ 42 ×1+3 ×3
×1+1× 3
4 ×2+3 × 4
2× 2+1× 4
=
][
4+9 8+12
2+3 4+ 4
=
13 20
5 8 ][ ]
≠ AB

Exercise 4. Find AB and DE.

[ ] [ ]
−2 4 5 −2 4 7
A=
[ ] [
4 2
3 1
, B=
−5 7
4 11 ]
, D= 3 2 1 , E= 3 −5 1
1 4 4 −1 2 2

“Dividing” Matrices

Can one matrix be divided by another? Well sort of. To “divide” a matrix by a second matrix,
we multiply the first matrix by the inverse of the second matrix. The inverse of B above is

−1
B =
[−1/2
1 −2 ]
3/2
.
Then AB is really AB-1;

AB =
3 4 1 −2[ ][
1 2 −1 /2 3/2
−1
= ] [ [3 4]
[1]
[ 1 2 ] −1 /2

[−1/2
1 ]
[ 1 2 ] 3 /2

[3 4]
[ −2 ]
[ 3/2
−2 ]
]
¿
[ 1× (−1/2 ) +2 ×1 1 ×3 /2+ 2× (−2 )
=
−1/2+2 3 /2−4
3 × (−1 /2 )+ 4 ×1 3 ×3 /2+ 4 × (−2 ) −3 /2+ 4 9/2−8 ][ ]
[ 3/2
5/2
−5 /2
−7 /2 ]
Exercise 5. Find A/B, D/E (use B-1 and E-1 from Exercise 2).

[ ] [ ]
−2 4 5 −2 4 7
A=
[ ] [
4 2
3 1
, B=
−5 7
4 11 ]
, D= 3 2 1 , E= 3 −5 1
1 4 4 −1 2 2

You might also like