QR decomposition breaks a matrix into two parts: Q, which is an orthogonal matrix (like a set of perpendicular directions), and R, which is an upper triangular matrix (like a staircase shape). This helps solve equations and understand matrix properties.
Click to reveal answer
beginner
What does the Q matrix represent in QR decomposition?
Q is an orthogonal matrix, meaning its columns are at right angles to each other and have length 1. This means Q's transpose is also its inverse, which is useful for calculations.
Click to reveal answer
beginner
What is the shape and property of the R matrix in QR decomposition?
R is an upper triangular matrix, which means all the numbers below the diagonal are zero. It is the part that contains the 'weights' or 'scaling' in the decomposition.
Click to reveal answer
intermediate
How can QR decomposition help solve linear systems?
Instead of solving Ax = b directly, we write A as QR. Then solve Qy = b (easy because Q is orthogonal), and then solve Rx = y (easy because R is triangular). This is more stable and efficient.
Click to reveal answer
beginner
Which scipy function is used for QR decomposition?
The function scipy.linalg.qr() computes the QR decomposition of a matrix. It returns Q and R matrices that you can use for further calculations.
Click to reveal answer
What type of matrix is Q in QR decomposition?
ADiagonal matrix
BSymmetric matrix
CLower triangular matrix
DOrthogonal matrix
✗ Incorrect
Q is an orthogonal matrix, meaning its columns are perpendicular and have length 1.
What shape does the R matrix have in QR decomposition?
ADiagonal
BLower triangular
CUpper triangular
DSymmetric
✗ Incorrect
R is an upper triangular matrix, with zeros below the diagonal.
Which scipy function is used to perform QR decomposition?
Ascipy.linalg.eig()
Bscipy.linalg.qr()
Cscipy.linalg.svd()
Dscipy.linalg.inv()
✗ Incorrect
scipy.linalg.qr() computes the QR decomposition.
Why is QR decomposition useful for solving Ax = b?
ABecause Q is orthogonal and R is triangular, making the system easier to solve
BBecause R is orthogonal
CBecause Q is diagonal
DBecause it reduces matrix size
✗ Incorrect
Q being orthogonal and R triangular simplifies solving the system step-by-step.
If A = QR, what is the product Q * R equal to?
AMatrix A
BTranspose of A
CZero matrix
DIdentity matrix
✗ Incorrect
The product Q * R reconstructs the original matrix A.
Explain the steps to solve a linear system Ax = b using QR decomposition.
Think about breaking the problem into simpler parts using Q and R.
You got /4 concepts.
Describe the properties of Q and R matrices in QR decomposition and why they are useful.
Focus on shape and orthogonality.
You got /4 concepts.
Practice
(1/5)
1. What does QR decomposition do to a matrix A?
easy
A. Converts A into a lower triangular matrix only
B. Splits A into two diagonal matrices
C. Splits A into an orthogonal matrix Q and an upper triangular matrix R
D. Finds the inverse of A directly
Solution
Step 1: Understand QR decomposition definition
QR decomposition splits a matrix into two parts: an orthogonal matrix Q and an upper triangular matrix R.
Step 2: Compare options with definition
Only Splits A into an orthogonal matrix Q and an upper triangular matrix R correctly describes this split. Others describe different matrix operations.
Final Answer:
Splits A into an orthogonal matrix Q and an upper triangular matrix R -> Option C
Quick Check:
QR decomposition = Q and R matrices [OK]
Hint: QR always produces Q (orthogonal) and R (upper triangular) [OK]
Common Mistakes:
Confusing QR with LU decomposition
Thinking QR produces diagonal matrices
Assuming QR finds matrix inverse
2. Which of the following is the correct way to import and use QR decomposition from scipy?
easy
A. from scipy.linalg import qr
Q, R = qr(A)
B. import scipy.qr
Q, R = scipy.qr(A)
C. from scipy import qr
Q, R = qr(A)
D. import qr from scipy.linalg
Q, R = qr(A)
Solution
Step 1: Recall scipy QR import syntax
The correct import is from scipy.linalg import qr.
Step 2: Check usage correctness
Calling qr(A) returns Q and R. from scipy.linalg import qr
Q, R = qr(A) matches this exactly.
Final Answer:
from scipy.linalg import qr
Q, R = qr(A) -> Option A
Quick Check:
Correct import and call = from scipy.linalg import qr
Q, R = qr(A) [OK]
Hint: Use 'from scipy.linalg import qr' to access QR function [OK]
Common Mistakes:
Trying to import qr directly from scipy
Using incorrect import syntax
Calling qr without importing
3. Given the matrix A = [[1, 2], [3, 4]], what is the shape of Q and R after Q, R = qr(A)?
medium
A. Q is (2, 2) and R is (2, 1)
B. Q is (1, 2) and R is (2, 2)
C. Q is (2, 1) and R is (1, 2)
D. Q is (2, 2) and R is (2, 2)
Solution
Step 1: Check input matrix shape
Matrix A has shape (2, 2).
Step 2: Understand QR output shapes
For a square matrix, Q and R both have the same shape as A, which is (2, 2).
Final Answer:
Q is (2, 2) and R is (2, 2) -> Option D
Quick Check:
Square matrix QR outputs same shape matrices [OK]
Hint: Q and R shapes match input matrix shape for square matrices [OK]
Common Mistakes:
Assuming R has fewer columns
Confusing Q shape with R shape
Thinking Q or R is 1D
4. What is wrong with this code snippet for QR decomposition?
from scipy.linalg import qr
A = [[1, 2], [3, 4]]
Q, R = qr(A)
print(Q)
medium
A. Nothing is wrong with this code snippet
B. The qr function does not return two values
C. Matrix A should be a numpy array, not a list of lists
D. Import statement is incorrect
Solution
Step 1: Verify import statement
The import from scipy.linalg import qr is correct.
Step 2: Check qr function returns
qr(A) returns two values Q and R.
Step 3: Validate input type
List of lists for A works as qr accepts array-like inputs and converts internally.
Step 4: Check print statement
print(Q) correctly outputs the Q matrix.
Final Answer:
Nothing is wrong with this code snippet -> Option A
Quick Check:
Code runs successfully, produces correct Q and R [OK]
Hint: scipy.linalg.qr accepts lists of lists as array-like input [OK]
Common Mistakes:
Thinking Python lists cannot be passed to qr
Misunderstanding qr return values
Incorrect import statements
5. You want to solve the system Ax = b using QR decomposition where A is a 3x3 matrix and b is a vector. Which step correctly describes how to find x after computing Q, R = qr(A)?
hard
A. Compute x = Q @ b then solve Ry = x
B. Compute y = Q.T @ b then solve Rx = y using back substitution
C. Compute y = R @ b then solve Qx = y
D. Compute x = R.T @ Q @ b
Solution
Step 1: Use QR decomposition to rewrite Ax = b
Since A = QR, rewrite as QRx = b.
Step 2: Multiply both sides by Q.T
Multiply by Q.T to get Rx = Q.T b. Define y = Q.T b.
Step 3: Solve upper triangular system
Now solve Rx = y using back substitution to find x.
Final Answer:
Compute y = Q.T @ b then solve Rx = y using back substitution -> Option B
Quick Check:
Use Q.T b and solve Rx = y [OK]
Hint: Multiply b by Q.T, then solve Rx = y [OK]
Common Mistakes:
Multiplying b by Q instead of Q.T
Trying to solve Qx = y instead of Rx = y
Ignoring that R is upper triangular
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.