Marginal

Advanced Linear Algebra

The linear algebra of machine learning and physics: null spaces and rank–nullity, orthogonal projections and Gram–Schmidt, orthogonal matrices, trace and determinant, the spectral theorem, the singular value decomposition, low-rank approximation, PCA, norms and conditioning, matrix calculus, einsum index notation, the matrix exponential and the multivariate normal.

34 lessons in 3 units

Start your free trial14 days free. No card needed.
What you'll learn

34 lessons, one small step at a time

Each lesson states its goal, then works up to it in short steps with practice after each. A placement test at the start skips what you already know.

Subspaces & Orthogonality

7 lessons
  1. The null spaceTest whether a vector lies in a matrix's null space, and find a vector that spans it.
  2. Rank–nullityApply rank–nullity to count lost directions and free parameters, settle one-to-one and onto questions from dimensions, and read the nullity of a matrix.
  3. Orthogonal projectionCompute the projection of a vector onto a line, its distance to the line, and the projection matrix.
  4. Gram–SchmidtNormalize vectors and remove projections with Gram–Schmidt, find coordinates in an orthonormal basis by dot products, and read the QR factorization.
  5. Least squares as projectionFit a regression through the origin by projection, and use the orthogonality of the residuals.
  6. Rotation matricesRotate vectors with rotation matrices in the plane and in space, and compose rotations.
  7. Orthogonal matricesShow that orthogonal matrices preserve length, invert them by transposing, and tell rotations from reflections.

Decompositions

15 lessons
  1. Trace, det & eigenvaluesFind eigenvalues from the trace and determinant, check claimed eigenvalues with them, and read the eigenvalues of triangular matrices.
  2. Eigenvalues of matrix functionsFind the eigenvalues of powers, shifts and inverses of a matrix.
  3. Symmetric 2×2 eigenvaluesCompute the eigenvalues of a symmetric 2×2 matrix with a formula, and its perpendicular eigenvectors.
  4. Quadratic forms on the sphereEvaluate a quadratic form on unit vectors, find its extremes from the eigenvalues, and find the axes of its level ellipse.
  5. The spectral theoremRebuild a symmetric matrix from its eigenvalues and orthonormal eigenvectors, and compute functions of it.
  6. Power iterationRun power iteration toward the leading eigenvector, estimate how fast it converges, and estimate the eigenvalue with the Rayleigh quotient.
  7. Singular valuesCompute the Gram matrix AᵀA, the singular values of A, and the ellipse that A makes of the unit circle.
  8. Rank-one matricesCompute outer products and how they act on vectors, split a matrix into rank-one pieces, and find the singular value of a rank-one matrix.
  9. Singular value decompositionRead the largest and smallest stretches of a matrix from its SVD, and its rank.
  10. Low-rank approximationCompute the error of the best low-rank approximation of a matrix, and the share of the matrix it keeps.
  11. The pseudoinverseCompute the pseudoinverse from the SVD, find minimum-norm solutions, and relate the pseudoinverse to least squares and to penalized fits.
  12. Covariance matricesCompute a covariance matrix from data and its total variance, and tell which matrices can be covariance matrices.
  13. Principal component analysisCompute the variance along principal components and the share each explains, compute scores, and find the direction of the first component.
  14. Matrix normsCompute the Frobenius norm of a matrix, and both the Frobenius and the operator norm from its singular values.
  15. Condition numbersCompute a matrix's condition number, and the error amplification and lost digits it implies.

Matrix Calculus & Computation

12 lessons
  1. Gradients of quadratic formsCompute gradients of quadratic forms for symmetric and for general matrices, and combine the rules to find a minimizer.
  2. Least-squares gradientsCompute the least-squares gradient, and derive and solve the normal equations.
  3. Gradient descent on quadraticsFollow gradient descent on a quadratic along each eigenvector, find the learning rate at which it diverges, and relate its speed to the condition number.
  4. Einstein summationCompute dot products, sums along an axis and matrix products with Einstein summation.
  5. Tensor shapes & compute costFind the output shapes of tensor operations, count their multiply–adds, and choose a cheaper order for a chain of products.
  6. Decoupled linear systemsSolve ẋ = Ax for diagonal A, and along an eigenvector of any diagonalizable A.
  7. Nilpotent matricesCompute powers of nilpotent matrices, and solve ẋ = Nx with them.
  8. The matrix exponentialApproximate the matrix exponential from its series, and compute it by splitting a matrix into commuting parts.
  9. Variance of linear combinationsCompute the variance of a linear combination as a quadratic form in the covariance matrix, and explain diversification.
  10. Covariance under linear mapsCompute covariances after a linear map with the sandwich rule Cov(AX) = AΣAᵀ, explain why it holds, and apply it to sums and differences.
  11. The Cholesky factorizationCompute a Cholesky factor, simulate correlated variables with it, and solve systems with two triangular solves.
  12. The multivariate normalCompute Mahalanobis distances, the multivariate normal density and its conditionals, and the probabilities of ellipses.
Sample lesson

The null space

Goal: Test whether a vector lies in a matrix's null space, and find a vector that spans it.

Some directions are invisible to a matrix: moving along them changes nothing in the output. These directions explain why underdetermined systems have infinitely many solutions, and why an overparameterized model can change its parameters without changing its predictions.

We will test membership and finish with finding a null vector.

Step 1: Testing membership

The null space of a matrix A is the set of vectors x with Ax = 0: the directions A sends to nothing. It always contains 0, and it is a subspace: sums and multiples of null vectors are null vectors, since A(x + y) = Ax + Ay = 0. Each entry of Ax is a row of A dotted with x, so

x is in the null space ⇔ every row of A is orthogonal to x

For A with rows (1, −1, 0) and (2, −2, 3), x = (1, 1, 0) gives 1 − 1 + 0 = 0 and 2 − 2 + 0 = 0, so x is a null vector, and so are −x and 0. But (1, 0, 1) gives 1 for the first row, so it is not.

Step 2: Finding a null vector

A singular 2 × 2 matrix has rows that are multiples of each other, so the two equations of Ax = 0 say the same thing and one does all the work. For the row (a, b), the null vectors lie along (−b, a), since a(−b) + b·a = 0. For A = [2 −6; 1 −3], the second row is half the first, and the null space is the line through (6, 2), or equivalently (3, 1): check 2 × 3 − 6 × 1 = 0. To find which (1, t) is a null vector, solve 2 − 6t = 0, so t = 1/3. Moving along this line changes the input without changing the output.

In the app, each step ends with practice questions, new ones every time, and the lesson comes back later in spaced reviews.

Start Advanced Linear Algebra

Lessons that need something you haven't learned yet bring it in first, from any course.

Start your free trial14 days free. No card needed.