Bird
0
0

Given the code:

medium📝 Predict Output Q4 of 15
SciPy - Linear Algebra (scipy.linalg)
Given the code:
import numpy as np
from scipy.linalg import qr
A = np.array([[1, 0], [1, 1]])
Q, R = qr(A)
print(np.round(Q, 2))

What is the output?
A[[ -0.71 0.71] [ -0.71 -0.71]]
B[[ 0.71 0.71] [ 0.71 -0.71]]
C[[ 0.71 -0.71] [ 0.71 0.71]]
D[[ 1.00 0.00] [ 0.00 1.00]]
Step-by-Step Solution
Solution:
  1. Step 1: Perform QR decomposition on matrix A

    Matrix A is [[1,0],[1,1]]. QR decomposition produces orthogonal Q and upper triangular R.
  2. Step 2: Calculate Q and round values

    Q columns are orthonormal vectors. The output rounded to 2 decimals is [[0.71, -0.71],[0.71, 0.71]].
  3. Final Answer:

    [[ 0.71 -0.71] [ 0.71 0.71]] -> Option C
  4. Quick Check:

    Q matrix output matches [[ 0.71 -0.71] [ 0.71 0.71]] [OK]
Quick Trick: Q columns are orthonormal vectors from A [OK]
Common Mistakes:
MISTAKES
  • Ignoring sign differences in Q
  • Confusing Q with R matrix output
  • Not rounding output correctly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes