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 lu
A = np.array([[4, 3], [6, 3]])
P, L, U = lu(A)
print(np.round(L, 2))
A[[1. 0. ] [0.67 1. ]]
B[[4. 3. ] [6. 3. ]]
C[[1.5 0. ] [0. 1. ]]
D[[0.67 1. ] [1. 0. ]]
Step-by-Step Solution
Solution:
  1. Step 1: Perform LU decomposition on matrix A

    Using scipy.linalg.lu on A = [[4,3],[6,3]] gives matrices P, L, U where L is lower triangular with 1s on diagonal and multipliers below.
  2. Step 2: Calculate L matrix values

    L = [[1, 0], [6/4, 1]] = [[1, 0], [1.5, 1]]. But scipy.linalg.lu applies row permutations, so actual L is [[1,0],[0.67,1]] after permutation.
  3. Final Answer:

    [[1. 0. ] [0.67 1. ]] -> Option A
  4. Quick Check:

    L matrix lower triangular with 1 diagonal = [[1,0],[0.67,1]] [OK]
Quick Trick: L is lower triangular with 1s on diagonal [OK]
Common Mistakes:
MISTAKES
  • Confusing L with original matrix A
  • Ignoring row permutations affecting L
  • Rounding errors in L matrix values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes