C10 (LA, chapter M, pg 172)

Perform the following calculations on the matrices and scalars below:

\[\mathbf{A} = \left[\begin{array} {rrr} 1 & 4 & -3 \\ 6 & 3 & 0 \end{array}\right] \]

\[\mathbf{B} = \left[\begin{array} {rrr} 3 & 2 & 1 \\ -2 & 6 & 5 \end{array}\right] \]

\[\mathbf{C} = \left[\begin{array} {rrr} 2 & 4 \\ 4 & 0 \\ -2 & 2 \end{array}\right] \]

\[\alpha = 4\]

\[\beta = \frac{1}{2}\]

# Create matrices and set scalars
A <- matrix(c(1, 4, -3, 6, 3, 0), nrow = 2, ncol = 3, byrow = TRUE)
B <- matrix(c(3, 2, 1, -2, 6, 5), nrow = 2, ncol = 3, byrow = TRUE)
C <- matrix(c(2, 4, 4, 0, -2, 2), nrow = 3, ncol = 2, byrow = TRUE)
alpha = 4
beta = .5
  1. \(A + B\)
A + B
##      [,1] [,2] [,3]
## [1,]    4    6   -2
## [2,]    4    9    5
  1. \(A + C\)
A + C
## Error in A + C: non-conformable arrays

The matrices cannot be summed as their dimension are different.

  1. \(B^{t} + C\)
t(B) + C
##      [,1] [,2]
## [1,]    5    2
## [2,]    6    6
## [3,]   -1    7
  1. \(A + B^{t}\)
A + t(B)
## Error in A + t(B): non-conformable arrays

The matrices cannot be summed as their dimension are different.

  1. \(\beta\)\(C\)
beta * C
##      [,1] [,2]
## [1,]    1    2
## [2,]    2    0
## [3,]   -1    1
  1. \(4A - 3B\)
4 * A - 3 * B
##      [,1] [,2] [,3]
## [1,]   -5   10  -15
## [2,]   30   -6  -15
  1. \(A^{t} +\) \(\alpha\)\(C\)
t(A) + alpha * C
##      [,1] [,2]
## [1,]    9   22
## [2,]   20    3
## [3,]  -11    8
  1. \(A + B - C^{t}\)
A + B - t(C)
##      [,1] [,2] [,3]
## [1,]    2    2    0
## [2,]    0    9    3
  1. \(4A + 2B - 5C^{t}\)
4 * A + 2 * B - 5 * t(C)
##      [,1] [,2] [,3]
## [1,]    0    0    0
## [2,]    0   24    0