Due date

Tuesday, March 28, by the start of class time (2:00pm).

Instructions

Use of R Markdown is optional for this assignment.

Problem 1

Assume that \(\mathbf{A}\), \(\mathbf{B}\), and \(\mathbf{C}\) are square \(n \times n\) invertible matrices with conformable dimensions.

If \(\mathbf{AB} = \mathbf{C}\), then how would you solve for \(\mathbf{B}\)?

Provide an answer in terms of syntactically correct R code. You can construct \(3 \times 3\) identity matrices as “placeholders” for \(\mathbf{A}\), \(\mathbf{B}\), and/or \(\mathbf{C}\) so that the variables are defined and your code will run without error.

# identity matrices A,B,C:

A <- diag(3)
B <- diag(3)
C <- diag(3)

# AB = c -> B = A^T * C
A_inverse <- solve(A)
B <- A_inverse %*% C

cat("B = ", B)
## B =  1 0 0 0 1 0 0 0 1

Problem 2

Assume that \(\mathbf{A}\), \(\mathbf{B}\), \(\mathbf{C}\), and \(\mathbf{D}\) are square invertible matrices with conformable dimensions.

If \(\mathbf{ABC} = \mathbf{D}\), then what does \(\mathbf{B}\) equal?

A <- diag(3)
B <- diag(3)
C <- diag(3)
D <- diag(3)

A_inverse <- solve(A)
C_inverse <- solve(C)

B <- A_inverse %*% D %*% C_inverse

cat("B = ", B)
## B =  1 0 0 0 1 0 0 0 1

Problem 3

Assume that \(\mathbf{A}, \mathbf{B}, \mathbf{C}\) and \(\mathbf{D}\) are square invertible matrices with conformable dimensions.

If \(\mathbf{A}(\mathbf{B}^T) + \mathbf{C} = \mathbf{D}\), then what does \(\mathbf{B}\) equal?

A <- diag(3)
B <- diag(3)
C <- diag(3)
D <- diag(3)

# A(B^T) + C = D -> B = (D-C)^T * A^T
B <- t(D - C) %*% solve(t(A))
cat("B = ", B)
## B =  0 0 0 0 0 0 0 0 0

Problem 4

Solve the following system of linear equations for the variables \(x_1, x_2, x_3\):

\[ \begin{aligned} x_1+16 x_2+49 x_3=312 \\ 4 x_1+25 x_2+64 x_3=432\\ 9 x_1+36 x_2+81 x_3=576\\ \end{aligned} \]

A <- matrix(c(1, 16, 49, 4, 25, 64, 9, 36, 81), nrow = 3, ncol = 3, byrow = TRUE)
B <- c(312, 432, 576)

A_inverse <- solve(A)

ans <- A_inverse %*% B

cat("(x_1, x_2, x_3) = ", ans)
## (x_1, x_2, x_3) =  3 4 5

Problem 5

Solve the following system of linear equations for the variables \(x_1,x_2,x_3\):

\[ \begin{aligned} x_1+5 x_2=23 \\ 3 x_1+7 x_2=37 \\ x_1+2 x_2+3 x_3=26 \\ \end{aligned} \]

A <- matrix(c(1, 5, 0, 3, 7, 0, 1, 2, 3), nrow = 3, byrow = TRUE)
B <- c(23, 37, 26)
A_inverse <- solve(A)

ans <- A_inverse %*% B

cat("(x_1, x_2, x_3) = ", ans)
## (x_1, x_2, x_3) =  3 4 5