M11 p278

Find a value of k so that the matrix A =
1 2 1
2 0 1
2 3 k
has det(A) = 0, or explain why it is not possible.

So first, I need to make the matrix. In R, the matrix will have to store all string values as we have the variable k.

A <- matrix(c(1,2,2,2,0,3,1,1,'k'), nrow = 3, ncol = 3)
A
##      [,1] [,2] [,3]
## [1,] "1"  "2"  "1" 
## [2,] "2"  "0"  "1" 
## [3,] "2"  "3"  "k"
To find the det(A), we split the 3x3 matrix into 3 2x2 matrices and take their determinant with the following formula: \[\begin{aligned} ad - bc \\ \end{aligned}\]

where abcd are located like the matrix below.

##      [,1] [,2]
## [1,] "a"  "b" 
## [2,] "c"  "d"

The three matrices we get as below:
(I could not figure out if I can use the A[] for a2 where I needed to pull columns 1 and 3 that are not next to each other.)

a1 <- A[2:3,2:3]
a2 <- matrix(c('2','2','1','k'), nrow = 2, ncol = 2)
a3 <- A[2:3,1:2]
## [1] "1*a1"
##      [,1] [,2]
## [1,] "0"  "1" 
## [2,] "3"  "k"
## [1] "-2*a2"
##      [,1] [,2]
## [1,] "2"  "1" 
## [2,] "2"  "k"
## [1] "1*a3"
##      [,1] [,2]
## [1,] "2"  "0" 
## [2,] "2"  "3"
Using the 2x2 determinant formula and setting the sum of all three to 0, we get the following equation and breakdown:
\[\begin{aligned} 1(0*k - 1*3) - 2(2*k - 1*2) + 1(2*3 - 0*2) = 0 \\ 1(0k - 3) - 2(2k - 2) + 1(6 - 0) = 0 \\ -3 -4k +4 +6 = 0 \\ -4k +7 = 0 \\ 7 = 4k \\ \frac{7}{4} = k \\ \end{aligned}\]

So, k = or 1.75.
We can check this in R by creating a new matrix with the k value and using the det function to test if it is 0.

A_ans <- matrix(c(1,2,2,2,0,3,1,1,1.75), nrow = 3, ncol = 3)
A_ans
##      [,1] [,2] [,3]
## [1,]    1    2 1.00
## [2,]    2    0 1.00
## [3,]    2    3 1.75
det(A_ans)
## [1] 0