Exercise: Column space

Task 1: You have seen that the SVD of an $m \times n$ matrix $A$ gives, among other things, a basis for the range (column space). Compute this for the given matrix.

Another way to obtain a basis for the range is using the QR factorization, also implemented in scipy. Carefully go through the linked QR documentation page. Then compute a basis for the column space of a given A using QR, and then using the SVD.

Task 2: Check that the column spaces (not the bases) you obtained in the two ways are the same. (How would you check that two given bases span the same space?)

Task 3: For a $500 \times 500$ random matrix, which method is faster?

In [1]:
import numpy as np
from scipy.linalg import svd, qr

A = np.array([[1, -2, 3, -3], [2, -4, 9, -2], [-3, 6, -9, 9]])