Bird
0
0

What is the output of this code?

medium📝 Predict Output Q13 of 15
SciPy - Linear Algebra (scipy.linalg)
What is the output of this code?
import numpy as np
from scipy.linalg import inv
matrix = np.array([[1, 2], [3, 4]])
inverse_matrix = inv(matrix)
print(np.round(inverse_matrix, 2))
A[[ -2. 1. ] [ 1.5 -0.5]]
B[[ 4. -2. ] [-3. 1. ]]
C[[ 0.25 0.5 ] [ 0.75 1. ]]
D[[ 1.5 -1. ] [-1.5 1. ]]
Step-by-Step Solution
Solution:
  1. Step 1: Calculate determinant of the matrix

    Determinant = (1*4) - (2*3) = 4 - 6 = -2 (non-zero, so invertible).
  2. Step 2: Compute inverse using formula

    Inverse = (1/det) * [[d, -b], [-c, a]] = (1/-2) * [[4, -2], [-3, 1]] = [[-2, 1], [1.5, -0.5]].
  3. Final Answer:

    [[ -2. 1. ] [ 1.5 -0.5]] -> Option A
  4. Quick Check:

    Inverse matrix matches [[ -2. 1. ] [ 1.5 -0.5]] [OK]
Quick Trick: Use formula inverse = 1/det * adjugate for 2x2 matrices [OK]
Common Mistakes:
MISTAKES
  • Mixing up signs in the inverse formula
  • Not rounding output
  • Confusing transpose with inverse

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes