EM1 Ex7 Theory

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

7.

Matrices

Contents

1 Definition of a Matrix 2

2 Vector as a Matrix 2

3 Matrix Operations 3

4 Matrix Addition and Scaling 4

5 Matrix Rows and Columns 5

6 Matrix Multiplication 5

7 Different Types of Matrices 8

8 Determinant 8

9 Inverse Matrix 11

1
1 Definition of a Matrix

A matrix is a table of numbers. The notation (m×n)-matrix, which is read as m cross n matrix
or m times n matrix, refers to a matrix with m rows and n columns. For example,
 
4 2
1 1
is a (2 × 2)-matrix, and  
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
is a (3×9)-matrix. In this material, matrices are represented using square brackets, primarily
because square brackets are also used in MATLAB and MathCad computing programs. It
is also common to see matrices represented with ordinary parentheses, for example, the
aforementioned matrices would be represented as
 
  1 2 3 4 5 6 7 8 9
4 2 1 2 3 4 5 6 7 8 9  .
,
1 1
1 2 3 4 5 6 7 8 9
There is no significant difference; when writing by hand, you can use whichever parentheses
you prefer.

2 Vector as a Matrix

From now on, we interpret and denote that a point in the xy-plane, or a vector (x, y), is the
same as a (2 × 1)-matrix  
x
y
i.e.,  
x
(x, y) = .
y
A plane vector is thus a special case of a matrix, i.e., it is a (2 × 1)-matrix, also called a
column vector. Similarly, a 3D vector or a point in space coordinates (x, y, z) is represented
as  
x
(x, y, z) = y  .

z
 
x  
Note particularly that now (x, y) = is not the same as a (1 × 2)-matrix x y , which is
y
also called a row vector.

2
3 Matrix Operations

The numbers in a matrix are called elements, and matrices are denoted in these materials
with bold capital letters, e.g.,  
4 2
A= .
1 1
The elements of a matrix are referred to with the same letter as the matrix but without
boldface, and with the element’s row and column given as subscripts. Thus, Aij refers to
the element of matrix A that is in row i and column j. For example, if A is as above, then
A21 = 1, and the entire matrix can be written as
 
A11 A12
A= .
A21 A22

In literature, other, more or less confusing notations are used, and unfortunately, there is no
unified practice, nor will there ever be.

The transpose of a matrix means a matrix obtained by swapping its rows and columns.
Thus, the first column of the transpose is the first row of the original matrix, the second
column is the second row of the original matrix, etc. For example, the transpose of the
matrix  
4 2 5
1 1 2
is  
4 1
2 1  .
5 2
The transpose of matrix A is denoted as A⊤ or A∗ . If A is an (n × m)-matrix, then A⊤ is
an (m × n)-matrix.

Matrices are equal if they have the same number of rows and columns and all their elements
are equal. This can be briefly expressed as

A = B ⇐⇒ Aij = Bij , for all i, j.

Matrices with the same number of rows and columns are conformal. Matrices that are not
conformal are non-conformal.

3
4 Matrix Addition and Scaling

Matrices of the same shape can be added together. Matrix addition is done by adding
corresponding elements. This can be written elegantly as

A + B = C ⇐⇒ Cij = Aij + Bij , for all i, j.

The result of the addition is a matrix that has the same shape as the summands. For example,

       
4 2 5 4 2 5 4+4 2+2 5+5 8 4 10
+ = =
1 1 2 1 1 2 1+1 1+1 2+2 2 2 4
     
A11 A12 B11 B12 A11 + B11 A12 + B12
+ =
A21 A22 B21 B22 A21 + B21 A22 + B22

Matrix subtraction is done by subtracting corresponding elements. This can be written


elegantly as
A − B = C ⇐⇒ Cij = Aij − Bij , for all i, j.
For example,
     
A11 A12 B11 B12 A11 − B11 A12 − B12
− =
A21 A22 B21 B22 A21 − B21 A22 − B22

Matrices can be multiplied by numbers. This is called scalar multiplication or scaling, and if
matrix A is multiplied by the number a, it is denoted aA. Scalar multiplication is done by
multiplying each element. This can be written elegantly as

aA = B ⇐⇒ Bij = aAij for all i, j.

The result of scalar multiplication is a matrix that has the same shape as the original matrix.
For example,

     
4 2 5 3·4 3·2 3·5 12 6 15
3 = =
1 1 2 3·1 3·1 3·2 3 3 6
   
A11 A12 aA11 aA12
a = .
A21 A22 aA21 aA22
In particular, the negative matrix of A is −A = −1A and A − B = A + (−B).

4
It is fairly obvious that matrix addition and scalar multiplication follow many similar arith-
metic laws as ordinary addition and multiplication. For example, we have

A+B=B+A
a(A + B) = aA + aB
(a + b)A = aA + bA

5 Matrix Rows and Columns

Sometimes there is a need to extract a row or column from a matrix. For this purpose, so-
called dot notation is used. The notation Ai• refers to the i-th row of matrix A, considered
as a row vector. Similarly, the notation A•j refers to the j-th column of matrix A, considered
as a column vector. For example, if
 
4 2 5
A = 1 1 2 ,
1 2 3

then  
  2  
A1• = 4 2 5 , A•2 = 1 , A3• = 1 2 3 .
2
The notation can be thought of as the dot • being a running parameter that goes through
all the different options.

6 Matrix Multiplication

Matrices can be multiplied together under certain conditions. The product of matrices is
called the matrix product, and unfortunately, calculating it is not as straightforward as
matrix addition or scalar multiplication. The product of matrices A and B, provided it can
be calculated at all, is denoted by AB. The matrix product AB is defined if and only if
matrix A has as many columns as matrix B has rows. When this condition is met, the result
of the matrix product is a matrix that has as many rows as A and as many columns as B.

If A is an (m × n)-matrix and B is an (n × k)-matrix, then the product C = AB is an


m × k-matrix, whose elements are calculated as
n
X
Cij = Aih Bhj .
h=1

5
A simpler way to understand this definition is to think that C = AB is an m × k-matrix,
whose element in row i and column j is obtained by calculating the dot product of the vector
formed from the i-th row of A and the vector formed from the j-th column of B.

For example,       
2 3 2 3 2·2+3·1 2·3+3·2 7 12
= =
1 2 1 2 1·2+2·1 1·3+2·2 4 7

 
  1 2  
4 2 5  4 · 1 + 2 · 0 + 5 · 1 4 · 2 + 2 · 2 + 5 · 1
0 2 =
1 1 2 1·1+1·0+2·1 1·2+1·2+2·1
1 1
 
9 17
=
3 6

6
Matrix multiplication is not commutative, meaning that

AB ̸= BA.

However, matrix multiplication obeys the distributive law and is associative, so

A(B + C) = AB + AC, (A + B)C = AC + BC, A(BC) = (AB)C = ABC.

7
7 Different Types of Matrices

Zero matrix 0 is a matrix where all elements are zeros. There are several zero matrices,
each tailored to the size of the matrix. It is often clear from the context which zero matrix
is meant, or (m × n)-zero matrices can be denoted, for example, as 0m×n .

Square matrix is a matrix where the number of rows equals the number of columns. The
identity matrix I is a square matrix whose main diagonal, i.e., the diagonal starting from
the top left and ending at the bottom right, consists of ones, and all other elements are zeros.
It is often clear from the context which identity matrix is meant, or (m×m)-identity matrices
can be denoted, for example, as Im×m , where
 
1 0 0 0 0 0
0 1 0 0 0 0
   
1 0 0 0 1 0 0 0
I2×2 = , I6×6 =  
0 1 0 0 0 1 0 0
 
0 0 0 0 1 0
0 0 0 0 0 1

It is quite evident that


A+0=A
for all matrices A that are of the same shape as 0. Furthermore, through matrix multiplica-
tion, it can be observed that
IA = AI = A,
for all matrices A that are of the same shape as I. Matrix powers can be defined for square
matrices as well:
An = AA
| {z · · · A}
n times

8 Determinant

(Only!) For square matrices, the determinant det(A) = |A| can be defined as follows:

ˆ If A is a (1 × 1)-matrix a , then
 

|A| = a
 
a b
ˆ If A is a (2 × 2)-matrix , then
c d
a b
|A| = = ad − cb
c d

8
 
a b c
ˆ If A is a (3 × 3)-matrix d e f , then
g h j

a b c
e f d f d e
|A| = d e f = a −b +c .
h j g j g h
g h j

For matrices larger than (3 × 3), determinants can be theoretically defined by following the
same logic, i.e., by expanding them through subdeterminants.

If A is a (4 × 4)-matrix  
a b c d
e f g h
A=
i
,
j k l
m n h i
then
a b c d
f g h e g h e f h e f g
e f g h
|A| = =a j k l −b i k l +c i j l −d i j k .
i j k l
n h i m h i m n i m n h
m n h i
Higher determinants can be expanded similarly. The precise definition requires the concept
of cofactor :
Definition 8.1. The cofactor Cij at element Aij of a square matrix A is defined as follows:

1. Remove the i-th row and j-th column from the original matrix A, resulting in a sub-
matrix Bij .
2. Calculate the determinant of this submatrix |Bij | = Dij .
3. The cofactor Cij is the determinant |Bij | = Dij multiplied by (−1)i+j , i.e., the sign of
the cofactor alternates depending on whether the sum of its row and column indices is
even or odd.

Now the determinant of a square matrix of any size can be defined.


Definition 8.2. Let A be an n × n square matrix. The determinant of matrix A, denoted
det(A) = |A|, is calculated by the formula
n
X
|A| = Aij Cij ,
j=1

where i is any integer in the closed interval [1, n].

9
The determinant can be equivalently expanded with respect to columns. That is, for square
matrix A, we have
Xn
|A| = Aij |Bij |,
i=1

where j is any integer in the closed interval [1, n], and Bij is the submatrix obtained by
removing the i-th row and j-th column from the original matrix A.
 
3 1
For example, let’s calculate the determinant of the matrix . We obtain
5 2

3 1
= 3 · 2 − 5 · 1 = 1.
5 2

For another example, let’s calculate the determinant of the matrix


 
4 5 6
1 2 3
7 8 9

We get

The solution is developed according to the first row. Similarly, we could develop it with
respect to the first column, yielding

     
2 3 5 6 5 6
det(A) = 4 · det − 1 · det + 7 · det
8 9 8 9 2 3
Now let’s calculate the values of these 2 × 2 subdeterminants:

 
2 3
1. det = 2 · 9 − 3 · 8 = 18 − 24 = −6
8 9
 
5 6
2. det = 5 · 9 − 6 · 8 = 45 − 48 = −3
8 9
 
5 6
3. det = 5 · 3 − 6 · 2 = 15 − 12 = 3
2 3

10
Substitute these values into the equation we obtained earlier:

det(A) = 4 · (−6) − 1 · (−3) + 7 · 3 = −24 + 3 + 21 = 0

We arrive at the same result as when developing with respect to the first row, as expected.

Determining the sign of the cofactor coefficient (+1 or -1) can sometimes be challenging. The
following helper matrices can be used:
 
  + − + − +
  + − + −
  + − +  − + − + −
+ − − + − ,
− + − + 
+ − + − +

,  ,
− +  + − + −   
+ − +  − + − + −
− + − +
+ − + − +

9 Inverse Matrix

The inverse matrix A−1 of a square matrix A is a matrix of the same shape such that

AA−1 = A−1 A = I.

It can be shown that A−1 exists if and only if det(A) ̸= 0.

The inverse matrix of a (1 × 1) matrix a is a−1 .


   

 
a b
If A is a (2 × 2) matrix and det(A) ̸= 0, then it can be shown that
c d
 
−1 1 d −b
A = ,
det(A) −c a
which is the matrix obtained from the original by swapping the places of the main diagonal
elements, changing the off-diagonal elements to their negatives, and then multiplying this
resulting matrix by the reciprocal of the determinant.
 
99 2 99 2
For example, for the matrix , there is no inverse matrix since = 0.
0 0 0 0
 
1 2
The determinant of the matrix is 1 · 0 − 3 · 2 = −6, and its inverse matrix is
3 0

0 13
   
1 0 −2
= 1 .
−6 −3 1 2
− 16

11
This can be verified by calculation:

1 2 0 13
    
1 0
= .
3 0 12 − 16 0 1

Calculating the inverse matrix for larger matrices is laborious and challenging. We do not
currently address how to compute them by hand. However, inverse matrices of larger matrices
are denoted in exactly the same way as for (2 × 2) matrices, and their computation can be
done with a computer.

12

You might also like