Linear algebra practice problems
14 problems · 0 solved
Almost every ML model is linear algebra underneath: data is a matrix, weights are matrices, and training is a long chain of matrix operations. Knowing how these operations behave helps you understand compression, stability and why some computations blow up. These problems ask you to implement the key methods instead of only calling a library. You will build a cosine similarity matrix for embeddings, project vectors onto a subspace, count numerical rank from singular values, measure the loss of a rank-k SVD approximation, orthonormalise vectors with Gram-Schmidt, find the main direction of data with PCA, solve least squares with a pseudo-inverse, write a Cholesky factorisation, solve a tridiagonal system with the Thomas algorithm, compute QR with Householder reflections, and find top eigenpairs with power iteration and deflation. Start with the Easy problems on cosine similarity and projections. Then do Gram-Schmidt, PCA and Cholesky, and finish with Householder QR and power iteration. Ideas like low-rank approximation sit behind LoRA, embeddings and compression, and interviewers regularly ask about SVD, PCA and numerical stability.
Easy 5
Medium 6
- Find the main direction of your data with PCA
- Orthonormalise a set of vectors with Gram-Schmidt
- Solve least squares with an SVD pseudo-inverse that drops tiny singular values
- Solve a tridiagonal system in linear time with the Thomas algorithm
- Write a Cholesky factorisation and use it to solve a system
- Find the eigenvalue nearest a shift with inverse power iteration