Consider the following matrices:
\[
\mathbf{X} = \begin{bmatrix}2 & 3 \\1 & 2 \end{bmatrix} \qquad \mathbf{Y} = \begin{bmatrix}3 & 4 \\2 & 1 \end{bmatrix} \qquad \mathbf{Z} = \begin{bmatrix}2 & 3 & 1 \\5 & 6 & 8\\9 & 4 & 7 \end{bmatrix}
\]
Find \(\mathbf{X} + \mathbf{Y}\) .
Show/Hide Solution
\[
\begin{split}
\mathbf{X}+\mathbf{Y} &= \begin{bmatrix}2+3 & 3+4 \\1+2 & 2+1 \end{bmatrix} \\[1em]
&= \begin{bmatrix}5 & 7 \\3 & 3 \end{bmatrix}
\end{split}
\]
Find \(\mathbf{X} - \mathbf{Y}\) .
Show/Hide Solution
\[
\begin{split}
\mathbf{X}-\mathbf{Y} &= \begin{bmatrix}2-3 & 3-4 \\1-2 & 2-1 \end{bmatrix} \\[1em]
&= \begin{bmatrix}-1 & -1 \\-1 & 1 \end{bmatrix}
\end{split}
\]
Find \(3 \mathbf{Z}\) .
Show/Hide Solution
\[
\begin{split}
3\mathbf{Z} &= \begin{bmatrix}3(2) & 3(3) & 3(1) \\3(5) & 3(6) & 3(8)\\3(9) & 3(4) & 3(7) \end{bmatrix} \\[1em]
&= \begin{bmatrix}6 & 9 & 3 \\15 & 18 & 24\\27 & 12 & 21 \end{bmatrix}
\end{split}
\]
Find \(-2 \mathbf{X} + 4\mathbf{Y}\) .
Show/Hide Solution
\[
\begin{split}
-2\mathbf{X}+4\mathbf{Y} &= \begin{bmatrix}-2(2)+4(3) & -2(3)+4(4) \\-2(1)+4(2) & -2(2)+4(1) \end{bmatrix} \\[1em]
&= \begin{bmatrix}8 & 10 \\6 & 0 \end{bmatrix}
\end{split}
\]
Consider the following matrices:
\[
\mathbf{A} = \begin{bmatrix}0 & 6 \\5 & 1 \end{bmatrix} \qquad \mathbf{B} = \begin{bmatrix}0 & 5 \\2 & \frac{1}{2} \end{bmatrix} \qquad \mathbf{C} = \begin{bmatrix}6 & 2 & 1 \\5 & 3 & 1\\8 & 4 & 1 \end{bmatrix} \qquad \mathbf{D} = \begin{bmatrix}0& 1 & 4 & 6 \\1 & 2 & 5 & -2\\1 & 3 & 2 & 8 \end{bmatrix}
\]
Is AB conformable?
Show/Hide Solution
Yes. Since A has two columns and B has the same number of rows, AB is conformable.
\[
\underset{2\times\color{red}{2}}{\mathbf{A}}~\underset{{\color{red}{2}} \times2}{\mathbf{B}}
\]
Is BC conformable?
Show/Hide Solution
No. Since B has two columns and C has three rows, BC is not conformable.
\[
\underset{2\times\color{red}{2}}{\mathbf{B}}~\underset{{\color{red}{3}} \times3}{\mathbf{C}}
\]
Is the product where we premultiply D by C conformable?
Show/Hide Solution
Yes. Since C has three columns and D has the same number of rows, CD is conformable.
\[
\underset{3\times\color{red}{3}}{\mathbf{C}}~\underset{{\color{red}{3}} \times4}{\mathbf{D}}
\]
Statistics Example: Weights
Consider the scores for five students on four course exams (each out of 100 points) shown in matrix X . The final percentage in the course is based on the following weighting: the first and second exams are worth 10% of the course, the third exam is worth 30% of the course, and the fourth exam is worth 50% of the course. These weights are presented in the column vector w . Use R to find the final percentage for each student by postmultiplying the score matrix by the weight vector.
\[
\mathbf{X} = \begin{bmatrix}32 & 54 & 56 & 21 \\42 & 23 & 52 & 35 \\ 16 & 41 & 54 & 56 \\ 58 & 52 & 31 & 24 \\ 41 & 50 & 42 & 40 \end{bmatrix} \qquad \mathbf{w} = \begin{bmatrix} 0.10 \\ 0.10 \\ 0.30 \\ 0.50 \end{bmatrix}
\]
Show/Hide Solution
# Create X
X = matrix (
data = c (32 , 54 , 56 , 21 ,
42 , 23 , 52 , 35 ,
16 , 41 , 54 , 56 ,
58 , 52 , 31 , 24 ,
41 , 50 , 42 , 40 ),
byrow = TRUE ,
ncol = 4
)
# Create w
w = matrix (data = c (0.10 , 0.10 , 0.30 , 0.50 ), ncol = 1 )
# Compute Xw
X %*% w
[,1]
[1,] 35.9
[2,] 39.6
[3,] 49.9
[4,] 32.3
[5,] 41.7