Bird
0
0

What will be the result of this code?

medium📝 Predict Output Q5 of 15
SciPy - Linear Algebra (scipy.linalg)
What will be the result of this code?
import numpy as np
from scipy.linalg import cholesky
A = np.array([[1, 2], [2, 1]])
L = cholesky(A)
AA lower triangular matrix L
BAn upper triangular matrix L
CA runtime error due to non-positive definite matrix
DA matrix of zeros
Step-by-Step Solution
Solution:
  1. Step 1: Check matrix properties

    Matrix A = [[1,2],[2,1]] is symmetric but not positive definite because its eigenvalues include negative values.
  2. Step 2: Understand Cholesky behavior

    Cholesky decomposition requires positive definiteness; otherwise, it raises a runtime error.
  3. Final Answer:

    A runtime error due to non-positive definite matrix -> Option C
  4. Quick Check:

    Non-positive definite matrix causes error [OK]
Quick Trick: Cholesky fails if matrix not positive definite [OK]
Common Mistakes:
MISTAKES
  • Assuming decomposition always works
  • Ignoring matrix definiteness
  • Expecting zero matrix output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes