Linear Algebra
Seven ideas from a second course in linear algebra, done the way Axler does it: operators first, determinants last. Drag vectors to test subspaces and change bases, bend the plane with a matrix, hunt for eigenvectors, project onto subspaces, watch circles become ellipses, then check yourself with concept questions, practice problems and exercises from the book.
Follows the chapter order of S. Axler, Linear Algebra Done Right, 4th ed. (Springer, 2024; open access), Chapters 1–3 and 5–9. Result numbers refer to that book; the questions and examples here are written for this page. Exercises from the book appear at the end of each module, with their numbers from the book and their statements restated in our own words. Exercises from the book appear at the end of each module, with their numbers from the book and their statements restated in our own words. For how this subject feeds the others on this site, see the roadmap.
Vector spaces and subspaces
A vector space is anywhere you can add things and scale them, with the usual rules. A subspace is a subset you can't leave by adding or scaling. That one closure condition rules out most sets you might draw.
The idea
Examples:
Explore
Worked example
Let
Compute
. forces . So , a line, not .So the sum is not direct. Exhibit a vector with two decompositions.
, with the first term in and the second in both times.Find
.Every vector in either has
, so , a 3-dimensional space. By Axler 2.43, , so they are equal.
Check your understanding
Which of these is a subspace of
It doesn't contain 0. leaves the set.
Is the set of polynomials of degree exactly 3 a subspace of
- Yes.Add
and . - No.
Three lines through 0 in
- Yes, the pairwise intersections are
.That test is only valid for two subspaces. - No: the sum is
, and 0 can be written as a nonzero sum.
Practice
Functions as vectorsA subspace you can't draw
Show that
Solution
The first condition is linear: if
Even and oddA direct sum of function spaces
Show that
Solution
Write
From Axler, Linear Algebra Done Right (4th ed., Springer, 2024; open access)
Numbers match the book. Each question is restated in our own words; the hints and solutions are written for this page.
Exercise 1C.10Intersections of subspaces
If
Hint
Check the three conditions; each holds in both subspaces separately.
Solution
Exercise 1C.12When is a union a subspace?
Prove that the union of two subspaces of
Hint
If neither contains the other, pick
Solution
If
Conversely, suppose
Exercise 1C.20A complement in 𝐅⁴
For
Hint
Solution
Take
There are many other choices: any 2-dimensional
Span, independence and bases
A basis is a coordinate system: every vector is a combination of the basis vectors in exactly one way. Spanning gives "at least one way", independence gives "at most one", and the key inequality between them makes dimension well defined.
The idea
The proof is a swap: insert the independent vectors one at a time into the spanning list, and each time the linear dependence lemma (Axler 2.19) lets you throw out one of the original spanning vectors. You never run out, so there were at least as many of them.
Explore
Worked example
Find a basis of
Guess a natural list in
. : all vanish at 6.Why is it independent?
The degrees are 1, 2, 3, 4: in a combination equal to 0, the top-degree term can't cancel, so its coefficient is 0; repeat downward.
Why does it span
? (Use dimension instead of solving.) (the constant 1 is missing), so . It contains 4 independent vectors, so , and an independent list of the right length is a basis (Axler 2.38).
Check your understanding
Can four vectors in
- Yes, if chosen carefully.The standard basis is a spanning list of length 3.
- No.
- 0Use
. - 2
- 5That's the largest.
What is
Count .
Practice
Extending to a basisAxler 2.32
Extend
Solution
Add
Complements always existAxler 2.33
Show every subspace
Solution
Extend a basis
From Axler, Linear Algebra Done Right (4th ed., Springer, 2024; open access)
Numbers match the book. Each question is restated in our own words; the hints and solutions are written for this page.
Exercise 2A.1Four vectors spanning a plane
Find four distinct vectors in
Hint
The plane is 2-dimensional. Any two independent vectors in it span it, and extra vectors in it don't enlarge the span.
Solution
Take
Exercise 2A.6Dependent exactly when c = 8
Show that
Hint
The first two vectors are independent, so the list is dependent iff the third is a combination of the first two.
Solution
Exercise 2C.14Three big subspaces must meet
Let
Hint
Apply
Solution
Linear maps and rank–nullity
A linear map is determined by what it does to a basis, and whatever it loses (the null space) is exactly what it fails to reach (in dimension count). That is the fundamental theorem of linear maps.
The idea
Consequences: a map to a smaller space can't be injective; a map to a larger space can't be surjective; an operator on a finite-dimensional space is injective iff surjective iff invertible (Axler 3.65). The matrix of
Explore
Worked example
Let
Null space?
iff is constant: , dimension 1.Range?
Derivatives of degree-
polynomials have degree , and every such is for an antiderivative . So , dimension 4.Check.
. And since is not injective, it is not surjective either, as the theorem predicts for an operator.
Check your understanding
Can a linear map
- Yes.Its range has dimension at most 3.
- No.
- 3Orientation reversal flips the sign.
- −3
- 1/3That's
up to sign.
- Injective, not surjective.
- Both, since it's an operator.That equivalence needs finite dimension.
Practice
Prescribing a map on a basisAxler 3.4
Is there a linear
Solution
First: yes, uniquely, since
Rank of a productComposition
Show
Solution
From Axler, Linear Algebra Done Right (4th ed., Springer, 2024; open access)
Numbers match the book. Each question is restated in our own words; the hints and solutions are written for this page.
Exercise 3B.1Prescribed null space and range
Give an example of a linear map
Hint
The fundamental theorem says the domain must be 5-dimensional.
Solution
Exercise 3B.4Maps with a big null space don't form a subspace
Show that
Hint
Find two such maps whose sum has a small null space.
Solution
Let
Exercise 3B.10Images of a spanning list span the range
If
Hint
Write an arbitrary vector of the range as
Solution
Each
Eigenvalues and eigenvectors
An eigenvector is a direction the operator doesn't turn, only stretches. Find enough of them and the operator becomes a list of numbers acting on independent axes.
The idea
Axler's proof of existence avoids determinants: for nonzero
Explore
Worked example
Diagonalize
Find the eigenvalues.
is not invertible iff , so .Eigenvectors?
: . : . They form a basis, so is diagonalizable with matrix in this basis.Compute
. , so . In the eigenbasis, powers are just powers of numbers.
Check your understanding
Rotation of
- None.
- One.Every nonzero vector is turned.
- Two.
Is the shear
- Yes, it is upper triangular.Triangular is weaker than diagonalizable.
- No: its only eigenvalue is 1 and the eigenspace is a line.
An operator on
- Yes.
- Not necessarily.Four distinct eigenvalues on a 4-dimensional space.
Practice
Invariant subspacesAxler 5.2
Show that for any
Solution
If
Eigenvalues of a polynomial in TSpectral mapping
If
Solution
From Axler, Linear Algebra Done Right (4th ed., Springer, 2024; open access)
Numbers match the book. Each question is restated in our own words; the hints and solutions are written for this page.
Exercise 5A.5A map with no real eigenvalues
Find the eigenvalues of
Hint
Compute
Solution
Exercise 5A.10Eigenvectors of x d/dx
Define
Hint
Try monomials.
Solution
Exercise 5D.1Diagonalizability from a polynomial equation
For
Hint
The minimal polynomial divides any polynomial that kills
Solution
(a) The minimal polynomial divides
(b) It divides
(c)
Inner products and orthogonal projection
An inner product adds lengths and angles. Its most useful consequence: the closest point of a subspace to a vector is its orthogonal projection, which is how least squares, Fourier series and best approximations all work.
The idea
Explore: least squares as a projection
Worked example
Find the polynomial
Gram–Schmidt on
with . . , with norm , so .Project
. , . So .Check orthogonality.
: and . The residual is orthogonal to , as Axler 6.61 requires.
Check your understanding
When does equality hold in Cauchy–Schwarz?
- When one vector is a scalar multiple of the other.
- When they are orthogonal.Then the left side is 0.
If
Only if .- 0Only if
.
In the least squares figure, the sum of the residuals is always 0 for the line model. Why?
- The residual vector is orthogonal to the all-ones column.
- By coincidence of the data.Drag points: it stays 0.
Practice
Pythagoras and the parallelogram lawAxler 6.12, 6.21
Show
Solution
Expand both squares; the cross terms cancel. For
Orthogonal complementsAxler 6.49, 6.51
Show
Solution
From Axler, Linear Algebra Done Right (4th ed., Springer, 2024; open access)
Numbers match the book. Each question is restated in our own words; the hints and solutions are written for this page.
Exercise 6B.1A converse to Pythagoras
Suppose
Hint
First take a single nonzero coefficient, then two.
Solution
Taking
Exercise 6B.14Exactly 2ᵐ Gram–Schmidt outputs
In a real inner product space, let
Hint
The condition determines
Solution
Let
Conversely, Gram–Schmidt gives one valid list
Exercise 6C.1The perp of a list is the perp of its span
For
Hint
One inclusion is immediate since each
Solution
Being orthogonal to the larger set
The spectral theorem and SVD
Self-adjoint operators are diagonal in an orthonormal basis: perpendicular axes, real stretch factors. Every linear map, self-adjoint or not, is diagonal between two orthonormal bases, which is the singular value decomposition, and it is why every invertible map sends circles to ellipses.
The idea
Geometrically (Axler 7.99):
Key terms in plain words
The ideas above without the symbols. Switch to Quiz me to test yourself: you see an explanation and pick the term it describes.
- Adjoint
- The operator that moves
from one side of an inner product to the other. In an orthonormal basis its matrix is the conjugate transpose. - Self-adjoint
- Describes an operator equal to its own partner on the other side of the inner product; for real matrices, symmetric. Its eigenvalues are real.
- Normal operator
- One that commutes with its adjoint. Over the complex numbers these are exactly the ones with an orthonormal basis of eigenvectors; rotations are examples that are not symmetric.
- Spectral theorem
- A guarantee that certain operators are completely described by perpendicular directions that they only stretch: over the reals, the symmetric ones; over the complex numbers, the ones that commute with their adjoint.
- Singular value decomposition
- Any linear map, even between different spaces, is a rotation, then a stretch along perpendicular axes, then another rotation.
- Singular values
- How much a linear map stretches along its principal directions: the lengths of the semi-axes of the ellipse (or ellipsoid) it makes from the unit circle (or ball).
Explore
Worked example
Find the singular values of the shear
Compute
. .Its eigenvalues?
Trace 3, determinant 1:
.Singular values, and a sanity check.
: the golden ratio and its reciprocal. Their product is , the area scale. The eigenvalues of are both 1, very different from the singular values: is not normal.
Check your understanding
For a self-adjoint operator, the singular values are
- the absolute values of its eigenvalues.
- its eigenvalues.Singular values are never negative.
Which matrices are normal?
- Rotations.
- The shear
. here.
The best rank-1 approximation of
.- the rank-1 piece with the smallest singular value.Keep the biggest, drop the rest.
Practice
Eigenvalues of self-adjoint operators are realAxler 7.12
Prove it, and prove eigenvectors for distinct eigenvalues are orthogonal.
Solution
Operator normAxler 7.85
Show
Solution
With
From Axler, Linear Algebra Done Right (4th ed., Springer, 2024; open access)
Numbers match the book. Each question is restated in our own words; the hints and solutions are written for this page.
Exercise 7A.4Invariant subspaces and the adjoint
For
Hint
Use
Solution
Suppose
Conversely, if
Exercise 7E.1Zero singular values
Show
Hint
The singular values are the square roots of the eigenvalues of
Solution
If
Exercise 7E.3Eigenvalues 0, 0 but singular values 5, 0
Give
Hint
A nilpotent map with a large entry.
Solution
Ridge regression: fitting without overfitting
A model is chosen to fit the data you have, but it is judged on data you haven't seen. Ridge regression is the simplest way to trade a little fit for a lot of stability. It has three equivalent readings: a penalty on large coefficients, a shrinkage of the directions the data barely determine, and a Gaussian prior on the coefficients. The third reading tells you which penalty to use when you know how the coefficients tend to vary.
The idea
What you see and what you are judged on. Data
For a fixed
Least squares, and solving by minimizing. Stack the inputs as the rows of a design matrix
Least squares breaks down when
A symmetric matrix
Show the computation
With
Bias and variance. Shrinking adds bias: even with no noise,
A general positive definite
Explore
Worked example
One feature, no intercept:
Write down the posterior density of
up to a constant.Prior times likelihood:
.Find the value of
that maximizes it.Minimize
. Setting the derivative to zero gives . The exponent is quadratic in , so the posterior is Gaussian and this is also the posterior mean.Compare with ridge regression. What is
?Ridge gives
, so . Noisier data or a tighter prior means more shrinkage.What happens as
and as ? (no prior information) gives least squares, . (certain that ) gives whatever the data say. Ridge interpolates between trusting the data and trusting the prior, weighted by how much each is worth: the total data precision against the prior precision .
Check your understanding
Drag the penalty to its smallest value. The training error is essentially zero, yet the test error is large. Why?
- With 12 features and 12 points, the polynomial can pass through every point, noise included. Fitting the noise exactly makes the curve swing wildly between the points.
- The optimizer failed to converge.The fit is computed exactly from the closed form. It is the best possible fit to the training data, and that is the problem.
- The true function is not a polynomial, so no polynomial can have small test error.Moderate λ gives test error close to the noise floor with the same 12 features. The issue is variance, not the model class.
In the SVD picture, which directions of the coefficient vector does ridge shrink the most?
- Those along right singular vectors
with small singular values . - Those with the largest least-squares coefficients.The shrinkage factor
depends only on , not on the size of the coefficient. - All directions equally, by the factor
.That happens only when every is the same, i.e. orthogonal features with .
Generalized ridge with penalty
- The first: its factor is
, against for the second. - The second, because it has the smaller entry in
.The penalty uses , so the first coordinate is penalized less. - They are shrunk equally.That would be ordinary ridge,
.
A model is fitted on a sample, and its error on the same sample is reported. On average, compared with its error on fresh data, this number is…
- …smaller, because the model was chosen to fit this sample's noise.
- …the same, because the empirical risk is an unbiased estimate of the risk.That holds for a parameter fixed before seeing the data, not for one chosen using the data.
- …larger, because the sample is finite.A finite sample makes the estimate noisy, but selection on the same sample makes it biased downward.
Practice
Solving by minimizingTwo inconsistent equations
The "equations"
Outline
- The minimizer of
is .Why?
The derivative
vanishes at . For and this is . - The gradient of
is .Why?
Expand
and differentiate in . - Setting it to zero gives
: the residual is orthogonal to every column of .Why?
Geometrically,
is the orthogonal projection of onto the column space of . The first part is the case where is a column of ones.
Ridge always has a unique answerPositive definiteness at work
Show that
Outline
for .Why?
The first term is
and the second is . A positive definite matrix has no zero eigenvalue, so it is invertible.- The objective is strictly convex, and its gradient
vanishes exactly at .Why?
Its Hessian is
, so the critical point is the unique global minimum. .Why?
The smallest eigenvalue of
is at least , so its inverse has operator norm at most .
The best linear predictorCompleting the square in matrices
Let
Outline
.Why?
, whose second-moment matrix is . Then average over the independent .- Since
, writing makes the cross terms cancel.Why?
The terms linear in
are , and , . What remains is . .Why?
Multiply both sides on the left by
and on the right by . Both sides become (the "push-through" identity).
The identity holds for any distribution with these first two moments. Gaussianity is only needed to say that no nonlinear estimator does better.
Effective degrees of freedomA trace formula
The fitted values of ridge are
Outline
.Why?
Substitute the thin SVD
: .- The trace of
is the trace of .Why?
and . - At
with , each of the factors is .Why?
is then the orthogonal projection onto the -dimensional column space, whose trace is its dimension.
Key terms in plain words
The ideas above without the symbols. Switch to Quiz me to test yourself: you see an explanation and pick the term it describes.
- Empirical risk
- The average loss of a model on the data you have; it is what training makes small.
- Population risk
- The average loss a model would have on fresh data from the same source; it is what you actually care about and can't compute.
- Generalization gap
- How much worse a fitted model does on new data than on the data it was fitted to.
- Overfitting
- Fitting the noise in a particular sample so closely that predictions on new data get worse.
- Ridge regression
- Least squares plus a penalty on the squared size of the coefficients, which keeps the answer unique and stable.
- Shrinkage
- Pulling estimated coefficients toward zero, most strongly in the directions the data say least about.
- Effective degrees of freedom
- How many directions a regularized fit really uses, a number between zero and the number of features.
- Generalized ridge
- Ridge with a different penalty weight in each direction, set by the inverse of how much the coefficients are expected to vary there.
- Positive definite matrix
- A symmetric matrix whose quadratic form is positive for every nonzero vector, so all its eigenvalues are positive and it can be inverted.
Generalized eigenvectors and Jordan form
When there aren't enough eigenvectors, generalized ones fill the gap: vectors killed by some power of
The idea
For a
Explore
Worked example
Find the generalized eigenspaces and a Jordan basis for
Eigenvalues?
The matrix is upper triangular with diagonal
, so the eigenvalues are 6 and 7 (Axler 5.41), with multiplicities 2 and 1. and ? has matrix with rows ; its square kills and , so , while only. is spanned by (solve ).Jordan basis?
Take
, , and . In the basis , has blocks and .
Check your understanding
A nilpotent operator on
. .A single Jordan block has .
For a Jordan block with
- Yes, though it can grow first.
- No, the
term blows up. when .
Over
- the sum of the eigenvalues, with multiplicity.
- the sum of the distinct eigenvalues.Multiplicity counts.
Practice
Cayley–Hamilton in 2×2Axler 8.29
Verify
Solution
Square rootsAxler 8.39–8.41
Find a square root of
Solution
Use
From Axler, Linear Algebra Done Right (4th ed., Springer, 2024; open access)
Numbers match the book. Each question is restated in our own words; the hints and solutions are written for this page.
Exercise 8A.3When null space and range are complementary
For
Hint
The sum is direct iff
Solution
(⇒) Let
(⇐) If
Exercise 8B.1Generalized eigenspaces of a rotation
For
Hint
Solution
Exercise 8C.1A nilpotent operator with no square root
Prove that
Hint
A square root of a nilpotent operator is nilpotent, and nilpotent operators on