Challenge - 5 Problems
Matrix Inverse Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of matrix inverse calculation
What is the output of this code snippet using
np.linalg.inv()?NumPy
import numpy as np A = np.array([[4, 7], [2, 6]]) inv_A = np.linalg.inv(A) print(inv_A)
Attempts:
2 left
💡 Hint
Recall the formula for 2x2 matrix inverse: 1/det * [[d, -b], [-c, a]]
✗ Incorrect
The determinant of A is (4*6 - 7*2) = 10. The inverse is 1/10 * [[6, -7], [-2, 4]] which matches option D.
❓ data_output
intermediate1:00remaining
Shape of inverse matrix
Given a square matrix
B of shape (3, 3), what is the shape of np.linalg.inv(B)?Attempts:
2 left
💡 Hint
The inverse of a square matrix has the same shape as the original matrix.
✗ Incorrect
The inverse matrix has the same dimensions as the original square matrix, so shape remains (3, 3).
🔧 Debug
advanced1:30remaining
Error raised by singular matrix inverse
What error does this code raise when trying to invert a singular matrix?
NumPy
import numpy as np C = np.array([[1, 2], [2, 4]]) inv_C = np.linalg.inv(C)
Attempts:
2 left
💡 Hint
A singular matrix has determinant zero and cannot be inverted.
✗ Incorrect
The matrix C is singular because its rows are linearly dependent, so np.linalg.inv raises LinAlgError.
🧠 Conceptual
advanced2:00remaining
Matrix inverse property check
If
D is an invertible matrix, which expression correctly checks if inv_D is the inverse of D?Attempts:
2 left
💡 Hint
Use a function that allows for floating point tolerance when comparing arrays.
✗ Incorrect
np.allclose checks if two arrays are element-wise equal within a tolerance, suitable for floating point results.
🚀 Application
expert2:30remaining
Inverse of a matrix product
Given two invertible matrices
E and F, which expression correctly computes the inverse of their product E @ F?Attempts:
2 left
💡 Hint
Recall the rule: (AB)^-1 = B^-1 A^-1
✗ Incorrect
The inverse of a product is the product of the inverses in reverse order.