Skip to content

10 min read

Linear algebra speedrun

Cram notes for a first linear algebra course: extracting a maximal independent subset, null space bases, change of basis, rank, determinants and LU, the adjugate, diagonalization, Gram-Schmidt, and quadratic forms.

Exam-cram notes from February 2023, rebuilt and carefully checked afterwards.

Vectors and independence

Extracting a maximal independent subset

Given vectors a1,,aka_1,\dots,a_k, select a maximal subset of them that is linearly independent. A basis of the span could be assembled from combinations; here the answer must be drawn from the given vectors themselves.

Put the vectors in as the columns of a matrix AA, row-reduce to reduced row echelon form, and note which columns hold pivots. The original columns in those positions are a maximal linearly independent subset, and there are rank(A)\operatorname{rank}(A) of them.

This works because row operations preserve every linear dependence among the columns. A relation cjaj=0\sum c_ja_j=0 is a vector in the null space, row operations leave the null space untouched, and so the dependencies visible in the echelon form are the dependencies in the original.

Row-reducing a matrix whose rows are the vectors returns a basis for the span built out of combinations of the inputs. The singular value decomposition A=UΣVTA=U\Sigma V^{T} gives rank(A)\operatorname{rank}(A) as the number of nonzero singular values, with the leading columns of UU an orthonormal basis for the column space. Both describe the span without selecting from the inputs.

The change of basis matrix

Let B=(b1,,bn)B=(b_1,\dots,b_n) and B=(b1,,bn)B'=(b'_1,\dots,b'_n) be bases of a vector space VV. Express each new basis vector in the old basis:

bj=i=1npijbi.b'_j=\sum_{i=1}^{n}p_{ij}\,b_i .

The scalar pijp_{ij} is the ii-th coordinate of bjb'_j, so the jj-th column of PP is the coordinate vector of bjb'_j in the basis BB. In matrix form,

[b1bn]=[b1bn]P.\begin{bmatrix}b'_1&\cdots&b'_n\end{bmatrix}=\begin{bmatrix}b_1&\cdots&b_n\end{bmatrix}P .

PP is invertible, both families being bases. A vector with coordinate column yy with respect to BB' has coordinates PyPy with respect to BB, and P1P^{-1} carries coordinates back.

A basis for the null space

To solve Ax=0Ax=0, row-reduce AA to reduced row echelon form. Variables in pivot columns are the leading variables, determined by the rest; variables in non-pivot columns are free. With r=rank(A)r=\operatorname{rank}(A) and nn columns there are nrn-r free variables, and setting one of them to 11 with the others at 00 and back-substituting produces nrn-r solutions forming a basis for the null space.

Row operations are the only ones available here. They recombine equations and leave the solution set alone, whereas column operations recombine the variables and give the null space of a different system.

Rank

Row rank equals column rank

The row rank is the dimension of the span of the rows, the column rank the dimension of the span of the columns. They agree for every matrix, including rectangular ones where the two spans live in different spaces.

Reducing AA to echelon form establishes that the row rank is the number of nonzero rows that survive, and a separate argument has to bring the columns in. A factorization does it. Let rr be the column rank and CC be m×rm\times r with columns a basis of the column space. Every column of AA is a combination of those, so A=CRA=CR for some r×nr\times n matrix RR. Read that product by rows instead: every row of AA is a combination of the rr rows of RR, so the row rank is at most rr. The same argument applied to ATA^{T} gives the reverse inequality.

The geometric reason

An m×nm\times n matrix is a map RnRm\mathbb{R}^n\to\mathbb{R}^m.

Inside the domain Rn\mathbb{R}^n, the null space and the row space are orthogonal complements, since Ax=0Ax=0 says precisely that xx is orthogonal to every row. So

dim(row space)+dim(null space)=n,\dim(\text{row space})+\dim(\text{null space})=n,

while rank-nullity says

dim(column space)+dim(null space)=n.\dim(\text{column space})+\dim(\text{null space})=n .

Subtract to get the theorem. Geometrically, AA annihilates the null space and maps the row space isomorphically onto the column space. If xx lies in the row space with Ax=0Ax=0, then xx is orthogonal to itself and therefore zero, so the restriction is injective; and splitting any xx into row-space and null-space parts leaves only the first contributing, so the restriction is onto. The two spaces are copies of one another, which is why their dimensions match.

The theorem makes rank stable under transposition. Reordering a product is a different matter: with A=[10]A=\begin{bmatrix}1&0\end{bmatrix} and B=[01]B=\begin{bmatrix}0\\1\end{bmatrix}, ABAB is the 1×11\times1 zero matrix of rank 00 while BABA has rank 11.

Determinants

Cofactor expansion

The minor MijM_{ij} is the determinant of the submatrix left after deleting row ii and column jj. The cofactor attaches a sign depending on the parity of i+ji+j:

Aij=(1)i+jMij.A_{ij}=(-1)^{i+j}M_{ij}.

Expanding along any row,

detA=j=1naijAij.\det A=\sum_{j=1}^{n}a_{ij}A_{ij}.

The diagonal rule, taking signed products along wrapped diagonals, is valid only for n3n\leq 3. The full expansion is a sum over all n!n! permutations signed by parity, and wrapped diagonals supply just 2n2n of them.

Cramer’s rule runs in the other direction, solving a linear system from determinants already in hand: xi=det(Ai)/det(A)x_i=\det(A_i)/\det(A), where AiA_i is AA with column ii replaced by the right-hand side.

The adjugate

Collect the cofactors into a matrix CC with Cij=AijC_{ij}=A_{ij} and transpose it, the sign going on once as the cofactor is formed:

adj(A)=CT,adj(A)ij=Cji.\operatorname{adj}(A)=C^{T},\qquad \operatorname{adj}(A)_{ij}=C_{ji}.

The defining property is

Aadj(A)=adj(A)A=det(A)I,A\operatorname{adj}(A)=\operatorname{adj}(A)A=\det(A)\,I,

from which A1=1detAadj(A)A^{-1}=\frac{1}{\det A}\operatorname{adj}(A) when detA0\det A\neq0.

Every square matrix has an adjugate, singular ones included, since it is assembled from determinants of submatrices and divides by nothing. What a singular matrix lacks is the inverse. There the identity above reads Aadj(A)=0A\operatorname{adj}(A)=0, and the rank of the adjugate follows from the rank of AA: at rank(A)=n1\operatorname{rank}(A)=n-1 the adjugate has rank 11 and its columns span the null space of AA, and below that every (n1)×(n1)(n-1)\times(n-1) minor vanishes and the adjugate is zero. For A=[123456789]A=\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}, of rank 22, the adjugate is [3636126363]\begin{bmatrix}-3&6&-3\\6&-12&6\\-3&6&-3\end{bmatrix}, whose columns are multiples of (1,2,1)(1,-2,1), spanning the null space.

By elimination

Reduce to triangular form and multiply the diagonal, tracking what each operation does. Adding a multiple of one row to another leaves the determinant unchanged, which is what makes elimination usable. Swapping two rows negates it. Scaling a row by kk multiplies it by kk.

LU decomposition

Elimination without row swaps factors A=LUA=LU, with LL unit lower triangular holding the multipliers and UU upper triangular. Take

A=[211433879].A=\begin{bmatrix}2&1&1\\4&3&3\\8&7&9\end{bmatrix}.

Eliminating by R22R1R_2-2R_1, R34R1R_3-4R_1, then R33R2R_3-3R_2 leaves

U=[211011002],L=[100210431],U=\begin{bmatrix}2&1&1\\0&1&1\\0&0&2\end{bmatrix},\qquad L=\begin{bmatrix}1&0&0\\2&1&0\\4&3&1\end{bmatrix},

the multipliers 22, 44, 33 sitting at the positions they cleared.

Since detL=1\det L=1, detA=detU=iUii\det A=\det U=\prod_i U_{ii}. For

A=[21347761822]A=\begin{bmatrix}2&1&3\\4&7&7\\6&18&22\end{bmatrix}

the multipliers are 22, 33, 33, giving U=[2130510010]U=\begin{bmatrix}2&1&3\\0&5&1\\0&0&10\end{bmatrix} and detA=2510=100\det A=2\cdot5\cdot10=100, which cofactor expansion confirms.

Not every matrix factors this way. A zero pivot forces a row swap, and the general statement is PA=LUPA=LU with PP a permutation matrix, whence detA=(1)siUii\det A=(-1)^{s}\prod_iU_{ii} for ss swaps. Numerical work uses partial pivoting regardless, for stability.

Cofactor expansion is O(n!)O(n!) and elimination is O(n3)O(n^3), which is the difference between infeasible and routine somewhere around n=20n=20.

Eigenvalues and diagonalization

Computing them

The eigenvalues of an n×nn\times n matrix AA are the roots of the characteristic polynomial det(λIA)=0\det(\lambda I-A)=0, of degree nn. For each λi\lambda_i, the eigenvectors are the nonzero solutions of

(AλiI)x=0.(A-\lambda_i I)x=0 .

That system always has nontrivial solutions, which is what being an eigenvalue means: det(AλiI)=0\det(A-\lambda_iI)=0, so the matrix is singular and its null space is larger than {0}\{0\}. The system is homogeneous, so it is never inconsistent, and its matrix is singular, so the solution is never unique.

Eigenvalues come from the characteristic polynomial first, eigenvectors from the null space of AλIA-\lambda I second, since the definition of an eigenvector already presumes a λ\lambda.

For a repeated eigenvalue, take a basis of that null space, the eigenspace. Its dimension is the geometric multiplicity, which can fall short of the algebraic multiplicity and never exceeds it.

When a matrix is diagonalizable

AA is diagonalizable when some invertible PP makes P1AP=DP^{-1}AP=D diagonal, equivalently A=PDP1A=PDP^{-1} with the columns of PP eigenvectors and the diagonal of DD their eigenvalues.

The criterion is that AA has nn linearly independent eigenvectors, which holds exactly when geometric multiplicity equals algebraic multiplicity for every eigenvalue.

An AA with nn distinct eigenvalues is diagonalizable, because eigenvectors belonging to distinct eigenvalues are always linearly independent, which makes distinctness the cheapest sufficient test available. It is sufficient without being necessary: the identity matrix has a single eigenvalue and is already diagonal.

Failure requires a repeated eigenvalue whose eigenspace is too small. The smallest instance is

[2102],\begin{bmatrix}2&1\\0&2\end{bmatrix},

with eigenvalue 22 of algebraic multiplicity 22 and a one-dimensional eigenspace. Such a matrix is similar to a Jordan form whose blocks exceed 1×11\times 1.

Gram-Schmidt

Given linearly independent a1,,aka_1,\dots,a_k, set q1=a1/a1q_1=a_1/\lVert a_1\rVert and, for each jj in turn,

vj=aji<j(ajqi)qi,qj=vjvj.v_j=a_j-\sum_{i<j}(a_j\cdot q_i)\,q_i,\qquad q_j=\frac{v_j}{\lVert v_j\rVert}.

Each step strips from aja_j its projection onto everything already orthonormalized, leaving the part orthogonal to that span.

Correctness is an induction. Suppose q1,,qj1q_1,\dots,q_{j-1} are orthonormal. For any i<ji<j,

qivj=qiajl<j(ajql)(qiql)=qiaj(ajqi)=0,q_i\cdot v_j=q_i\cdot a_j-\sum_{l<j}(a_j\cdot q_l)(q_i\cdot q_l)=q_i\cdot a_j-(a_j\cdot q_i)=0,

since qiqlq_i\cdot q_l vanishes unless l=il=i, where it is 11. So vjv_j is orthogonal to all its predecessors, and normalizing preserves that.

If aja_j lies in the span of its predecessors, vjv_j is 00 and the normalization divides by zero, which is how the algorithm reports the dependence.

Collecting the qjq_j as columns of QQ gives A=QRA=QR with RR upper triangular. In floating point, classical Gram-Schmidt loses orthogonality badly; modified Gram-Schmidt and Householder reflections are what numerical libraries use.

Quadratic forms

Definition

A quadratic form in nn variables is a homogeneous polynomial of degree two,

Q(x1,,xn)=i=1nj=1naijxixj=xTAx.Q(x_1,\dots,x_n)=\sum_{i=1}^{n}\sum_{j=1}^{n}a_{ij}x_ix_j=x^{T}Ax .

Take AA symmetric. Nothing is lost, since xTAxx^{T}Ax and xT ⁣(A+AT2) ⁣xx^{T}\!\left(\frac{A+A^{T}}{2}\right)\!x agree for every xx, and symmetry delivers the real eigenvalues and orthogonal eigenbasis everything below relies on.

Cross terms xixjx_ix_j with iji\neq j are degree two and belong here. They are what diagonalization clears.

Standard form and normal form

The standard form is what an orthogonal change of variables produces. By the spectral theorem a real symmetric AA factors as A=PDPTA=PDP^{T} with PP orthogonal, so PTAP=DP^{T}AP=D, and substituting x=Pyx=Py gives

Q=λ1y12++λnyn2Q=\lambda_1y_1^2+\cdots+\lambda_ny_n^2

with the λi\lambda_i the eigenvalues of AA. The yiy_i are the new coordinates; the eigenvectors are the columns of PP.

The normal form allows any nonsingular change of variables, which can rescale each coordinate and drive every nonzero coefficient to ±1\pm1:

Q=y12++yp2yp+12yp+q2.Q=y_1^2+\cdots+y_p^2-y_{p+1}^2-\cdots-y_{p+q}^2 .

Sylvester’s law of inertia says pp and qq do not depend on the route taken. The standard form keeps the eigenvalues; the normal form keeps only their signs.

Eigenvectors for distinct eigenvalues of a symmetric matrix are automatically orthogonal, so normalizing is enough for them. Within a repeated eigenvalue any basis of the eigenspace will do, and it has to be orthonormalized by Gram-Schmidt before going into PP; the product PDPTPDP^{T} then reassembles AA.

Definiteness

For a real symmetric AA:

  • Positive definite: Q(x)>0Q(x)>0 for all x0x\neq 0, equivalently every eigenvalue is positive.
  • Negative definite: Q(x)<0Q(x)<0 for all x0x\neq 0, equivalently every eigenvalue is negative.
  • Positive semidefinite: Q(x)0Q(x)\geq0 for all xx, equivalently every eigenvalue is nonnegative.
  • Negative semidefinite: Q(x)0Q(x)\leq0 for all xx, equivalently every eigenvalue is nonpositive.
  • Indefinite: QQ takes both signs, equivalently eigenvalues of both signs occur.

Each criterion quantifies over all the eigenvalues, so semidefiniteness turns on the absence of eigenvalues of the opposite sign. A zero eigenvalue rules out the strict forms and decides nothing further: eigenvalues 11, 00 and 1-1 give an indefinite form, while 11, 00 and 00 give a positive semidefinite one.