Matrix decomposition is the expression of a matrix as a product of matrices. Just as factorizing a number can tell us important properties of a number, so does matrix decomposition can reveal important properties.
Here are five important matrix factorizations
\(A = LU\)
This comes from elimination. Matrix L is lower triangular and U is upper triangular.
\(A = QR\)
Comes from orthogonalizing the columns \(a_1\) to \(a_n\), as in ‘Gram-Schmidt’
\(S = Q{\Lambda}Q^T\)
S is a symmetric matrix. Q has orthonormal eigen vectors as its columns. The corresponding eigen values are the digagonal of \(\Lambda\)
# lets reconstruct the matrixnp.linalg.multi_dot([q, np.diag(w), np.transpose(q)])
array([[6., 5., 4.],
[5., 3., 5.],
[4., 5., 4.]])
# Check that the columns of the matrix are orthogonal# select two columns randomly and check the dot prodctcol_idxs = random.sample(range(0, s.shape[0]), k=2)assert np.isclose(np.dot(q[col_idxs[0]], q[col_idxs[1]]), 0)
# check the Euclidean norm of any of columns. It should be 1 as they are orthonormalcol_idx = random.choice(range(0, s.shape[0]))np.linalg.norm(q[col_idx], ord=2)