2.3 Matrix Equations¶
The key to understanding matrix multiplication is the dot product of two vectors. The book calls this the row-column recipe for matrix-vector multiplication.
The dot product is the sum of the component-wise products.
MATLAB has a dot product function called, not too surprisingly, dot
.
x = [-1 ; 1 ; 5]
y = [ 1 ; 3 ; -1]
dot(x,y)
x =
-1
1
5
y =
1
3
-1
ans =
-3
When multiplying a matrix by a vector, as in \(A\vec x\), we take the dot product of each row with the vector.
This means that the matrix must have the same number of columns as there are components (rows) of \(\vec x\). If \(A \vec x = \vec b\), then the first component of \(\vec b\) is the dot product of the first row of \(A\) with \(\vec x\).
The second component is the product of the second row and \(\vec x\), and so on.
We can have MATLAB do the multiplication to verify our work that shows
If we create vectors \(\vec r_1,\vec r_2,\vec r_3\) from the rows of \(A\), we can use the dot product function to check.
A = [3 -2 3 -2 ; -2 -2 0 1 ; 0 4 5 1 ];
r1 = A(1,:)
r2 = A(2,:)
r3 = A(3,:)
x = [-2 ; 1 ; 5 ; 0]
r1 =
3 -2 3 -2
r2 =
-2 -2 0 1
r3 =
0 4 5 1
x =
-2
1
5
0
b = [ dot(r1,x) ; dot(r2,x) ; dot(r3,x) ]
b =
7
2
29
Of course, we can simply use MATLAB’s multiplication function to verify \(\vec b\).
b = A * x
b =
7
2
29
This explains why, when we row reduce the augmented matrix \([A|\vec b]\), we find the vector \(\vec x\).
rref([A,b])
ans =
1.0000 0 0 -0.6486 -2.0000
0 1.0000 0 0.1486 1.0000
0 0 1.0000 0.0811 5.0000