Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q5 of 15
SciPy - Linear Algebra (scipy.linalg)
What will be the output of this code?
import numpy as np
from scipy.linalg import solve
A = np.array([[1, 2], [3, 4]])
b = np.array([5, 11])
x = solve(A, b)
print(x)
A[2. 1.]
B[3. 4.]
C[1. 2.]
D[4. 3.]
Step-by-Step Solution
Solution:
  1. Step 1: Write the system of equations

    1*x1 + 2*x2 = 5 and 3*x1 + 4*x2 = 11.
  2. Step 2: Solve the system

    From first: x1 = 5 - 2*x2. Substitute in second: 3*(5 - 2*x2) + 4*x2 = 11 -> 15 - 6*x2 + 4*x2 = 11 -> -2*x2 = -4 -> x2 = 2, then x1 = 5 - 4 = 1.
  3. Final Answer:

    [1. 2.] -> Option C
  4. Quick Check:

    Solution vector x = [1, 2] [OK]
Quick Trick: Substitute and solve stepwise for x [OK]
Common Mistakes:
MISTAKES
  • Swapping values of x1 and x2
  • Arithmetic errors in substitution
  • Misreading matrix rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes