Challenge - 5 Problems
Matrix Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of transpose on a matrix
What is the output of the following R code that transposes a matrix?
R Programming
mat <- matrix(1:6, nrow=2, ncol=3) transposed <- t(mat) print(transposed)
Attempts:
2 left
💡 Hint
Remember that transpose flips rows and columns.
✗ Incorrect
The original matrix has 2 rows and 3 columns. Transpose swaps rows and columns, so the result has 3 rows and 2 columns with elements rearranged accordingly.
❓ Predict Output
intermediate2:00remaining
Output of inverse of a matrix
What is the output of this R code that calculates the inverse of a matrix?
R Programming
mat <- matrix(c(4,7,2,6), nrow=2) inv_mat <- solve(mat) print(round(inv_mat, 2))
Attempts:
2 left
💡 Hint
The inverse of a 2x2 matrix [[a,b],[c,d]] is (1/(ad-bc))*[[d,-b],[-c,a]].
✗ Incorrect
The determinant is (4*6 - 7*2) = 24 - 14 = 10. The inverse is (1/10)*[[6,-2],[-7,4]] which is [[0.6,-0.2],[-0.7,0.4]].
🔧 Debug
advanced2:00remaining
Identify the error in matrix inversion code
What error will this R code produce when trying to invert a matrix?
R Programming
mat <- matrix(c(1,2,2,4), nrow=2) inv_mat <- solve(mat) print(inv_mat)
Attempts:
2 left
💡 Hint
Check if the matrix is invertible by its determinant.
✗ Incorrect
The matrix has determinant zero (1*4 - 2*2 = 0), so it is singular and cannot be inverted. solve() throws this error.
🧠 Conceptual
advanced2:00remaining
Effect of transpose on matrix multiplication
Given two matrices A and B, which of the following is true about the transpose of their product (A %*% B)?
Attempts:
2 left
💡 Hint
Transpose reverses the order of multiplication.
✗ Incorrect
The transpose of a product of matrices equals the product of their transposes in reverse order: t(A %*% B) = t(B) %*% t(A).
❓ Predict Output
expert3:00remaining
Output of combined transpose and inverse operations
What is the output of this R code that combines transpose and inverse operations?
R Programming
mat <- matrix(c(2,1,1,2), nrow=2) result <- solve(t(mat)) print(round(result, 2))
Attempts:
2 left
💡 Hint
Transpose of a symmetric matrix is the same matrix.
✗ Incorrect
Since mat is symmetric, t(mat) equals mat. So solve(t(mat)) equals solve(mat), which is [[0.67, -0.33], [-0.33, 0.67]] after rounding.