Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Matrices Lecture 1 PDF

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

Matrices

Matrix Operations
What is a Matrix?
• A matrix is a rectangular array of numbers

1 4 3
2 5 1

Our example matrix has 2 rows and 3 columns.


Rows go left-right, and columns go up-down.
We say that the order of the matrix is 2x3. (rows x
columns)
A matrix is usually shown by a capital letter (such as
A, B, C etc.)
• Each number in a matrix is a matrix element
• An m x n matrix is a rectangular array of numbers with
m rows and n columns. In the matrix shown below,
• m = 4, n = 4
𝑎11 𝑎12 𝑎13 𝑎14
𝑎21 𝑎22 𝑎23 𝑎24
• 𝑎31 𝑎32 𝑎33 𝑎34
𝑎41 𝑎42 𝑎43 𝑎44

• If m = n, the matrix is said to be square.


• The size of a matrix is given by m x n.
Adding Matrices

1 2 5 6 1+5=𝟔 2+6=𝟖
+ =
3 4 7 −8 3+7=𝟏𝟎 4+ −8 = − 𝟒

• The matrices above are 2x2 matrices


• To add two matrices, add the numbers in the
matching positions.

Subtracting Matrices
• This is similar to addition, except that you
would now subtract the numbers in the
matching positions.
5 6 1 3 5−1 = 𝟒 6−3 = 𝟑
- =
7 −8 2 1 7−2 = 𝟓 −8−1 = −𝟗
Point to remember:
• To add and subtract matrices, the two matrices
must be the same size, m x n, i.e. the rows must
match in size, and the columns must match in
size.
• Example: a matrix with 3 rows and 5 columns can
be added to another matrix of 3 rows and 5
columns. Both matrices are 3 x 5.
• But it could not be added to a matrix with 3
rows and 4 columns (the columns don't match in
size). You cannot add a 3 x 5 matrix to a 3 x 4
matrix.
• Example: Suppose that Brown, Joan and Smith
go to a grocery store and purchase the following
items:
• Brown purchases 2 apples, 6 lemons and 5
mangoes
• Joan purchases 12 eggs, 2 lemons and 6 mangoes
• Smith purchases 4 apples, 6 eggs and 10
mangoes.
• Construct a matrix that shows the various
purchases of Brown, Joan and Smith.
A L M E
2 6 5 0
• 0 2 6 12
4 0 10 6
Multiply a matrix by a constant
• We can multiply a matrix by some value.

1 −2 2∗1 = 𝟐 2∗ − 2 = −𝟒
2 =
0 4 2∗0 = 𝟎 2∗4 = 𝟖

In our example, we multiply each element of the


matrix by the constant 2.
Matrix Multiplication
2 1
1 4 3
x 0 3 =
2 5 1
−1 4

1∗2 + 4∗0 + 3 −1 = −𝟏 1∗1 + 4∗3 + 3∗4 = 𝟐𝟓


2∗2 + 5∗0 +1 −1 = 𝟑 2∗1 + 5∗3 +1∗4 = 𝟐𝟏
Point to Remember
To multiply 2 matrices,
• The number of columns of the 1st matrix must
equal the number of rows of the 2nd matrix.
Otherwise the product is undefined.
• The result will have the same number of rows as
the 1st matrix, and the same number of columns
as the 2nd matrix.
• Note that in our multiplication example, we
multiplied a 2x3 matrix by a 3x2 matrix. Our
product was a 2x2 matrix.
• When you multiply an m×n matrix by
an n×p matrix, the product is an m×p matrix.
Matrix Multiplication
• In order to multiply matrices,
• Step 1: Make sure that the number
of columns in the 1st matrix equals the
number of rows in the 2nd matrix. (The pre-
requisite to be able to multiply)
• Step 2: Multiply the elements of each row of
the first matrix by the elements of each
column in the second matrix.
• Step 3: Add the products.
Order of Multiplication of Matrices
• In arithmetic, 3*5 = 5*3 (commutative law)
• But this is not generally true for matrices
(matrix multiplication is not commutative):
AB ≠ BA
• When you change the order of multiplication
of the matrices, the answer is (usually)
different.
• Example:
• See how changing the order affects this
multiplication:
1 2 2 0 𝟒 𝟒
=
3 4 1 2 𝟏𝟎 𝟖

2 0 1 2 𝟐 𝟒
=
1 2 3 4 𝟕 𝟏𝟎
Identity Matrix
• The "Identity Matrix" is the matrix equivalent of
the number "1":
2x2 Identity matrix 3x3 Identity matrix
𝟏 0 0
𝟏 0
0 𝟏 0
0 𝟏
0 0 𝟏

• It is "square" (has same number of rows as


columns),
• It has 1s on the diagonal and 0s everywhere else.
• It's symbol is the capital letter .
Identity Matrix
• It is a special matrix, because when you multiply a
matrix A by it, the product is the original matrix A.
• (Arithmetic: 3*1 = 3; 1*3 = 3)
• A× =A

• ×A=A
1 2 1 0 1x1+2x0 = 𝟏 1x0+2x1 = 𝟐
=
3 4 0 1 3x1+4x0 = 𝟑 3x0+4x1 = 𝟒

1 0 1 2 1x1+3x0 = 𝟏 1x2+0x4 = 𝟐
=
0 1 3 4 0x1+1x3 = 𝟑 0x2+1x4 = 𝟒
Determinant of a Matrix
• The determinant of a matrix is a number that
tells us things about the matrix that are useful
in systems of linear equations, helps us find
the inverse of a matrix, is useful in calculus
and more.
• The symbol for determinant is two vertical
lines either side.
Example:
|A| means the determinant of the matrix A
Determinant of a 2x2 matrix
• In order to calculate the determinant of a matrix, the
matrix must be square (i.e. have the same number of rows
as columns)
• For a 2×2 matrix A (2 rows and 2 columns):
𝑎 𝑏
A=
𝑐 𝑑
the determinant is:
|A| = ad - bc
• The determinant of A = a * d minus b * c

𝑎 𝑏
𝑐 𝑑
Example
• What is the determinant of the matrix
4 6
B=
3 8

4 6
𝐵 = = 4*8 – 6*3
3 8
=32– 18 = 14
Determinant of a 3x3 matrix
• For a 3×3 matrix (3 rows and 3 columns):

𝑎 𝑏 𝑐
A= 𝑑 𝑒 𝑓
𝑔 ℎ 𝑖
the determinant is:
|A| = a|ei – fh| – b|di – fg| + c|dh – eg|

• Note the alternating signs.


Determinant of a 3x3 matrix
Determinant of a 3×3 matrix
• Multiply a by the determinant of
the 2×2 matrix that is not in a's
row or column.
• Likewise for b, and for c
• Add them up, but remember
that b has a negative sign!
As a formula (remember the vertical
bars || mean "determinant of"):

The determinant of A equals a times the determinant of ... etc


Example
• Find the determinant of
6 1 1
C= 4 −2 5
2 8 7
6 1 1
𝐶 = 4 −2 5
2 8 7

= 6(-2*7 – 5*8) − 1(4*7 – 5*2) + 1(4*8 – (-2)*2)


= 6*(-54) − 1*18 + 1*36
= -306
Shortcut Method for Determinant of 3x3 matrix

2 1 1
• Given P = 3 5 2 , find |P|
4 3 3
__ __ __

2 1 1 2 1
3 5 2 3 5
4 3 3 4 3
+ + +
|P| = 2*5*3 + 1*2*4 + 1*3*3 – 4*5*1 – 3*2*2 –
3*3*1
• = 30 + 8 + 9 – 20 – 12 – 9
• = 6
Transposing a Matrix
• To "transpose" a matrix, swap the rows and columns. We
put a "T" in the top right-hand corner to mean transpose:
𝑻
1 4 3 1 2 3 𝑇 1 2
2 5 1 = 4 5 6 1 4 3
= 4 5
3 6 7 2 5 1
3 1 7 3 1
• The transpose is essentially formed by writing the columns
of the original matrix as rows in the new matrix (or rows of
the original matrix as columns in the new matrix).
• Note that the diagonal remains fixed. So, the transpose
can also be created by simply swapping the elements
across the diagonal.
• The transpose of an a x b matrix is a b x a matrix. For
example, in our 2nd example, the transpose of a 2x3 matrix
is a 3x2 matrix.
Matrix Division
• We don’t really divide matrices. Instead, we
multiply by an Inverse.
A/B = A * (1/B) = A B-1
where B-1 means the "inverse" of B.
Inverse of a Matrix
• The Inverse of a Matrix is the same idea as
the reciprocal of a number:

• But we don't write 1/A (because we don't


divide by a Matrix!), instead we write A-1 for
the inverse:

• (In fact 1/8 can also be written as 8-1)


Inverse of a Matrix
• When you multiply a number by its
reciprocal you get 1; for example , 8 × (1/8) = 1
• When you multiply a Matrix by its Inverse you
get the Identity Matrix (which is like "1" for
Matrices): A * A-1 =
• It also works when the inverse comes
first: (1/8) × 8 = 1 and A-1 * A =
• So we have a definition of a Matrix Inverse ...
The Inverse of A is A-1 only when:
A A-1 = A-1 A =
• Sometimes there is no Inverse at all.
Inverse of a 2x2 matrix

In other words: swap the positions of


a and d, put negatives in front of b
and c, and divide everything by the
determinant (ad-bc).
Example
• How do we know this is the right answer?
• Remember it must be true that: A A-1 = I
• So, let us check to see what happens when we multiply
the matrix by its inverse:
1 6 −7 4 7
10 −2 4 2 6
1 24 − 14 42 − 42
=
10 −8 + 8 −14 + 24
1 10 0
=
10 0 10

1 0
= We end up with the Identity Matrix! So it must be right.
0 1
Requirements for Inverse to Exist
• First of all, to have an Inverse, the Matrix must
be "Square" (same number of rows and
columns).
• Also the determinant cannot be zero (or you
would end up dividing by zero).

• When the inverse of a matrix does not exist,


we say that the matrix is singular.
24-24? That equals 0, and 1/0 is undefined.
We cannot go any further! This Matrix has no Inverse.

Such a Matrix is called "Singular", which only happens when


the determinant is zero.

You might also like