12.1: Basic Matrix Multiplication
- Page ID
- 85044
By Carey Smith
Matrix Multiplication Summary:
A matrix times a vector (3x3 case):
\( A*B =
\begin{matrix}
|a & b & c| \\
|p & q & r| \\
|u & v & w|
\end{matrix} * \begin{matrix}
|x| \\
|y| \\
|z|
\end{matrix} = \begin{matrix}
|a*x & b*y & c*z| \\
|p*x & q*y & r*z| \\
|u*x & v*y & w*z|
\end{matrix}
\)
Matrices do not need to be square, but the number of columns in A needs to equal the number of rows in B.
Matrix multiplication is generally not commutative. That is A*B ≠ B*A, in general.
.
Watch this video about multiplying matrices:
Matlab Video Tutorial: Multiplying Matrices and Vectors, https://www.youtube.com/watch?v=sgzFn42jU6Y
.
A = [3 2 1;
2 1 0
1 0 -1]
B = [4
5
6]
A*B
Solution
A*B =
28
13
-2
% = [28 %(28 = 3*4 + 2*5 + 1*6)
% 13 %(13 = 2*4 + 1*5 + 0*6)
% -2] %(-2 = 1*4 + 0*5 + -1*6)
.
1. True or False: These 2 matrices (which have 3 rows and 2 columns) can be multiplied together:
[ 1 5 ] [ 9 5 ]
A = | 2 9 | B = | 8 9 |
[ 3 4 ] [ 7 5 ]
2. True or False: These 2 matrices can be multiplied together:
[ 1 5 ]
A = | 2 9 |; B = [ 1 3 2 ]
[ 3 4 ] [ 4 6 9 ]
- Answer
-
1. No, because the number of columns in A (2) does not equal the number of rows in B (3).
1. Yes, because the number of columns in A (2) does equal the number of rows in B (2).
Matrix Multiplication Calculation
1. What is A*B ?
A = [1 4
3 -5]
B = [ 2 12
3 1]
(Do a matrix multiply, not an element-by element multiply)
- Answer
-
A*B = [14 16
-9 31]
.
A matrix with ones on the diagonal and zeros elsewhere is called the Identity matrix:
I = eye(3) = [1 0 0
0 1 0
0 0 1]
I*A = A
A*I = A
For more information, see: https://en.Wikipedia.org/wiki/Matrix_multiplication
.