Problem 4: Calculate a Matrix's Inverse and Verify It
Easypython
Problem Description
Write a Python program that calculates the inverse of a 2x2 matrix using np.linalg.inv(), then verifies the result by multiplying the original matrix by its inverse (which should produce the identity matrix).
Input
A 2x2 matrix.
Output
The inverse matrix, and the verification result (should be the identity matrix).
Constraints
- The matrix must be invertible (non-zero determinant).
Example Input
text[[2,0],[0,4]]
Example Output
textInverse: [[0.5, 0.], [0., 0.25]] Verification (should be identity): [[1., 0.], [0., 1.]]
Concepts Covered
np.linalg.inv(), np.matmul(), identity matrix verification.