Sei sulla pagina 1di 6

Math 415 - Lecture 4

Matrix operations

Monday August 29 2016


Textbook: Chapter 1.3, 1.4
Suggested Practice Exercise: Chapter 1.4 Exercise 1, 2, 10, 12, 13, 21, 30, 34, 45,
Khan Academy Video: Matrix multiplication (part I)

Matrices
Two ways to denote m n matrix A (m rows, n column).
In terms of the columns of A:


A=
In terms of the entries of A:

a1

a2

an

a11
a21

A= .
..

a12
a22
..
.

..
.

a1n
a2n

..
.

am1

am2

amn

aij is in the ith row and jth column


aj is j th column:

a1j
a2j

aj = .
..
amj
Main diagonal entries: a11 , a22 , . . ., amm (only care about these when m = n)
Even more notation
Zero matrix:

0
..
.

0=
0
.
..
0
1

0
..
.
0
..
.
0

0
..
.

..
.
0


Definition. Let A = a1
scalar. Then



an , B = b1

a2

b2


bn be m n-matrices and let r be a

A + B is defined by

A + B = a1 + b1

a2 + b2

...

an + bn

Moreover, rA is defined as

rA = ra1

ra2

...

ran

Example 1. Calculate


1
5

 
 

0
2 3
3 3
+
=
2
3 1
8 3

 

2 3
20 30
10
=
3 1
30 10

Remark. Of course, we could have defined


matrix addition inin terms ofthe entries
a11 a12 a1n
b11 b12
a21 a22 a2n
b21 b22

(and not in terms of columns). So if A = .


..
.. and B = ..
..
..
..
.

.
.
.
.
am1 am2 amn
bm1 bm2
then indeed

a11 + b11
a12 + b12 a1n + b1n
a21 + b21
a22 + b22 a2n + b2n

A+B =
.
..
..
..
..

.
.
.
.
am1 + bm1 am2 + bm2 amn + bmn

of matrices

b1n
b2n

.. ,
..
.
.

bmn

It is simply more convenient to define in terms of the columns.


Definition. Let A1 , . . . , Ak be m n-matrix and r1 , . . . , rk numbers, then
r1 A1 + + rk Ak
is a linear combination of A1 , . . . , Ak .
Theorem 1. Let A, B, and C be matrices of the same size, and let r and s be scalars.
A+B =B+A
(A + B) + C = A + (B + C)
A+0=A
r(A + B) = rA + rB
(r + s) A = rA + sA
r (sA) = (rs) A
Remark. Here matrices behave like usual numbers! We will see later this is not always the case.

Example 2. We can think of a grayscale picture consisting of m n many pixels as an m n matrix


(aij )1im,1jn in this vector space where all the aij s are between 0 and 1. Here the entry aij of
a grayscale picture represents the grayscale value of the pixel at position i, j in this picture. So the
value 1 means the pixel is white and 0 means the pixel is black. The operations defined correspond
to operations your favorite image manipulation software can carry out. For example, let P1 and P2
be two grayscale pictures. Then taking the linear combination 12 P1 + 21 P2 is the same as blending the
two pictures together. For example,

1
2

1
2

Lets look at few other operations.


(a) Which linear operation corresponds to changing the brightness of a grayscale picture?
(b) Let P be a grayscale picture and let B be the m n-matrix all whose entries are 1. Calculating
B P correspond to which function of your favorite image manipulation software?
Solution.
(a) This will correspond with scalar multiplication.
(b) This will invert the brightness of a picture. At brighter pixels, we will now have darkness
(because if aij is near to 1, then B P will have an entry near to 0). Similarly dark pixels will
become brighter.

Matrix Multiplication

Definition. Let x be a vector in Rn and A = a1

...


an an m n-matrix. We define Ax by

Ax = x1 a1 + x2 a2 + . . . + xn an .
Remark.
It is important to realize that Ax is a linear combination of the columns of A that uses the
corresponding entries in x as weights.
The product Ax is only defined if the number of entries of x is equal to the number of columns
of A.
Example 3. Consider

2
A=
1


0
,
1

1
B = 0
3

Determine Ax and Bx.

2
1 ,
5

 
2
x=
3

Solution.
Ax =


2
1

1
Bx = 0
3

 
 
   
0 2
2
0
4
=2
+3
=
1 3
1
1
5



2  
1
2
8
2
1
= 2 0 + 3 1 = 3
3
5
3
5
21

Example 4. Consider the following vector equation


 
   
1
3
0
x1
+ x2
=
.
2
4
2
Is there a matrix 2 2 matrix A such that x1 , x2 is a solution to the above equation if and only if
   
x
0
A 1 =
?
x2
2
Solution.
Take A =


1
2


 
3
3
and x =
. Then
4
1
Ax =


1
2

 
 
 
3 x1
1
3
= x1
+ x2
.
4 x2
2
4

We already knew that solving a Linear System is finding Linear Combinations.


Now we know that finding linear Combination is the same as solving a matrix equation!


Theorem 2. Let A = a1 . . . an be an m n-matrix and b in Rm . Then the following are
equivalent


A b
(x1 , x2 , . . . , xn ) is a solution of the system with augmented matrix
(x1 , x2 , . . . , xn ) is a solution of the vector equation x1 a1 + x2 a2 + + xn an = b

x1
..
. is a solution to the matrix equation Ax = b.
xn
From now on we will write Ax = b for the system of equations with augmented matrix

A matrix is a machine
Let A be a m n matrix. So n columns, m rows. How is it a machine?
Input: n-component vector x Rn .
Output: m-component vector b = Ax Rm .
x

Ax


b .

Example 5. Consider the matrix A =


0
1


1
. What does this machine do?
0

Solution. 
x
Let x = 1 be our input.
x2
Ax =


0
1

 
 
   
1 x1
0
1
x
= x1
+ x2
= 2 .
0 x2
1
0
x1

So the machine A switches the entries of the vector x. Geometrically speaking, this machine reflects
across the x1 = x2 -line.


1 0
Example 6. Consider the matrix B =
. What does this machine do?
0 0
Solution. 
x
Let x = 1 be our input.
x2

1
Bx =
0

0
0

 
 
   
x1
1
0
x
= x1
+ x2
= 1 .
x2
0
0
0

So the machine B replace the second entry of the vector x by 0. Geometrically speaking, this machine
projects a vector onto the x1 -axis.
Composition of machines. Let A be an m n matrix and B be an k l matrix. Now we can
compose the two machines:
x

Ax

B(Ax)
B

Question. This composition only works for some k, l, m, n. For which?


Solution.
If A is a m n-matrix and x in Rn , then Ax is in Rm . In order to calculate B(Ax) when then need
B to have m columns. So we need l = m. Both n and k can be arbitrary.

Example 7. Let A, B be as in the previous two examples. Is A(Bx) = B(Ax)?


Solution.
No!

 
   
1
1
0
A(B
)=A
=
2
0
1
 
   
1
2
2
B(A
)=B
=
2
1
0

Projection and reflection do not commute! Draw a picture!

Linearity
The most important property of the machine corresponding to a matrix A is that it plays nice with
linear combinations.
Theorem 3. Let A be a matrix, x, y vectors and c, d scalars. If the input vector is a linear combination then also the output vector is a linear combination:
A(cx + dy) = cAx + dAy.
To see this write both sides out! This property of matrix multiplication is called Linearity.
Example 8. Assume we have a linear system Ax = b. Suppose x and y are two distinct solutions.
Why are there infinitely many solutions?
Solution.
Let x, y be such that x 6= y, Ax = b and Ay = b. Let us subtract:
Ax Ay = b b = 0.
The left hand side is a linear combinations of outputs of A, so it is A applied to a linear combination:
A(x y) = 0.
Define then the difference vector z = x y, so that Az = 0. This is not zero because x and y are
distinct. Then we can use the vector z to produce many solutions: choose a scalar c, and calculate
again using linearity
A(x + cz) = Ax + cAz = b + c0 = b.
So we see that we get infinitely many new solutions x + cz, if we have found just two solutions.

Potrebbero piacerti anche