1. Using matrix operations, describe the solutions for the following family of equations:

x + 2y - 3z = 5

2x + y - 3z = 13

-x + y = -8

My first approach would be to solve the system of equations by varible elimination. If we focus on the x’s and multiply the first equation (L1) by -1, we can add the equations together to get rid of the x’s.

L1: x + 2y - 3z = 5 (* -1) –> -x - 2y + 3z = -5

L2: stays the same –> 2X + y - 3z = 13

L3: stays the same –> -x + y = -8

Then -1L1 + L2 + L3 –> 0 + 0 + 0 = 0

This means there are infinite solutions. Let’s see if I can show that with matrix operations. We can represent this system of equations as:

\[\left[\begin{array} {rrr} 1 & 2 & -3 \\ 2 & 1 & -3 \\ -1 & 1 & 0 \end{array}\right] * \left[\begin{array} {r} x\\ y\\ z \end{array}\right] = \left[\begin{array} {r} -5\\ 13\\ -8 \end{array}\right] \]

Or, the matrix A * vector v = vector b = A * v = b

To solve for vector v we multiply by the inverse of matrix A and we get 1 over the determinant of A times the adjunct of matrix A time the vector b. We need the determinant of A.

v = A-1 * b –> v = 1/|A| * \(A_{adj}\) * b

\[\mathbf{|A|} = 1 * det \left[\begin{array} {rr} 1 & -3 \\ 1 & 0 \end{array}\right] - 2 * det \left[\begin{array} {rr} 2 & -3 \\ -1 & 0 \end{array}\right] + (-3) * det \left[\begin{array} {rr} 2 & 1 \\ -1 & 1 \end{array}\right] \]

|A| = 1 * (0 + 3) - 2 * (0 - 3) + (-3) * (2 + 1) = 3 + 6 - 9 = 0

Answer to 1.: The determinant is zero, which means the matrix is NOT invertible, which means we cannot solve this system of equations. 1/|A| = 1/0 = infinity, so I think we proved twice that there are infinite solutions.

2. Provide a solution for #1, using R functions of your choice.

Problem 1 boils down to finding the determinant of the matrix, which we found to be zero by hand above. We wanted the determinant in order to find the inverse of the matrix. The following R code first finds the determinant. When I tried to run: A.inv <- solve(A), to show the inverse of matrix A, I got this error message and my Markdown file would not Knit. Interesting that we cannot show code that gives an error in Markdown.

Error Message from A.inv <- solve(A): Error in solve.default(A) : Lapack routine dgesv: system is exactly singular: U[3,3] = 0

A <- matrix(c(1, 2, -1, 2, 1, 1, -3, -3, 0), ncol = 3)
det(A)
## [1] 0

3. Solve for AB by hand:

\[\mathbf{A} = \left[\begin{array} {rr} 4 & -3 \\ -3 & 5 \\ 0 & 1 \end{array}\right] , \mathbf{B} = \left[\begin{array} {rr} 1 & 4 \\ 3 & -2 \end{array}\right] \]

\[\mathbf{A * B} = \left[\begin{array} {rr} (4 * 1) + (-3 * 3) & (4 * 4) + (-3 * -2) \\ (-3 * 1) + (5 * 3) & (-3 * 4) + (5 * -2) \\ (0 * 1) + (1 * 3) & (0 * 4) + (1 * -2) \end{array}\right] = \left[\begin{array} {rr} -5 & 22 \\ 12 & -22 \\ 3 & -2 \end{array}\right] \]

4. Solve AB from #3 using R functions of your choice.

A <- matrix(c(4, -3, 0, -3, 5, 1), ncol = 2)
B <- matrix(c(1, 3, 4, -2), ncol = 2)
A %*% B
##      [,1] [,2]
## [1,]   -5   22
## [2,]   12  -22
## [3,]    3   -2