BetaFree coursewareRewritten from MIT OpenCourseWareCC BY-NC-SA 4.0
Open CosmologyPhysics & cosmology, from high school to a graduate year
Mathematics · Year II

18.06 Linear Algebra

Systems of linear equations, matrices, vector spaces, orthogonality, determinants, eigenvalues and eigenvectors, positive definite matrices and the singular value decomposition.

Based on MIT OpenCourseWare, Spring 2010 · Prof. Gilbert Strang · Course on OCW

Lectures 31 of 35 with pages so far

  • The geometry of linear equations

    The fundamental problem of linear algebra is to solve n linear equations in n unknowns, Ax = b. There are three ways to see it. The row picture takes one equation at a time: in two dimensions each is a line and the solution is where the lines meet; in three dimensions each is a plane. The column picture, the important one, asks for the linear combination of the columns of A that produces b. For 2x − y = 0, −x + 2y = 3, one of column (2, −1) plus two of column (−1, 2) gives (0, 3). If the columns are independent, their combinations fill the whole space and Ax = b is solvable for every b: the matrix is invertible. If, say, the third column lies in the plane of the first two, only right-hand sides in that plane can be reached: the matrix is singular. The matrix form multiplies A by x either by rows (dot products) or, preferably, by columns: Ax is a combination of the columns of A.

  • Elimination with matrices

    Elimination, the method every software package uses, solves Ax = b by subtracting multiples of a pivot row from the rows below it, so as to get zeros under each pivot and turn A into an upper triangular U. For x + 2y + z = 2, 3x + 8y + z = 12, 4y + z = 2, the multipliers 3 and 2 give the pivots 1, 2, 5 (their product, 10, is the determinant). Carrying the right-hand side along in the augmented matrix gives Ux = c with c = (2, 6, −10), and back substitution gives z = −2, y = 1, x = 2. A zero in a pivot position calls for a row exchange; if no row below can help, the matrix is not invertible. Each step is a multiplication by an elimination matrix such as E₂₁, and by the associative law E₃₂(E₂₁A) = (E₃₂E₂₁)A = U. A row times a matrix combines the rows; matrices on the left act on rows, on the right on columns; AB ≠ BA in general; and the inverse of 'subtract 3 times row 1' is 'add it back'.

  • Matrix multiplication and inverse matrices

    Matrix multiplication can be seen in several ways, all giving the same answer. The (i, j) entry of AB is row i of A times column j of B, a sum over k of a_ik b_kj, which needs A to be m × n and B n × p, giving m × p. Each column of AB is A times a column of B, so a combination of the columns of A; each row of AB is a row of A times B, a combination of the rows of B. AB is also the sum of (column k of A)(row k of B), and each such column times row is a full matrix whose rows all lie on one line. Matrices can also be multiplied by blocks. A square matrix A is invertible if some A⁻¹ gives A⁻¹A = I = AA⁻¹. It is not invertible if Ax = 0 for some nonzero x, as for [1 3; 2 6] with x = (3, −1). Gauss–Jordan finds A⁻¹ by eliminating on [A I] until the left half is I; the right half is then A⁻¹, because EA = I means E = A⁻¹.

  • Factorization into A = LU

    The inverse of a product reverses the order, (AB)⁻¹ = B⁻¹A⁻¹, like putting socks and shoes back on; likewise (A⁻¹)ᵀ is the inverse of Aᵀ. Elimination without row exchanges takes A to U by elimination matrices, E₃₂E₃₁E₂₁A = U. Moving them to the other side gives A = LU with L = E₂₁⁻¹E₃₁⁻¹E₃₂⁻¹, lower triangular with ones on the diagonal. In that order the multipliers do not interfere: they simply sit in L, so L costs nothing to record, while the forward product E mixes them (a 10 from multipliers 2 and 5). Pulling the pivots out of U gives A = LDU. Elimination on an n × n matrix costs about n² + (n − 1)² + … + 1² ≈ n³/3 operations, and each right-hand side about n². Row exchanges use permutation matrices: there are 6 of size 3 × 3 (n! in general), products and inverses of them are again permutations, and P⁻¹ = Pᵀ.

  • Transposes, permutations and vector spaces

    With row exchanges, elimination gives PA = LU: the permutation P puts the rows in an order where no zero lands in a pivot position. There are n! permutation matrices of size n, and each has PᵀP = I, so P⁻¹ = Pᵀ. The transpose flips a matrix across its main diagonal, (Aᵀ)ᵢⱼ = Aⱼᵢ; a matrix is symmetric when Aᵀ = A, and RᵀR is symmetric for any rectangular R, because (RᵀR)ᵀ = RᵀRᵀᵀ = RᵀR. Then the step to real linear algebra: a vector space is a set of vectors closed under addition and multiplication by numbers, so every linear combination stays inside. Rⁿ, all real column vectors with n components, is the main example; it must contain the zero vector. A quarter of the plane is not a vector space, but a line through the origin is a subspace. The subspaces of R² are R² itself, the lines through the origin and the zero vector alone; in R³ add the planes through the origin. All combinations of the columns of A form a subspace, the column space C(A); two independent columns in R³ fill a plane.

  • Column space and nullspace

    A subspace is closed under linear combinations, so it contains zero. The union of a plane and a line through the origin is not a subspace (sums leave it), but the intersection of any two subspaces is. The column space C(A) holds all combinations of the columns of A; for the 4 × 3 matrix with columns (1, 2, 3, 4), (1, 1, 1, 1) and (2, 3, 4, 5) it is only a plane in R⁴, because column 3 is the sum of the first two. Ax = b can be solved exactly when b is in the column space, since Ax is a combination of the columns. The nullspace N(A) holds all solutions of Ax = 0; here it is the line of multiples of (1, 1, −1) in R³. It is a subspace because A(v + w) = Av + Aw and A(cv) = cAv. The solutions of Ax = b with b ≠ 0 are not a subspace, since zero is not among them: for b = (1, 2, 3, 4) they form a line that misses the origin. Column space and nullspace show the two ways to describe a subspace: by vectors to combine, or by equations to satisfy.

  • Solving Ax = 0: pivot variables and special solutions

    The nullspace is found by elimination, now on rectangular matrices: when a column has no pivot, move on to the next. Elimination does not change the solutions of Ax = 0. For A with rows (1, 2, 2, 2), (2, 4, 6, 8), (3, 6, 8, 10) it gives an echelon (staircase) matrix U with two pivots, so the rank is r = 2. Columns 1 and 3 are pivot columns; x₂ and x₄ are free. Setting one free variable to 1 and the others to 0 and back-substituting gives the special solutions (−2, 1, 0, 0) and (2, 0, −2, 1); the nullspace is all their combinations. An m × n matrix of rank r has n − r free variables, one special solution for each. Going further, with zeros above the pivots and pivots equal to 1, gives the reduced row echelon form R = [I F; 0 0]. Then Rx = 0 says x_pivot = −F x_free, so the nullspace matrix N, whose columns are the special solutions, is [−F; I]. For the transpose of the example, the rank is again 2, and the nullspace is the line through (−1, −1, 1).

  • Solving Ax = b: the complete solution

    Elimination on the augmented matrix [A b] decides whether Ax = b has a solution and finds all of them. For the matrix of Lecture 7, whose third row is the sum of the first two, the zero row of U turns into the condition b₃ − b₂ − b₁ = 0: if a combination of the rows gives the zero row, the same combination of the entries of b must give 0, which is the same as saying b is in the column space. A particular solution comes from setting the free variables to 0 and solving for the pivot variables: for b = (1, 5, 6), x_p = (−2, 0, 3/2, 0). The complete solution is x_p plus anything in the nullspace, because A(x_p + x_n) = b + 0; here it is a two-dimensional flat surface in R⁴ that misses the origin. The rank r of an m × n matrix satisfies r ≤ m and r ≤ n. With full column rank (r = n) there are no free variables and 0 or 1 solutions; with full row rank (r = m) every b has a solution, with n − m free variables; when r = m = n the matrix is invertible and R = I; and when r is less than both, there are 0 or infinitely many solutions. The rank tells the number of solutions.

  • Independence, basis and dimension

    When Ax = 0 has more unknowns than equations (n > m), there are free variables and so nonzero solutions. Vectors are independent when no combination of them gives zero except the zero combination; v and 2v are dependent, so is any set containing the zero vector, and so are any three vectors in the plane. Put them in the columns of A: they are independent exactly when N(A) contains only zero, that is, when the rank is n with no free variables. Vectors span a space when the space consists of all their combinations, as the columns span the column space. A basis is a set of vectors that is independent and spans. The columns of the identity are one basis of R³, and n vectors form a basis of Rⁿ exactly when the n × n matrix with those columns is invertible. Bases are not unique, but every basis of a given space has the same number of vectors: the dimension. For A with columns (1, 1, 1), (2, 1, 2), (3, 2, 3), (1, 1, 1), the pivot columns 1 and 2 are a basis of C(A), so the rank 2 is the dimension of the column space, and the two special solutions are a basis of N(A), whose dimension is n − r = 2.

  • The four fundamental subspaces

    Strang opens by correcting Lecture 9: (1, 1, 2), (2, 2, 5), (3, 3, 8) are not a basis, since the matrix with these columns has two equal rows, so its row space, and therefore its column space, is only two-dimensional. Every m × n matrix of rank r has four fundamental subspaces: the column space C(A) and the left nullspace N(Aᵀ) in Rᵐ, and the row space C(Aᵀ) and the nullspace N(A) in Rⁿ. Their dimensions are r, m − r, r and n − r, so the row space and nullspace dimensions add to n, the other two to m. Bases: the pivot columns of A for C(A); the first r rows of R for the row space (row operations change the column space but not the row space); the special solutions for N(A). The left nullspace holds the y with Aᵀy = 0, that is yᵀA = 0ᵀ, the combinations of rows giving the zero row. Gauss–Jordan on [A I] gives [R E] with EA = R; the rows of E that produce zero rows of R are a basis of N(Aᵀ). For A with columns (1, 1, 1), (2, 1, 2), (3, 2, 3), (1, 1, 1) that is y = (−1, 0, 1). Finally, the 3 × 3 matrices form a vector space too, with subspaces such as the upper triangular, symmetric and diagonal matrices; the diagonal ones have dimension 3.

  • Matrix spaces, rank one and small-world graphs

    The ideas of basis and dimension work in any vector space, not only Rⁿ. All 3 × 3 matrices form a space M of dimension 9; the symmetric matrices S and the upper triangular matrices U are subspaces of dimension 6 each. Their intersection is the diagonal matrices, of dimension 3; their union is not a subspace, but their sum S + U (any symmetric plus any upper triangular matrix) is all of M, and dim S + dim U = dim(S ∩ U) + dim(S + U), 6 + 6 = 3 + 9. The solutions of y″ + y = 0 form a vector space with basis cos x and sin x (or e^{ix} and e^{−ix}): dimension 2, a nullspace of a differential operator. A rank-one matrix is a column times a row, A = uvᵀ, such as (1, 2) times (1, 4, 5); rank-one matrices are the building blocks of all matrices, but they do not form a subspace, since the rank of a sum can grow (rank(A + B) ≤ rank A + rank B). The vectors in R⁴ with v₁ + v₂ + v₃ + v₄ = 0 are the nullspace of the 1 × 4 matrix of ones: dimension 4 − 1 = 3, with three special solutions as a basis; its column space is R¹ and its left nullspace only zero, of dimension 0 with an empty basis. Finally, graphs (nodes and edges) and the small-world question: how many steps separate any two people in a friendship graph?

  • Graphs, networks and incidence matrices

    Real matrices come from applications and have structure. A graph with n nodes and m edges, each edge given a direction, has an m × n incidence matrix A: row k has −1 at the node edge k leaves and +1 at the node it enters. For Strang's graph with 4 nodes and 5 edges, Ax lists the potential differences across the edges, so Ax = 0 exactly when all potentials are equal: N(A) is the line through (1, 1, 1, 1), potentials are fixed only up to a constant (grounding a node removes it), and the rank is n − 1 = 3. Rows of A around a loop are dependent. Currents y on the edges satisfy Kirchhoff's current law Aᵀy = 0, a balance at each node; its solutions are currents around loops, and N(Aᵀ) has dimension m − r = 2, with one basis vector for each independent loop. The pivot rows of A (here edges 1, 2 and 4) form a tree, a graph with no loops. The count dim N(Aᵀ) = m − (n − 1) gives Euler's formula: nodes − edges + loops = 1. With Ohm's law y = Ce and current sources f, the three steps e = Ax, y = Ce, Aᵀy = f combine into AᵀCAx = f, the basic equation of applied mathematics in equilibrium; AᵀA is always symmetric.

  • Orthogonal vectors and subspaces

    The chapter on orthogonality starts with the big picture: the row space is perpendicular to the nullspace, and the column space to the left nullspace. Two vectors are orthogonal when xᵀy = 0; Pythagoras, ‖x‖² + ‖y‖² = ‖x + y‖², reduces to exactly that, since the length squared is xᵀx (14 for (1, 2, 3)). The zero vector is orthogonal to every vector. Subspaces S and T are orthogonal when every vector in S is orthogonal to every vector in T; so a wall and the floor are not orthogonal, since they share a line. Ax = 0 says that x is orthogonal to every row of A, and so to every combination of rows: the row space and the nullspace are orthogonal, and since their dimensions r and n − r add to n, they are orthogonal complements in Rⁿ; the nullspace holds all vectors perpendicular to the rows. For A with rows (1, 2, 5) and (2, 4, 10) the nullspace is the plane perpendicular to (1, 2, 5). The rest of the chapter solves Ax = b when there is no solution, as with many noisy measurements, through AᵀAx̂ = Aᵀb. AᵀA is square and symmetric, has the same nullspace and rank as A, and is invertible exactly when the columns of A are independent.

  • Projections onto subspaces

    Projecting b onto the line through a gives the closest point p = x̂a, found from the right angle: the error e = b − x̂a is perpendicular to a, so aᵀ(b − x̂a) = 0 and x̂ = aᵀb/aᵀa. The projection matrix P = aaᵀ/aᵀa has rank one, column space the line through a, and the two defining properties Pᵀ = P and P² = P (projecting twice changes nothing). Doubling b doubles p; doubling a changes nothing. Projections are needed because Ax = b often has no solution: replace b by its projection p onto the column space and solve Ax̂ = p. For a subspace with basis a₁, …, aₙ, the columns of A, the error must be perpendicular to every column: Aᵀ(b − Ax̂) = 0, so e is in N(Aᵀ), the orthogonal complement of C(A). That gives AᵀAx̂ = Aᵀb, x̂ = (AᵀA)⁻¹Aᵀb, p = Ax̂ and P = A(AᵀA)⁻¹Aᵀ, again symmetric with P² = P. The inverse cannot be split unless A is square, and then P = I. The first application, fitting the points (1, 1), (2, 2), (3, 2) by a line b = C + Dt, gives three equations in two unknowns with no solution, to be solved by least squares.

  • Projection matrices and least squares

    P = A(AᵀA)⁻¹Aᵀ keeps what is in the column space and kills what is perpendicular to it: if b = Ax then Pb = b, and if b is in N(Aᵀ) then Pb = 0. Every b splits as b = p + e, with p = Pb in C(A) and e = (I − P)b in N(Aᵀ); I − P is the projection onto the perpendicular space. Least squares fits the points (1, 1), (2, 2), (3, 2) by the line b = C + Dt by minimizing ‖Ax − b‖² = e₁² + e₂² + e₃², the sum of squared vertical errors (linear regression; outliers can distort it). The normal equations AᵀAx̂ = Aᵀb are 3C + 6D = 5 and 6C + 14D = 11, the same equations calculus gives by setting the partial derivatives to zero. They give D = 1/2, C = 2/3: the best line is 2/3 + t/2. The points on the line are p = (7/6, 5/3, 13/6), and e = b − p = (−1/6, 1/3, −1/6) is perpendicular to p and to both columns, (1, 1, 1) and (1, 2, 3). AᵀA is invertible when A has independent columns: AᵀAx = 0 gives xᵀAᵀAx = ‖Ax‖² = 0, so Ax = 0 and x = 0. Columns that are perpendicular unit vectors, orthonormal, are certainly independent, and then AᵀA = I: the subject of the next lecture.

  • Orthogonal matrices and Gram–Schmidt

    Orthonormal vectors q₁, …, qₙ are perpendicular unit vectors: qᵢᵀqⱼ = 0 for i ≠ j and 1 for i = j. Put them in the columns of Q and the whole statement becomes QᵀQ = I, whether Q is square or rectangular. A square Q is called an orthogonal matrix, and then Qᵀ = Q⁻¹. Examples: permutation matrices; the rotation with columns (cos θ, sin θ) and (−sin θ, cos θ); the matrices of ±1 named after Hadamard, divided by √2 or 2; and (1, 2, 2)/3 with (−2, −1, 2)/3. Orthonormal columns make projections easy: P = QQᵀ (the identity if Q is square), the normal equations become x̂ = Qᵀb, and each component is a dot product, x̂ᵢ = qᵢᵀb. Gram–Schmidt turns independent vectors a, b, c into orthonormal ones: keep A = a, subtract from b its projection onto A, B = b − (Aᵀb/AᵀA)A, subtract from c its projections onto A and B, then divide each by its length. For a = (1, 1, 1), b = (1, 0, 2) it gives B = (0, −1, 1) and q₁ = (1, 1, 1)/√3, q₂ = (0, −1, 1)/√2, spanning the same plane. In matrix form A = QR, with R upper triangular because each later q is perpendicular to the earlier a's.

  • Properties of determinants

    The second half of the course turns to square matrices, and the determinant is needed for eigenvalues. Instead of a big formula, the determinant is defined by three properties: det I = 1; exchanging two rows reverses the sign (so a permutation has determinant ±1); and the determinant is linear in each row separately, with the other rows fixed: a factor t in one row comes out, and a sum in one row splits the determinant into two. (It is not true that det(A + B) = det A + det B.) From these follow: two equal rows give 0; subtracting a multiple of one row from another leaves the determinant unchanged, so elimination does not change it; a row of zeros gives 0; a triangular matrix has determinant d₁d₂⋯dₙ, the product of its diagonal; and det A = 0 exactly when A is singular. So the determinant is ± the product of the pivots, the way software computes it; for 2 × 2 the pivots a and d − (c/a)b give ad − bc. Two more properties: det AB = (det A)(det B), so det A⁻¹ = 1/det A and det A² = (det A)², while doubling gives det 2A = 2ⁿ det A (from property 3), like a volume; and det Aᵀ = det A, so every row property holds for columns too.

  • Determinant formulas and cofactors

    The three defining properties lead to a formula. Splitting each row into pieces with one nonzero entry (linearity in each row) gives 2 × 2 determinants from four pieces, two of them zero, leaving ad − bc. For 3 × 3 there are 27 pieces, and only the 6 that take one entry from each row and each column survive: three with a plus sign and three with a minus, the sign being that of the permutation of the column numbers. The big formula for n × n: det A is a sum of n! terms ± a₁α a₂β ⋯ aₙω, where (α, β, …, ω) is a permutation of (1, …, n) and the sign is + for an even permutation, − for an odd one. (The 3 × 3 diagonal rule does not extend: the 4 × 4 counter-diagonal has a plus sign.) Collecting the terms that contain a₁ⱼ gives the cofactor formula det A = a₁₁C₁₁ + a₁₂C₁₂ + ⋯ + a₁ₙC₁ₙ, where the cofactor Cᵢⱼ is (−1)^(i+j) times the determinant of the matrix with row i and column j removed. For 2 × 2 it gives ad + b(−c). There are now three formulas: the product of the pivots, the big formula, and cofactors. Cofactors suit matrices with many zeros: for the tridiagonal matrices of ones, |Aₙ| = |Aₙ₋₁| − |Aₙ₋₂|, giving 1, 0, −1, −1, 0, 1 and then repeating with period 6.

  • Cramer's rule, the inverse matrix and volume

    The determinant gives formulas for things computed so far by elimination. The inverse is A⁻¹ = Cᵀ/det A, where C is the matrix of cofactors; for 2 × 2 that is the familiar (1/(ad − bc)) times the matrix with rows (d, −b) and (−c, a). The reason: ACᵀ = (det A)I. On the diagonal, a row times its own cofactors is the cofactor formula for det A; off the diagonal, a row times the cofactors of another row is the determinant of a matrix with two equal rows, so 0. Applied to Ax = b this gives Cramer's rule: xⱼ = det Bⱼ / det A, where Bⱼ is A with column j replaced by b. It needs n + 1 determinants and is a disastrous way to compute, though the formulas are valuable for algebra. Third, |det A| is the volume of the box (parallelepiped) whose edges are the rows of A; the sign says whether the box is right- or left-handed. The unit cube and any rotated cube (A = Q, with det Q = ±1 from QᵀQ = I) have volume 1, and doubling an edge doubles both the volume and the determinant. In two dimensions the parallelogram with sides (a, b) and (c, d) has area ad − bc, with no square roots, the triangle half of that, and a triangle with any three corners has area ½ times the absolute value of a 3 × 3 determinant with a column of ones.

  • Eigenvalues and eigenvectors

    An eigenvector of a square matrix A is a nonzero vector that comes out of A in its own direction: Ax = λx, and the number λ is its eigenvalue. Eigenvalue 0 means x is in the nullspace, so A is singular. A projection has eigenvalues 1 (vectors in the plane) and 0 (vectors perpendicular to it); the 2 × 2 swap permutation has 1 for (1, 1) and −1 for (−1, 1). To find them, write (A − λI)x = 0: a nonzero x exists only when A − λI is singular, so det(A − λI) = 0, the characteristic equation, gives the n eigenvalues first, and then each x comes from the nullspace of A − λI. The eigenvalues add up to the trace and multiply to the determinant; for 2 × 2 the equation is λ² − (trace)λ + det = 0. Adding 3I adds 3 to every eigenvalue and keeps the eigenvectors, but the eigenvalues of A + B or AB are not found from those of A and B. A 90° rotation has eigenvalues i and −i, a complex conjugate pair, and a triangular matrix such as (3 1; 0 3) has a repeated eigenvalue with only one independent eigenvector.

  • Diagonalisation and powers of A

    Put n independent eigenvectors of A into the columns of S. Then AS = SΛ, where Λ is the diagonal matrix of eigenvalues, so S⁻¹AS = Λ and A = SΛS⁻¹: a new factorisation beside LU and QR. Powers become easy: A² = SΛ²S⁻¹ and Aᵏ = SΛᵏS⁻¹, the same eigenvectors with the eigenvalues raised to the k-th power. So Aᵏ → 0 exactly when every eigenvalue has |λ| < 1. A matrix is sure to be diagonalisable when its n eigenvalues are all different; with a repeated eigenvalue it may be (the identity) or may not be ((2 1; 0 2), whose eigenvalue 2 has algebraic multiplicity 2 but only one eigenvector). The difference equation u_(k+1) = Auₖ is solved by uₖ = Aᵏu₀: write u₀ = c₁x₁ + ⋯ + cₙxₙ, and each piece is multiplied by its own λ at every step. Fibonacci's rule, made into a first-order system with uₖ = (F_(k+1), Fₖ) and A = (1 1; 1 0), has eigenvalues (1 ± √5)/2 ≈ 1.618 and −0.618: the numbers grow by about 1.618 per step, and F₁₀₀ ≈ c₁(1.618)¹⁰⁰.

  • Differential equations and exp(At)

    A system du/dt = Au with constant coefficients is solved by exponentials: each eigenvalue λ with eigenvector x gives a pure solution e^(λt)x, and u(t) = c₁e^(λ₁t)x₁ + ⋯ + cₙe^(λₙt)xₙ, with the c's fixed by u(0) = Sc. This is the parallel of last lecture's λᵏ for powers. In Strang's example A = (−1 2; 1 −2), u(0) = (1, 0): the eigenvalues are 0 and −3, the solution is ⅓(2, 1) + ⅓e^(−3t)(1, −1), and it settles to the steady state (⅔, ⅓). Stability (u → 0) needs every eigenvalue to have negative real part, since |e^(6it)| = 1; a steady state needs one eigenvalue 0 and the rest with negative real parts; a positive real part blows up. For 2 × 2 the test is trace < 0 and determinant > 0. Setting u = Sv uncouples the equations into dvᵢ/dt = λᵢvᵢ, which gives u(t) = Se^(Λt)S⁻¹u(0) = e^(At)u(0). The matrix exponential is the series I + At + (At)²/2! + ⋯, which always converges; e^(Λt) is diagonal with entries e^(λᵢt). Stability for powers means |λ| < 1, for exponentials Re λ < 0. A second-order equation y″ + by′ + ky = 0 becomes a 2 × 2 system with u = (y′, y).

  • Markov matrices and Fourier series

    A Markov matrix has entries ≥ 0 and every column adding to 1, and so do all its powers. Then λ = 1 is an eigenvalue: the columns of A − I add to zero, so the rows of A − I add to the zero row, (1, 1, …, 1) is in the nullspace of (A − I)ᵀ, and A − I is singular. (A and Aᵀ always have the same eigenvalues, since det(A − λI) = det(Aᵀ − λI).) The other eigenvalues have |λ| ≤ 1, normally < 1, so uₖ = Aᵏu₀ approaches the steady state c₁x₁, the eigenvector for λ = 1, whose components are not negative. For Strang's 3 × 3 example that eigenvector is (0.6, 33, 0.7). In his population model, 0.9 of California stays and 0.1 moves, 0.8 of Massachusetts stays and 0.2 moves: eigenvalues 1 and 0.7, and 1000 people starting in Massachusetts tend to 2000/3 and 1000/3. Second topic: in an orthonormal basis q₁, …, qₙ, the coefficients of v = x₁q₁ + ⋯ + xₙqₙ are simply xᵢ = qᵢᵀv (x = Qᵀv). Fourier series do the same in a space of functions: f(x) = a₀ + a₁cos x + b₁sin x + a₂cos 2x + ⋯, with the inner product ∫₀^(2π) f(x)g(x) dx, in which the sines and cosines are orthogonal; multiplying by cos x and integrating gives a₁ = (1/π)∫₀^(2π) f(x)cos x dx.

  • Symmetric matrices and positive definiteness

    A real symmetric matrix (A = Aᵀ) has real eigenvalues, and its eigenvectors can be chosen perpendicular (with a repeated eigenvalue there is a whole plane to choose from), and there is a full set of them. Made into unit vectors they form an orthogonal matrix Q, so A = SΛS⁻¹ becomes A = QΛQᵀ: the spectral theorem, or in mechanics the principal axis theorem. Why real: from Ax = λx, conjugate and transpose to get x̄ᵀA = λ̄x̄ᵀ (this uses A = Aᵀ and A real), multiply by x and compare with x̄ᵀAx = λx̄ᵀx; since x̄ᵀx = |x₁|² + ⋯ + |xₙ|² > 0, λ = λ̄. For complex matrices the good ones (real eigenvalues, perpendicular eigenvectors) have Āᵀ = A. Written out, A = λ₁q₁q₁ᵀ + λ₂q₂q₂ᵀ + ⋯: a combination of perpendicular projection matrices. For a symmetric matrix the signs of the pivots are the signs of the eigenvalues: as many positive pivots as positive eigenvalues, which is a safe way to count them. Positive definite matrices are the symmetric ones with all eigenvalues positive, equivalently all pivots positive, equivalently all upper-left sub-determinants positive. Strang's example (5 2; 2 3) has pivots 5 and 11/5, sub-determinants 5 and 11, and eigenvalues 4 ± √5; (−1 0; 0 −3) has a positive determinant but is not positive definite.

  • Complex matrices and the fast Fourier transform

    For complex vectors z in Cⁿ, zᵀz is the wrong length: for z = (1, i) it gives 1 + i² = 0. The right length squared is z̄ᵀz = |z₁|² + ⋯ + |zₙ|², written zᴴz (H for Hermite: transpose and conjugate together); (1, i) has length √2. The inner product is yᴴx. Symmetric becomes Hermitian, Aᴴ = A (real diagonal, entries 3 + i and 3 − i across it); such matrices have real eigenvalues and perpendicular eigenvectors. Orthonormal columns now mean qᵢᴴqⱼ = 0 or 1, i.e. QᴴQ = I, and a square Q of that kind is unitary. The Fourier matrix Fₙ has entries Wⁱʲ (i, j from 0 to n − 1), with W = e^(2πi/n), the first n-th root of 1 on the unit circle; for n = 4, W = i. Its columns are orthogonal, each of length √n, so Fₙ⁻¹ is Fₙᴴ/n. The fast Fourier transform rests on W₆₄² = W₃₂: F₆₄ = [I D; I −D] [F₃₂ 0; 0 F₃₂] P, where P puts the even components before the odd ones and D = diag(1, W, …, W³¹). Repeating the split brings the cost of multiplying by Fₙ down from n² to ½n log₂ n: for n = 1024, about 5 · 1024 instead of 1024², a factor of about 200.

  • Positive definite matrices and minima

    For a symmetric 2 × 2 matrix (a b; b c), four tests for positive definiteness agree: both eigenvalues positive; the upper-left determinants a and ac − b² positive; the pivots a and (ac − b²)/a positive; and the new one, which most books take as the definition: xᵀAx = ax² + 2bxy + cy² > 0 for every x ≠ 0. With b = 6 and a = 2, the matrix needs c > 18. At c = 18 it is positive semidefinite (eigenvalues 0 and 20, one pivot); at c = 7 the determinant is −22, the form 2x² + 12xy + 7y² is negative at (1, −1), and its graph is a saddle. At c = 20, completing the square gives 2(x + 3y)² + 2y²: the pivots 2, 2 stand outside the squares and the multiplier 3 inside, so completing the square is elimination, and the graph is a bowl with its minimum at the origin. Cutting the bowl at height 1 gives an ellipse (a saddle gives a hyperbola). As in calculus, a minimum needs zero first derivatives and a positive definite matrix of second derivatives (f_xx, f_xy; f_xy, f_yy), which is symmetric because f_xy = f_yx. For the 3 × 3 matrix with 2 on the diagonal and −1 beside it: determinants 2, 3, 4; pivots 2, 3/2, 4/3; eigenvalues 2 − √2, 2, 2 + √2; xᵀAx = 1 is an ellipsoid whose axes point along the eigenvectors (A = QΛQᵀ, the principal axis theorem).

  • Similar matrices and the Jordan form

    First, more on positive definite matrices: if A is positive definite so is A⁻¹ (eigenvalues 1/λ), and so is A + B when B is (add xᵀAx > 0 and xᵀBx > 0). For a rectangular m × n matrix A, AᵀA is square and symmetric, and xᵀAᵀAx = (Ax)ᵀ(Ax) = ‖Ax‖² ≥ 0; it is positive definite exactly when Ax = 0 only for x = 0, i.e. rank n (independent columns). Then similar matrices: B is similar to A when B = M⁻¹AM for some invertible M. Diagonalisation, S⁻¹AS = Λ, is the special case M = S. Similar matrices have the same eigenvalues: from Ax = λx, B(M⁻¹x) = λ(M⁻¹x), so the eigenvector moves to M⁻¹x. Strang's example: A = (2 1; 1 2), M = (1 4; 0 1) give B = (−2 −15; 1 6), with trace 4 and determinant 3 like A, eigenvalues 3 and 1. With a repeated eigenvalue the matrices split into families: 4I is similar only to itself, while (4 1; 0 4), (5 1; −1 3), (4 0; 17 4) and every other matrix with eigenvalues 4, 4 that is not 4I form one family, each with only one eigenvector. Counting eigenvectors is not enough: two 4 × 4 matrices with eigenvalue 0 four times and rank 2 can differ in their Jordan blocks (3 + 1 versus 2 + 2). Jordan's theorem: every square matrix is similar to a Jordan matrix J made of blocks with one eigenvalue on the diagonal and ones just above it, one block per eigenvector; with distinct eigenvalues J = Λ. It is hard to compute, since the slightest change in the numbers changes it.

  • Singular value decomposition

    Every matrix A, of any shape, factors as A = UΣVᵀ: orthogonal, diagonal, orthogonal. For a symmetric positive definite matrix this is QΛQᵀ with one Q on both sides, but in general the two orthogonal matrices differ. The goal: an orthonormal basis v₁, …, v_r of the row space that A sends to multiples of an orthonormal basis u₁, …, u_r of the column space, Avᵢ = σᵢuᵢ, so AV = UΣ; orthonormal bases of the two nullspaces complete V and U and give zeros in Σ. To find them, AᵀA = VΣᵀΣVᵀ removes U: the v's are the eigenvectors of AᵀA and the σ² its eigenvalues; likewise the u's are the eigenvectors of AAᵀ, which has the same nonzero eigenvalues. Strang's example (4 4; −3 3) gives AᵀA = (25 7; 7 25) with eigenvalues 32 and 18, v's (1, 1)/√2 and (1, −1)/√2, σ's √32 and √18, and AAᵀ = diag(32, 18); his product came out with a wrong sign in the second row, a puzzle he left for later (taking u₂ = Av₂/σ₂ = (0, −1) fixes it). The rank-one example (4 3; 8 6) has AᵀA = (80 60; 60 45) with eigenvalues 125 and 0, σ₁ = √125, v₁ = (0.8, 0.6), u₁ = (1, 2)/√5. The SVD chooses the right bases for all four fundamental subspaces: orthonormal, and making A diagonal.

  • Linear transformations and their matrices

    A linear transformation T takes input vectors to output vectors and respects the two vector operations: T(v + w) = T(v) + T(w) and T(cv) = cT(v), or in one rule T(cv + dw) = cT(v) + dT(w). It can be described without coordinates. Projection onto a line and rotation by 45° are linear. Shifting the plane by a fixed v₀ is not (T(0) must be 0), and neither is taking the length, since T(−2v) would have to be −2T(v). Multiplying by a matrix, T(v) = Av, is always linear; (1 0; 0 −1) turns a house upside down, and a 2 × 3 matrix takes R³ to R². To know T it is enough to know T(v₁), …, T(vₙ) for a basis, because T(c₁v₁ + ⋯ + cₙvₙ) = c₁T(v₁) + ⋯ + cₙT(vₙ). Coordinates come from a basis. With an input basis v₁, …, vₙ and an output basis w₁, …, w_m, the matrix A of T has as column j the coefficients of T(vⱼ) in the w's; then A times input coordinates gives output coordinates. Projection onto a line, in the basis along and across the line (its eigenvectors), has matrix (1 0; 0 0) = Λ; in the standard basis, for the 45° line, it is (½ ½; ½ ½). The derivative from c₁ + c₂x + c₃x² to c₂ + 2c₃x has the 2 × 3 matrix (0 1 0; 0 0 2).

  • Change of basis and image compression

    Image compression is a change of basis. A 512 × 512 gray-scale image is a vector x in Rⁿ with n = 512², each pixel a value from 0 to 255 (8 bits). The standard basis, one pixel at a time, ignores that neighbouring pixels are nearly equal; a better basis contains the all-ones vector, which alone carries a blank board, and vectors like (1, −1, 1, −1, …) or half ones and half minus ones. JPEG cuts the image into 8 × 8 blocks of 64 pixels and changes each block to the Fourier basis: a lossless step x → c. The lossy step throws away coefficients below a threshold, keeping ĉ with many zeros, perhaps 3 of 64, a compression of about 21 to 1. Video also uses the correlation between successive frames (prediction and correction). Wavelets compete with Fourier: the 8 Haar wavelets are the all-ones vector, four ones and four minus ones, two-by-two blocks and pairs (1, −1); the checkerboard vector is the sum of the last four. Changing basis means solving P = Wc, so c = W⁻¹P. A good basis must be fast (FFT; wavelet columns orthogonal, so W⁻¹ is Wᵀ after normalising) and must compress well (a few basis vectors close to the signal). The same transformation has matrix A in one basis and B in another, and they are similar, B = M⁻¹AM, with M the change-of-basis matrix. Column j of A holds the coefficients of T(vⱼ); in an eigenvector basis T(vⱼ) = λⱼvⱼ and A = Λ, the perfect but too expensive basis.

  • Left and right inverses; the pseudoinverse

    For an m × n matrix of rank r, the picture of the four subspaces decides which inverse exists. Full rank r = m = n: a two-sided inverse, A⁻¹A = I = AA⁻¹. Full column rank r = n: the nullspace is only zero, Ax = b has 0 or 1 solutions, AᵀA is invertible, and A_left⁻¹ = (AᵀA)⁻¹Aᵀ gives A_left⁻¹A = I (n × n); in the other order, A(AᵀA)⁻¹Aᵀ is the projection onto the column space. Full row rank r = m: Ax = b always has solutions, infinitely many with n − m free variables, AAᵀ is invertible, and A_right⁻¹ = Aᵀ(AAᵀ)⁻¹ gives AA_right⁻¹ = I; in the other order Aᵀ(AAᵀ)⁻¹A projects onto the row space. A rectangular matrix never has a two-sided inverse. In general (r < m, r < n), A is still one-to-one from the row space onto the column space: if x ≠ y are in the row space then Ax ≠ Ay, because x − y would be in both the row space and the nullspace, hence zero. The inverse of that map is the pseudoinverse A⁺, which statisticians need for least squares when AᵀA is singular. From the SVD A = UΣVᵀ: A⁺ = VΣ⁺Uᵀ, where Σ⁺ inverts the r nonzero σ's (1/σ₁, …, 1/σ_r) and is n × m; ΣΣ⁺ and Σ⁺Σ are the projections onto the column space and the row space of Σ, and AA⁺ = UΣΣ⁺Uᵀ and A⁺A = VΣ⁺ΣVᵀ those of A.

  • Problem set Problem Set 1: linear equations, elimination and matrix multiplication

    Six problems of our own on Lectures 1 to 3: the row and column pictures of a system, singular and invertible matrices, elimination with multipliers and pivots, back substitution, elimination and permutation matrices, the four ways to multiply matrices, block multiplication, and the idea of the inverse.

    Practises lectures 1, 2, 3

  • Problem set Problem Set 2: inverses, A = LU, permutations and subspaces

    Seven problems of our own on Lectures 3, 4 and 5: inverses by Gauss–Jordan elimination, the inverse of a product, the factorization A = LU and A = LDU, the elimination matrix E against L, the cost of elimination, row exchanges with PA = LU, permutation matrices, transposes and symmetric products, vector spaces, subspaces and the column space.

    Practises lectures 3, 4, 5

  • Problem set Problem Set 3: column space, nullspace and the complete solution

    Six problems of our own on Lectures 6, 7 and 8: which sets are subspaces, unions and intersections, the column space and the nullspace of a matrix, elimination on a rectangular matrix, pivot and free variables, special solutions, the reduced row echelon form, the condition for Ax = b to be solvable, the particular and the complete solution, rank and the number of solutions, and finding a matrix from its solutions.

    Practises lectures 6, 7, 8

  • Problem set Problem Set 4: independence, bases and the four subspaces

    Six problems of our own on Lectures 9 and 10: testing vectors for independence, the span of a set of vectors and a basis chosen from it, extending a basis, when three vectors are a basis of R³, why the right number of independent vectors is a basis, the four fundamental subspaces of a matrix with their dimensions and bases, the left nullspace from Gauss–Jordan, counting dimensions, and which subspaces row operations keep.

    Practises lectures 9, 10

  • Problem set Problem Set 5: matrix spaces, graphs and orthogonal subspaces

    Six problems of our own on Lectures 11, 12 and 14: subspaces of the space of 3 × 3 matrices with their dimensions, intersections and sums, solution spaces of differential equations, rank-one matrices and the rank of a sum, the incidence matrix of a graph with its potentials, currents, loops and trees, the network equation AᵀCAx = f, orthogonal vectors and Pythagoras, orthogonal subspaces, the nullspace as the orthogonal complement of the row space, and the nullspace of AᵀA.

    Practises lectures 11, 12, 14

  • Problem set Problem Set 6: projections, least squares and Gram–Schmidt

    Six problems of our own on Lectures 15, 16 and 17: projecting onto a line and onto a plane, the projection matrix and its two properties, the closest point, fitting a straight line by least squares and the effect of an outlier, the projection onto the perpendicular space, reflections, when AᵀA is invertible, Gram–Schmidt and A = QR, projections with orthonormal vectors, and orthogonal matrices.

    Practises lectures 15, 16, 17

  • Problem set Problem Set 7: determinants, eigenvalues and powers of a matrix

    Eight problems of our own on Lectures 18 to 22: the rules that define the determinant, a determinant by elimination, by the big formula and by cofactors, a family of tridiagonal determinants, the inverse from cofactors and Cramer's rule, areas and volumes, eigenvalues and eigenvectors with a shift and a parameter, powers of a matrix from its diagonalisation, and a recurrence and when a matrix with a repeated eigenvalue can be diagonalised.

    Practises lectures 18, 19, 20, 21, 22

  • Problem set Problem Set 8: differential equations, exp(At) and Markov matrices

    Seven problems of our own on Lectures 23 and 24: solving a system du/dt = Au from its eigenvalues and eigenvectors, stability from the trace and the determinant, the matrix exponential and the two series it is compared with, a third-order equation written as a system, a two-state and a three-state Markov chain and their steady states, and coefficients in an orthonormal basis and in a Fourier series.

    Practises lectures 23, 24

  • Problem set Problem Set 9: symmetric and positive definite matrices

    Seven problems of our own on Lectures 25 and 27: the spectral theorem and a sum of projections, why the eigenvalues of a symmetric matrix are real and its eigenvectors perpendicular, counting eigenvalues by the signs of pivots, the tests for positive definiteness on a matrix with a parameter, completing the square, the ellipse of a quadratic form, and the second-derivative test for a minimum.

    Practises lectures 25, 27

  • Problem set Problem Set 10: complex matrices, similar matrices and the SVD

    Seven problems of our own on Lectures 26, 28 and 29: lengths and inner products of complex vectors, the eigenvalues of a Hermitian matrix, the four-point Fourier matrix and its inverse, the counting behind the fast Fourier transform, similar matrices, Jordan blocks and how fragile they are, and the singular value decomposition of a square and of a rectangular matrix.

    Practises lectures 26, 28, 29

Not written yet