Exercise C10 (Page 64):

Compute: \[ 4 \begin{bmatrix} 2 \\ -3 \\ 4\\ 1\\ 0\\ \end{bmatrix} + (-2) \begin{bmatrix} 1\\ 2\\ -5\\ 2\\ 4\\ \end{bmatrix} + \begin{bmatrix} -1\\ 3\\ 0\\ 1\\ 2\\ \end{bmatrix} \]

Solution

# define matrices
matrix_1 <- matrix(c(2,-3,4,1,0), ncol = 1)
matrix_2 <- matrix(c(1,2,-5,2,4), ncol = 1)
matrix_3 <- matrix(c(-1,3,0,1,2), ncol = 1)

# define coefficients
coefficient_1 <- 4
coefficient_2 <- -2
coefficient_3 <- 1

# scalar matrices
scalar_1 <- matrix(coefficient_1, ncol = 1, nrow = nrow(matrix_1))
scalar_2 <- matrix(coefficient_2, ncol = 1, nrow = nrow(matrix_2))
scalar_3 <- matrix(coefficient_3, ncol = 1, nrow = nrow(matrix_3))

# multiplty scalar by matrix
matrix_1_solve <- matrix_1 * scalar_1
matrix_2_solve <- matrix_2 * scalar_2
matrix_3_solve <- matrix_3 * scalar_3

# add scaled matrices
solution_matrix <- matrix_1_solve + matrix_2_solve + matrix_3_solve
## Solution:
##      [,1]
## [1,]    5
## [2,]  -13
## [3,]   26
## [4,]    1
## [5,]   -6

Source

A First Course in Linear Algebra