How to study this
Picture first, numbers second, symbols last.
Linear algebra is rarely hard because of the arithmetic. It feels hard because textbooks start with the symbols, and symbols mean nothing until you have a picture to attach them to. These notes give you the picture first.
- Start in 2D. Anything true in $\R^3$ or $\R^n$ can first be drawn on paper in $\R^2$. Once it makes sense with two numbers, three or more is "the same thing, longer list".
- Say it in words. After any definition, explain it out loud as if to a friend who never took math. If you can't, you've memorised it rather than understood it.
- Predict before computing. "Will this dot product be positive or negative?" "Will this matrix have an inverse?" Guessing first builds intuition quickly.
- Check what kind of answer is wanted. A number? A vector? A matrix? Yes or no? Many lost marks come from giving the wrong type of answer.
- Practise by hand. Exams in courses like this usually allow only a basic calculator, so get comfortable doing row reduction, determinants and eigenvalues on paper.
- Check your work. Almost every computation in this course can be checked in under a minute. See Self-check habits at the end.
Sixteen lectures, grouped under the 11 course units, with two review lectures before the midterm and final. Each lecture has the ideas in plain English with pictures, worked examples with step-by-step solutions, common mistakes, a quick check and practice problems. Section numbers (§1.1, §1.2, …) are used for cross-references. The glossary, the big-picture summary, the self-check table and the MATLAB guide are in the appendices. Solutions to the practice problems are in the separate solutions booklet (PDF).
Vectors, length and the dot product
- Add, scale and form linear combinations, geometrically and by entries.
- Compute norms, unit vectors and distances.
- Compute dot products and use them to find angles and test orthogonality.
You walk 3 blocks east and then 4 blocks north. How far are you from where you started, in a straight line? What single "instruction" would have taken you there directly?
Show answer
Vectors
An arrow, or a list of numbers. It's the same thing.
The idea
A vector such as $\bm{u} = \begin{bmatrix} 3 \\ 1 \end{bmatrix}$ is a set of directions: "go 3 right and 1 up". It doesn't care where you start, only how far and which way. You can also read it as a list of data: 3 apples, 1 banana. Both readings are correct, and switching between them is half of this course.
- Adding vectors means doing one move, then the other. Put them tip to tail.
- Scaling (multiplying by a number) stretches or shrinks the arrow. A negative number flips it around.
- Length is Pythagoras: $\left\| \begin{bmatrix} 3 \\ 4 \end{bmatrix} \right\| = \sqrt{3^2 + 4^2} = 5$. More in Norm.
- $\R^n$ means "lists of $n$ numbers". $(2, 0, -1, 5)$ lives in $\R^4$. You can't draw it, but every rule works exactly the same: entry by entry.
Let $\bm{u} = \begin{bmatrix} 3 \\ 1 \end{bmatrix}$ and $\bm{v} = \begin{bmatrix} 1 \\ 2 \end{bmatrix}$. Then
$$\bm{u}+\bm{v} = \begin{bmatrix} 4 \\ 3 \end{bmatrix}, \qquad 2\bm{u} = \begin{bmatrix} 6 \\ 2 \end{bmatrix}, \qquad \bm{u}-\bm{v} = \begin{bmatrix} 2 \\ -1 \end{bmatrix}, \qquad \|\bm{u}\| = \sqrt{3^2+1^2} = \sqrt{10}.$$Draw every one of these on graph paper. Which direction does $\bm{u}-\bm{v}$ point, and why? (It's the arrow from the tip of $\bm{v}$ to the tip of $\bm{u}$.)
Linear combinations
A recipe: some of this vector, plus some of that one.
The idea
A linear combination of $\bm{v}_1$ and $\bm{v}_2$ is any vector of the form
$$c_1\bm{v}_1 + c_2\bm{v}_2,$$where the weights $c_1, c_2$ are ordinary numbers. You scale each ingredient, then add.
Practical hook: a smoothie. A banana gives 100 calories and 1 g of protein; a scoop of yogurt gives 60 calories and 5 g. Two bananas and three scoops give
$$2\begin{bmatrix} 100 \\ 1 \end{bmatrix} + 3\begin{bmatrix} 60 \\ 5 \end{bmatrix} = \begin{bmatrix} 380 \\ 17 \end{bmatrix} \quad \begin{matrix} \text{calories} \\ \text{grams of protein} \end{matrix}$$The interesting question runs backwards: "I want exactly this nutrition. How much of each ingredient do I need?" That's asking for the weights, and it's where systems of equations come from.
Can $\begin{bmatrix} 7 \\ 4 \end{bmatrix}$ be written as a linear combination of $\begin{bmatrix} 1 \\ 1 \end{bmatrix}$ and $\begin{bmatrix} 2 \\ 1 \end{bmatrix}$? We need weights $a, b$ with
$$a\begin{bmatrix} 1 \\ 1 \end{bmatrix} + b\begin{bmatrix} 2 \\ 1 \end{bmatrix} = \begin{bmatrix} 7 \\ 4 \end{bmatrix} \quad\Longleftrightarrow\quad \begin{aligned} a + 2b &= 7 \\ a + b &= 4 \end{aligned}$$Subtracting the equations gives $b = 3$, and then $a = 1$. Check: $1\begin{bmatrix} 1 \\ 1 \end{bmatrix} + 3\begin{bmatrix} 2 \\ 1 \end{bmatrix} = \begin{bmatrix} 7 \\ 4 \end{bmatrix}$ $\checkmark$
The big connection: finding weights is solving a system, and the vectors become the columns of the augmented matrix
$$\left[\begin{array}{cc|c} 1 & 2 & 7 \\ 1 & 1 & 4 \end{array}\right].$$Keep this in mind; it comes back in Units 2 and 3.
The norm (length)
Pythagoras, extended to as many entries as you like.
The idea
$$\|\bm{v}\| = \sqrt{v_1^2 + v_2^2 + \cdots + v_n^2}$$- In 2D it's the hypotenuse. In 3D it's the diagonal of a box. In $\R^n$ it's the same formula with more terms.
- Distance between two points $P$ and $Q$ is $\|\bm{p} - \bm{q}\|$. Subtract, then take the length.
- Unit vector in the direction of $\bm{v}$: $\dfrac{\bm{v}}{\|\bm{v}\|}$. It keeps the direction and sets the length to 1. Think "just the compass heading, no distance".
- Practical hook: comparing two customers' shopping lists, or two songs' features, by the distance between their vectors. Small distance means similar. Recommendation apps do exactly this in $\R^{1000}$.
Rules worth knowing
| Rule | In words |
|---|---|
| $\|\bm{v}\| \ge 0$, with equality only for $\bm{v} = \bm{0}$ | Lengths are never negative. |
| $\|c\bm{v}\| = |c|\,\|\bm{v}\|$ | Tripling an arrow triples its length. Flipping it doesn't change the length. |
| $\|\bm{u}+\bm{v}\| \le \|\bm{u}\| + \|\bm{v}\|$ | Triangle inequality: the direct route is never longer than the detour. |
| $|\bm{u}\cdot\bm{v}| \le \|\bm{u}\|\,\|\bm{v}\|$ | Cauchy–Schwarz: why $\cos\theta$ always lands between $-1$ and $1$. |
| $\|\bm{v}\|^2 = \bm{v}\cdot\bm{v}$ | Length squared is a dot product with itself. |
For $\bm{v} = (1, 2, 2)$:
$$\|\bm{v}\| = \sqrt{1 + 4 + 4} = 3, \qquad \frac{\bm{v}}{\|\bm{v}\|} = \left(\tfrac13, \tfrac23, \tfrac23\right), \qquad \left\|\left(\tfrac13, \tfrac23, \tfrac23\right)\right\| = \sqrt{\tfrac19 + \tfrac49 + \tfrac49} = 1 \;\checkmark$$Distance from $P(1, 2, 3)$ to $Q(4, 6, 3)$:
$$\|\bm{q} - \bm{p}\| = \|(3, 4, 0)\| = \sqrt{9 + 16 + 0} = 5.$$In $\R^4$: $\|(1, 1, 1, 1)\| = \sqrt{4} = 2$.
The dot product
One number that says how much two arrows agree.
The idea
Multiply matching entries and add them up:
$$\bm{u}\cdot\bm{v} = u_1v_1 + u_2v_2 + \cdots + u_nv_n.$$The answer is a plain number, not a vector.
Practical hook: you already use dot products at the till. Buy 2 coffees and 3 muffins at \$4 and \$3 each, and your bill is
$$\begin{bmatrix} 2 \\ 3 \end{bmatrix} \cdot \begin{bmatrix} 4 \\ 3 \end{bmatrix} = 2(4) + 3(3) = 17 \text{ dollars}.$$Geometric meaning:
$$\bm{u}\cdot\bm{v} = \|\bm{u}\|\,\|\bm{v}\|\cos\theta,$$where $\theta$ is the angle between them. So the sign tells you the direction relationship at a glance:
Physics example you may know: work $=$ force $\cdot$ displacement. Only the part of your push that goes along the direction of motion counts. That "part along a direction" idea becomes projections.
It works the same in $\R^n$: $(1, 0, 2, 3)\cdot(2, 5, 1, -1) = 2 + 0 + 2 - 3 = 1$.
Are $(1, 2)$ and $(4, -2)$ perpendicular?
$$(1, 2)\cdot(4, -2) = 4 - 4 = 0, \quad\text{so yes.}$$Find the angle between $\bm{u} = (1, 1)$ and $\bm{v} = (1, 0)$:
$$\cos\theta = \frac{\bm{u}\cdot\bm{v}}{\|\bm{u}\|\,\|\bm{v}\|} = \frac{1}{\sqrt{2}\cdot 1} = \frac{1}{\sqrt2} \quad\Longrightarrow\quad \theta = 45^\circ. \;\checkmark$$Worked examples
- CoreLet $\bm{u} = (1, -2, 3)$ and $\bm{v} = (4, 0, -1)$. Compute $2\bm{u} - 3\bm{v}$ and $\|\bm{u}\|$.Solution
- Scale each vector entry by entry: $2\bm{u} = (2,-4,6)$ and $3\bm{v} = (12,0,-3)$.
- Subtract entry by entry: $2\bm{u} - 3\bm{v} = (2-12,\ -4-0,\ 6-(-3)) = (-10,-4,9)$.
- For the length, square the entries, add, and take the square root: $\|\bm{u}\| = \sqrt{1^2 + (-2)^2 + 3^2} = \sqrt{14}$.
- CoreWrite $(4,1)$ as a linear combination of $(1,2)$ and $(3,-1)$.Solution
- We want weights with $a(1,2) + b(3,-1) = (4,1)$. Matching entries gives $a + 3b = 4$ and $2a - b = 1$.
- From the second equation, $b = 2a - 1$. Substitute into the first: $a + 3(2a - 1) = 4 \Rightarrow 7a = 7 \Rightarrow a = 1$.
- Then $b = 2(1) - 1 = 1$.
- Check: $1(1,2) + 1(3,-1) = (4,1)\;\checkmark$.
- CoreFind the angle between $\bm{u} = (1, 2, -1)$ and $\bm{v} = (2, 1, 1)$.Solution
- Dot product: $\bm{u}\cdot\bm{v} = 1(2) + 2(1) + (-1)(1) = 3$.
- Lengths: $\|\bm{u}\| = \sqrt{1+4+1} = \sqrt6$ and $\|\bm{v}\| = \sqrt{4+1+1} = \sqrt6$.
- Angle formula: $\cos\theta = \dfrac{\bm{u}\cdot\bm{v}}{\|\bm{u}\|\|\bm{v}\|} = \dfrac{3}{6} = \dfrac12$.
- So $\theta = 60^\circ$.
- CoreFind $k$ so that $(k, 1, 2)$ and $(3, k, -1)$ are orthogonal.Solution
- Orthogonal means the dot product is zero.
- $(k,1,2)\cdot(3,k,-1) = 3k + k - 2 = 4k - 2$.
- Set $4k - 2 = 0$, so $k = \tfrac12$. Check: $(\tfrac12,1,2)\cdot(3,\tfrac12,-1) = \tfrac32 + \tfrac12 - 2 = 0\;\checkmark$.
- StretchIs $(1,1,1)$ a linear combination of $(1,2,0)$ and $(0,1,1)$? Explain in a picture.Solution
- Write a general combination: $a(1,2,0) + b(0,1,1) = (a,\ 2a + b,\ b)$.
- Match with $(1,1,1)$: the first entry gives $a = 1$ and the third gives $b = 1$.
- The middle entry would then be $2a + b = 3$, but we need 1. The equations are inconsistent.
- No. Geometrically, all combinations of two non-parallel vectors fill a plane through the origin, and $(1,1,1)$ is not on that plane.
- ApplicationA drone flies 3 km east, 4 km north and climbs 12 km. Find its displacement vector, how far it is from the start, and the unit vector giving its direction.Solution
- Displacement (east, north, up): $\bm{d} = (3,4,12)$.
- Distance: $\|\bm{d}\| = \sqrt{9 + 16 + 144} = \sqrt{169} = 13$ km.
- Direction: $\dfrac{\bm{d}}{\|\bm{d}\|} = (\tfrac{3}{13}, \tfrac{4}{13}, \tfrac{12}{13})$. Check: $\tfrac{9 + 16 + 144}{169} = 1\;\checkmark$.
- Trying to add vectors of different sizes, like $(1, 2) + (1, 2, 3)$. You can't; they live in different spaces.
- Mixing up a point (a location) with a vector (a movement). The notation is the same, so context decides.
- Writing $\|\bm{u}+\bm{v}\| = \|\bm{u}\| + \|\bm{v}\|$. False, unless they point the same way. Walking 3 km north then 4 km east doesn't put you 7 km from home.
- Thinking weights must be positive or whole numbers. Negative and fractional weights are fine.
- Putting the vectors in as rows when setting up the system. They go in as columns.
- Assuming every target can be reached. $(1, 2)$ and $(2, 4)$ point the same way, so no combination of them makes $(1, 0)$.
- $\|-3\bm{v}\| = 3\|\bm{v}\|$, not $-3\|\bm{v}\|$. The absolute value matters.
- Squaring negatives: $(-2)^2 = 4$. A calculator given −2² returns $-4$.
- Forgetting the square root at the end.
- $\|\bm{u}+\bm{v}\| \ne \|\bm{u}\| + \|\bm{v}\|$ in general.
- Writing the answer as a vector. A dot product is always a single number.
- Trying to dot vectors of different sizes. Both must have the same number of entries.
- Calculator in radians when the question wants degrees (or the reverse).
Is the triangle with vertices $A(1,0,0)$, $B(0,1,0)$, $C(0,0,1)$ right-angled?
Show answer
Test yourself
- If $\bm{u}$ is walking directions, what does $-\bm{u}$ mean?
- What's a vector with length 0? Does it have a direction?
- Give a real-life thing that's naturally a list of 4 numbers.
- Write $(5, -2)$ as a combination of $\bm{e}_1 = (1, 0)$ and $\bm{e}_2 = (0, 1)$. (It's $5\bm{e}_1 - 2\bm{e}_2$. That's what coordinates are.)
- Is the zero vector a combination of any vectors? (Always: use all weights 0.)
- Without computing, is $(3, 1)\cdot(-2, 5)$ positive or negative? Sketch it first.
- What's $\bm{u}\cdot\bm{u}$? (It's $\|\bm{u}\|^2$. Good "aha".)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- With $\bm{u} = (2, -1)$ and $\bm{v} = (-1, 3)$, find $3\bm{u}-\bm{v}$.
- Compute $(1, 0, 2, -1) + 2(0, 3, 1, 1)$ in $\R^4$.
- Is $(1, 2, 3)$ a linear combination of $(1, 0, 1)$ and $(0, 1, 1)$?
- Is $(1, 2, 4)$ a linear combination of $(1, 0, 1)$ and $(0, 1, 1)$?
- Find the unit vector in the direction of $(3, -4)$.
- Compute $\|(2, -1, 0, 2)\|$.
- Find a vector of length 10 pointing the same way as $(1, 2, 2)$.
- Find $k$ so that $(2, k)$ is perpendicular to $(3, -6)$.
- Find the angle between $(1, 2, 2)$ and $(2, 0, 0)$.
- Let $\bm{u} = (2,-1,4)$ and $\bm{v} = (1,3,-2)$. Find $\bm{u} + 2\bm{v}$ and $\|\bm{u} - \bm{v}\|$.
- Find the unit vector pointing in the opposite direction to $(6,-2,3)$.
- Write $(1,7)$ as a linear combination of $(1,2)$ and $(-1,1)$.
- Find the angle between $(1,0,1)$ and $(0,1,1)$.
- Find every vector $(x, y)$ of length 5 that is orthogonal to $(3,4)$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 1 The geometry of linear equations. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §1.1–1.2.
- RD Sharma (Class 12): exercises in the chapters on Algebra of Vectors; Scalar (Dot) Product.
Projections, cross product, lines and planes
- Compute vector and scalar projections and split a vector into parallel and perpendicular parts.
- Compute cross products and use them for normals and areas.
- Write lines and planes in vector, parametric and (for planes) normal form.
- Find intersections and point-to-plane distances.
A plane passes through the origin and is perpendicular to $(1,2,3)$. Is $(3,0,-1)$ on it? Is $(1,1,1)$?
Show answer
Vector projections
The shadow one arrow casts on another.
The idea
Shine a light straight down onto the line of $\bm{v}$. The shadow $\bm{u}$ casts on it is the projection of $\bm{u}$ onto $\bm{v}$. It answers: "how much of $\bm{u}$ points in $\bm{v}$'s direction?"
Every vector splits into two pieces: the part along $\bm{v}$ (the projection) and the part perpendicular to $\bm{v}$ (what's left over).
Practical hook: a box on a ramp. Gravity pulls straight down, but you split it into the part along the ramp (makes the box slide) and the part into the ramp (presses it against the surface). That split is exactly a projection.
Formulas
$$\begin{aligned} \operatorname{proj}_{\bm{v}}\bm{u} &= \frac{\bm{u}\cdot\bm{v}}{\bm{v}\cdot\bm{v}}\,\bm{v} &&\text{(vector projection: a vector)} \\[4pt] \operatorname{comp}_{\bm{v}}\bm{u} &= \frac{\bm{u}\cdot\bm{v}}{\|\bm{v}\|} &&\text{(scalar projection: the signed shadow length)} \end{aligned}$$The perpendicular part is $\bm{u} - \operatorname{proj}_{\bm{v}}\bm{u}$. Reading the vector formula: $\dfrac{\bm{u}\cdot\bm{v}}{\bm{v}\cdot\bm{v}}$ is just a number, "how many $\bm{v}$'s long the shadow is". Then you multiply $\bm{v}$ by it.
Let $\bm{u} = (3, 4)$ and $\bm{v} = (2, 1)$. Then $\bm{u}\cdot\bm{v} = 10$ and $\bm{v}\cdot\bm{v} = 5$, so
$$\operatorname{proj}_{\bm{v}}\bm{u} = \frac{10}{5}\begin{bmatrix} 2 \\ 1 \end{bmatrix} = \begin{bmatrix} 4 \\ 2 \end{bmatrix}, \qquad \bm{u} - \operatorname{proj}_{\bm{v}}\bm{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} - \begin{bmatrix} 4 \\ 2 \end{bmatrix} = \begin{bmatrix} -1 \\ 2 \end{bmatrix}.$$Two checks: $(-1, 2)\cdot(2, 1) = -2 + 2 = 0$, so the leftover really is perpendicular $\checkmark$; and $(4, 2) + (-1, 2) = (3, 4)$, so the pieces add back to $\bm{u}$ $\checkmark$. Both take seconds. Do them every time.
The cross product
Give it two arrows in 3D, get back an arrow perpendicular to both.
The idea
- $\bm{u}\times\bm{v}$ is a vector that sticks straight out of the flat surface containing $\bm{u}$ and $\bm{v}$.
- Its length equals the area of the parallelogram $\bm{u}$ and $\bm{v}$ make: $\|\bm{u}\times\bm{v}\| = \|\bm{u}\|\,\|\bm{v}\|\sin\theta$.
- Its direction follows the right-hand rule: fingers along $\bm{u}$, curl toward $\bm{v}$, thumb points to $\bm{u}\times\bm{v}$.
- Real-world: torque. Push a wrench handle, and the bolt turns along the axis perpendicular to both the handle and your push.
The formula is easiest to remember as a determinant (Unit 7), expanded along the top row:
$$\bm{u}\times\bm{v} = \begin{vmatrix} \bm{i} & \bm{j} & \bm{k} \\ u_1 & u_2 & u_3 \\ v_1 & v_2 & v_3 \end{vmatrix} = \begin{bmatrix} u_2v_3 - u_3v_2 \\ -(u_1v_3 - u_3v_1) \\ u_1v_2 - u_2v_1 \end{bmatrix}.$$The minus sign on the middle entry is the part people get wrong.
Check by dotting with both original vectors:
$$(-3, 6, -3)\cdot(1, 2, 3) = -3 + 12 - 9 = 0 \;\checkmark, \qquad (-3, 6, -3)\cdot(4, 5, 6) = -12 + 30 - 18 = 0 \;\checkmark$$This check catches nearly every cross product mistake. Make it a habit.
Lines and planes in ℝⁿ
A line is "start here, walk one way". A plane is "start here, walk two ways".
Lines
Think GPS: a starting point $\bm{p}$, a direction $\bm{d}$, and a time $t$. Where are you at time $t$?
$$\bm{x} = \bm{p} + t\,\bm{d}, \qquad \text{e.g.}\quad \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \\ 2 \end{bmatrix} + t\begin{bmatrix} 2 \\ 1 \\ 3 \end{bmatrix}.$$At $t = 0$ you're at $(1, 0, 2)$; at $t = 1$, at $(3, 1, 5)$; at $t = -1$, at $(-1, -1, -1)$. This formula doesn't care about dimension: a line in $\R^4$ is just $(1, 0, 2, -1) + t(1, 1, 0, 3)$.
Planes, version 1: parametric form (any $\R^n$)
A plane needs a starting point and two directions that don't point the same way. Two parameters, because a plane has two degrees of freedom:
$$\bm{x} = \bm{p} + s\,\bm{u} + t\,\bm{v}.$$Every point on the plane is "start at $\bm{p}$, go $s$ steps along $\bm{u}$ and $t$ steps along $\bm{v}$": $\bm{p}$ plus a linear combination of $\bm{u}$ and $\bm{v}$.
Planes, version 2: one equation ($\R^3$ only)
In 3D a plane can also be pinned down by one point on it and one normal vector $\bm{n} = (a, b, c)$ that sticks straight out of it, like a pencil standing upright on a table. Every arrow lying in the table is perpendicular to the pencil, so
$$\bm{n}\cdot(\bm{x} - \bm{p}) = 0 \quad\Longleftrightarrow\quad ax + by + cz = d.$$The coefficients $(a, b, c)$ are the normal vector. Read it straight off.
Plane through $(1, 2, 3)$ with normal $(2, -1, 1)$:
$$2(x-1) - (y-2) + (z-3) = 0 \quad\Longrightarrow\quad 2x - y + z = 3.$$Check the point: $2(1) - 2 + 3 = 3$ $\checkmark$. For a plane through three points, make two arrows between them, cross them to get the normal, then do the above.
Each equation removes one degree of freedom. In $\R^2$, $ax + by = d$ is a line. In $\R^3$, $ax + by + cz = d$ is a plane. In $\R^4$, $a_1x_1 + a_2x_2 + a_3x_3 + a_4x_4 = d$ is a 3-dimensional "hyperplane". So a plane in $\R^4$ needs two equations, which is why the parametric form is the one to use beyond 3D.
Plane through $(1, 0, 0)$ with directions $\bm{u} = (1, 1, 0)$ and $\bm{v} = (0, 1, 1)$. The normal is
$$\bm{n} = \bm{u}\times\bm{v} = \begin{bmatrix} 1\cdot1 - 0\cdot1 \\ -(1\cdot1 - 0\cdot0) \\ 1\cdot1 - 1\cdot0 \end{bmatrix} = \begin{bmatrix} 1 \\ -1 \\ 1 \end{bmatrix}, \qquad\text{so}\qquad x - y + z = 1.$$Check: the point $(1,0,0)$ gives $1 = 1$ $\checkmark$, and $\bm{p} + \bm{u} = (2, 1, 0)$ gives $2 - 1 + 0 = 1$ $\checkmark$.
Line $(1, 0, 2) + t(2, 1, 3)$ and plane $2x - y + z = 3$. Substitute $x = 1 + 2t$, $y = t$, $z = 2 + 3t$:
$$2(1+2t) - t + (2+3t) = 3 \quad\Longrightarrow\quad 4 + 6t = 3 \quad\Longrightarrow\quad t = -\tfrac16.$$The point is $\left(\tfrac23, -\tfrac16, \tfrac32\right)$. Check: $\tfrac43 + \tfrac16 + \tfrac32 = \tfrac{8 + 1 + 9}{6} = 3$ $\checkmark$.
If $t$ cancels out and you get something false like $4 = 3$, the line is parallel to the plane and never hits it. If you get something always true, the line lies inside the plane.
Distance from a point to a plane
This is a projection onto the normal in disguise:
$$\text{distance from } (x_0, y_0, z_0) \text{ to } ax + by + cz = d \;=\; \frac{|ax_0 + by_0 + cz_0 - d|}{\sqrt{a^2 + b^2 + c^2}}.$$For example, from the origin to $2x - y + z = 3$: $\dfrac{|0 - 3|}{\sqrt6} = \dfrac{3}{\sqrt6} \approx 1.22$.
Worked examples
- CoreProject $\bm{u} = (2,1,3)$ onto $\bm{v} = (1,1,0)$ and find the part of $\bm{u}$ perpendicular to $\bm{v}$.Solution
- Compute the two dot products: $\bm{u}\cdot\bm{v} = 2 + 1 + 0 = 3$ and $\bm{v}\cdot\bm{v} = 1 + 1 + 0 = 2$.
- Projection: $\operatorname{proj}_{\bm{v}}\bm{u} = \tfrac{3}{2}(1,1,0) = (\tfrac32, \tfrac32, 0)$.
- Perpendicular part: $\bm{u} - \operatorname{proj}_{\bm{v}}\bm{u} = (2 - \tfrac32,\ 1 - \tfrac32,\ 3 - 0) = (\tfrac12, -\tfrac12, 3)$.
- Check: $(\tfrac12, -\tfrac12, 3)\cdot(1,1,0) = 0\;\checkmark$.
- CoreFind the area of the triangle with vertices $P(1,0,0)$, $Q(0,2,0)$, $R(0,0,3)$.Solution
- Edge vectors from $P$: $\overrightarrow{PQ} = Q - P = (-1,2,0)$ and $\overrightarrow{PR} = (-1,0,3)$.
- Cross product: $\overrightarrow{PQ}\times\overrightarrow{PR} = \big(2\cdot3 - 0\cdot0,\ -[(-1)(3) - 0\cdot(-1)],\ (-1)(0) - 2(-1)\big) = (6,3,2)$.
- Its length is the parallelogram's area: $\sqrt{36 + 9 + 4} = 7$.
- The triangle is half the parallelogram: area $\tfrac72$.
- CoreWhere does the line $(1,1,1) + t(1,-1,2)$ meet the plane $x + 2y + z = 10$?Solution
- Points on the line: $x = 1 + t,\ y = 1 - t,\ z = 1 + 2t$.
- Substitute into the plane: $(1+t) + 2(1-t) + (1+2t) = 10$.
- Simplify: $4 + t = 10$, so $t = 6$.
- The point is $(1+6,\ 1-6,\ 1+12) = (7,-5,13)$. Check: $7 - 10 + 13 = 10\;\checkmark$.
- StretchFind the distance from $(1,1,1)$ to the plane $6x + 3y + 2z = 6$.Solution
- Use $\text{distance} = \dfrac{|ax_0 + by_0 + cz_0 - d|}{\sqrt{a^2+b^2+c^2}}$ with $(a,b,c) = (6,3,2)$, $d = 6$ and the point $(1,1,1)$.
- Numerator: $|6 + 3 + 2 - 6| = 5$. Denominator: $\sqrt{36 + 9 + 4} = 7$.
- Distance $\tfrac57$.
- ExtraFind the distance from $P(1,2,3)$ to the line $\bm{x} = (0,0,1) + t(1,1,0)$.Solution
- Vector from a point on the line to $P$: $\bm{u} = (1,2,3) - (0,0,1) = (1,2,2)$.
- Project onto the direction $\bm{d} = (1,1,0)$: $\tfrac{\bm{u}\cdot\bm{d}}{\bm{d}\cdot\bm{d}}\bm{d} = \tfrac32(1,1,0) = (\tfrac32, \tfrac32, 0)$.
- Perpendicular part: $(1,2,2) - (\tfrac32, \tfrac32, 0) = (-\tfrac12, \tfrac12, 2)$. Check: its dot product with $(1,1,0)$ is 0 $\checkmark$.
- Distance: $\sqrt{\tfrac14 + \tfrac14 + 4} = \sqrt{\tfrac92} = \tfrac{3}{\sqrt2} \approx 2.12$.
- Projecting the wrong way round. $\operatorname{proj}_{\bm{v}}\bm{u}$ ($\bm{u}$'s shadow on $\bm{v}$) is not $\operatorname{proj}_{\bm{u}}\bm{v}$. The vector you project onto goes in the denominator and outside.
- Dividing by $\|\bm{v}\|$ instead of $\bm{v}\cdot\bm{v} = \|\bm{v}\|^2$ in the vector formula.
- Giving a vector when the question asks for the scalar projection (or "component"), or the reverse.
- Order matters: $\bm{v}\times\bm{u} = -(\bm{u}\times\bm{v})$. Swapping flips the arrow.
- A sign error in the middle component.
- Trying to take a cross product in 2D. It only exists for vectors in $\R^3$.
- Using the plane's normal as if it's a direction in the plane. It's the opposite: it points out of the plane.
- Thinking a line has one equation in 3D. $ax + by + cz = d$ is a plane, not a line.
- Using the same letter for both parameters in a parametric plane, or when intersecting two lines. Use $s$ for one and $t$ for the other.
- Picking two directions that are multiples of each other. That gives a line, not a plane.
Are the planes $x + 2y - z = 3$ and $-2x - 4y + 2z = 1$ parallel?
Show answer
Test yourself
- What's the projection of $\bm{u}$ onto $\bm{v}$ if they're perpendicular? (The zero vector: no shadow.)
- What if $\bm{u}$ is already along $\bm{v}$? ($\bm{u}$ itself.)
- Does projecting onto $2\bm{v}$ instead of $\bm{v}$ change the answer? (No. Only the line's direction matters.)
- What is $\bm{u}\times\bm{u}$? Why? (The zero vector: no parallelogram, no area.)
- If $\bm{u}\times\bm{v} = \bm{0}$, what does that tell you about $\bm{u}$ and $\bm{v}$? (They're parallel.)
- What's the normal of the plane $z = 0$ (the floor)? ($(0, 0, 1)$.)
- When are two planes parallel? (When their normals are multiples of each other.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Project $(1, 2, 3)$ onto $(1, 1, 1)$, and find the perpendicular part.
- Find the distance from the point $(3, 4)$ to the line through the origin with direction $(2, 1)$.
- Find the area of the triangle with vertices $(0,0,0)$, $(1,0,0)$ and $(0,2,0)$.
- Find the line through $(1, 0, 2)$ and $(3, 1, 5)$.
- Find the plane through the origin perpendicular to $(1, -2, 4)$.
- Is the point $(3, 2, 2, 5)$ on the line $(1, 0, 2, -1) + t(1, 1, 0, 3)$ in $\R^4$?
- Find the scalar and vector projections of $\bm{u} = (1,2,3)$ onto $\bm{v} = (2,-1,2)$.
- Compute $(1,-1,2)\times(3,0,1)$ and check your answer.
- Find the equation of the plane through $(1,2,0)$, $(0,1,1)$ and $(2,0,1)$.
- Find parametric equations for the line where the planes $x + y + z = 6$ and $x - y = 0$ meet.
- Find the distance from $(2,-1,3)$ to the plane $2x - y + 2z = 1$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 15 Projections onto subspaces (first half: projecting onto a line). ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §4.2.
- RD Sharma (Class 12): exercises in the chapters on Vector (Cross) Product; Straight Line in Space; The Plane.
Systems, row reduction and RREF
- Translate between a system and its augmented matrix.
- Use elementary row operations to reach row echelon form and back-substitute.
- Reduce a matrix to RREF and identify pivot and free variables.
- Write solution sets in parametric vector form.
Adult tickets cost \$12, child tickets \$8. A group buys 10 tickets for \$100. How many of each?
Show answer
Systems of linear equations
Several conditions that all have to be true at once.
The idea
Each equation in two unknowns is a line. Solving the system means finding where all the lines meet. In three unknowns each equation is a plane. There are only three possibilities, and it's worth being able to draw all three:
"Linear" means each variable appears only multiplied by a number and added: no $x^2$, no $xy$, no $\sin x$, no $1/x$. That's what keeps the pictures flat (lines and planes, never curves).
A cinema sells adult tickets for \$12 and child tickets for \$8. A group buys 10 tickets for \$100. How many of each? Let $a$ be the number of adults and $c$ the number of children:
$$\begin{aligned} a + c &= 10 &&\text{(tickets)} \\ 12a + 8c &= 100 &&\text{(dollars)} \end{aligned}$$From the first equation $c = 10 - a$, so $12a + 8(10 - a) = 100$, which gives $4a = 20$. Hence $a = 5$ and $c = 5$. Check: $5 + 5 = 10$ and $60 + 40 = 100$ $\checkmark$.
Substitution works for two variables. For three or more it gets messy fast, which is why the course switches to augmented matrices.
Augmented matrices, REF and RREF
High-school elimination, with tidy bookkeeping.
The augmented matrix
The variable names never change during elimination, so stop writing them. Keep only the numbers, one row per equation and one column per variable, with a bar where the $=$ signs were:
$$\begin{aligned} x + 2y - z &= 3 \\ 2x + 4y + z &= 9 \end{aligned} \qquad\longrightarrow\qquad \left[\begin{array}{ccc|c} 1 & 2 & -1 & 3 \\ 2 & 4 & 1 & 9 \end{array}\right]$$A missing variable gets a 0 in its column. Don't skip it.
The three elementary row operations
Only ever do these, because none of them change the solution:
- Interchange two rows, $R_i \leftrightarrow R_j$. (Listing the equations in a different order.)
- Scale a row by a non-zero number, $R_i \to kR_i$. (Multiplying both sides of an equation.)
- Replace a row by itself plus a multiple of another, $R_i \to R_i + kR_j$. (Classic elimination.)
REF and RREF
| REF (row echelon form) | RREF (reduced row echelon form) | |
|---|---|---|
| Looks like | A staircase: zeros below every pivot | A staircase where each pivot is 1, with zeros above and below it |
| Rules | Each pivot is to the right of the one above it; zero rows at the bottom | All REF rules, plus pivots equal 1 and each pivot is alone in its column |
| Then you… | Back-substitute from the bottom up | Read the answer straight off |
| Unique? | No, different people get different REFs | Yes, everyone gets the same RREF |
The same system at both stages:
$$\underbrace{\left[\begin{array}{ccc|c} 1 & 1 & 1 & 9 \\ 0 & 2 & 1 & 7 \\ 0 & 0 & 3 & 9 \end{array}\right]}_{\text{REF}} \qquad\qquad \underbrace{\left[\begin{array}{ccc|c} 1 & 0 & 0 & 4 \\ 0 & 1 & 0 & 2 \\ 0 & 0 & 1 & 3 \end{array}\right]}_{\text{RREF}} \qquad \Longrightarrow\quad x = 4,\ y = 2,\ z = 3.$$Strategy: work left to right, creating zeros below each pivot (this gives REF). Then work right to left, scaling pivots to 1 and creating zeros above them (this gives RREF).
Solve
$$\begin{aligned} x + y + z &= 6 \\ 2x + y - z &= 1 \\ x - y + z &= 2 \end{aligned}$$ $$\left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 2 & 1 & -1 & 1 \\ 1 & -1 & 1 & 2 \end{array}\right] \xrightarrow[\;R_3 - R_1\;]{\;R_2 - 2R_1\;} \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & -1 & -3 & -11 \\ 0 & -2 & 0 & -4 \end{array}\right]$$Back-substitute from the bottom: row 3 says $-2y = -4$, so $y = 2$. Row 2 says $-2 - 3z = -11$, so $z = 3$. Row 1 says $x + 2 + 3 = 6$, so $x = 1$.
Check in the second original equation: $2(1) + 2 - 3 = 1$ $\checkmark$.
The pivots are in the $x$ and $z$ columns. The $y$ column has no pivot, so $y$ is free: set $y = t$. Then $z = 1$ and $x = 4 - 2t$, so
$$\begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 4 \\ 0 \\ 1 \end{bmatrix} + t\begin{bmatrix} -2 \\ 1 \\ 0 \end{bmatrix}, \qquad t \in \R.$$Check $t = 0$: $4 + 0 - 1 = 3$ and $8 + 0 + 1 = 9$ $\checkmark$.
Look at the answer's shape: a point plus $t$ times a direction. The solution set is a line (section 1.7). Many topics in this course turn out to be the same idea seen from different angles.
Reading the final matrix
Worked examples
- CoreSolve $x - y + 2z = 5,\ 2x + y - z = 1,\ 3x + 2y + z = 10$.Solution
- Write the augmented matrix and row reduce:$$\begin{aligned} &\left[\begin{array}{ccc|c} 1 & -1 & 2 & 5 \\ 2 & 1 & -1 & 1 \\ 3 & 2 & 1 & 10 \end{array}\right] \xrightarrow{\substack{R_2 - 2R_1 \\ R_3 - 3R_1}} \left[\begin{array}{ccc|c} 1 & -1 & 2 & 5 \\ 0 & 3 & -5 & -9 \\ 0 & 5 & -5 & -5 \end{array}\right] \xrightarrow{\tfrac15 R_3} \left[\begin{array}{ccc|c} 1 & -1 & 2 & 5 \\ 0 & 3 & -5 & -9 \\ 0 & 1 & -1 & -1 \end{array}\right] \\[6pt] \xrightarrow{R_2 \leftrightarrow R_3} &\left[\begin{array}{ccc|c} 1 & -1 & 2 & 5 \\ 0 & 1 & -1 & -1 \\ 0 & 3 & -5 & -9 \end{array}\right] \xrightarrow{R_3 - 3R_2} \left[\begin{array}{ccc|c} 1 & -1 & 2 & 5 \\ 0 & 1 & -1 & -1 \\ 0 & 0 & -2 & -6 \end{array}\right] \end{aligned}$$
- Back-substitute from the bottom: $-2z = -6 \Rightarrow z = 3$; $y - z = -1 \Rightarrow y = 2$; $x - y + 2z = 5 \Rightarrow x = 5 + 2 - 6 = 1$.
- Check in the third equation: $3(1) + 2(2) + 3 = 10\;\checkmark$.
- CoreReduce $\left[\begin{array}{ccc|c} 1 & 2 & 3 & 4 \\ 2 & 4 & 7 & 9 \end{array}\right]$ to RREF and write the solution in parametric vector form.Solution
- Row reduce:$$\begin{aligned} &\left[\begin{array}{ccc|c} 1 & 2 & 3 & 4 \\ 2 & 4 & 7 & 9 \end{array}\right] \xrightarrow{R_2 - 2R_1} \left[\begin{array}{ccc|c} 1 & 2 & 3 & 4 \\ 0 & 0 & 1 & 1 \end{array}\right] \xrightarrow{R_1 - 3R_2} \left[\begin{array}{ccc|c} 1 & 2 & 0 & 1 \\ 0 & 0 & 1 & 1 \end{array}\right] \end{aligned}$$
- The pivots are in the $x$ and $z$ columns, so $y$ is free. Let $y = s$.
- Read off the rows: $z = 1$ and $x + 2y = 1 \Rightarrow x = 1 - 2s$.
- In vector form: $\begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix} + s\begin{bmatrix} -2 \\ 1 \\ 0 \end{bmatrix}$.
- CoreSolve the homogeneous system $x_1 + 2x_2 - x_3 + x_4 = 0,\ 2x_1 + 4x_2 - x_3 + 3x_4 = 0$.Solution
- The right-hand sides are all 0, so reduce the coefficient matrix:$$\begin{aligned} &\begin{bmatrix} 1 & 2 & -1 & 1 \\ 2 & 4 & -1 & 3 \end{bmatrix} \xrightarrow{R_2 - 2R_1} \begin{bmatrix} 1 & 2 & -1 & 1 \\ 0 & 0 & 1 & 1 \end{bmatrix} \xrightarrow{R_1 + R_2} \begin{bmatrix} 1 & 2 & 0 & 2 \\ 0 & 0 & 1 & 1 \end{bmatrix} \end{aligned}$$
- Pivots in columns 1 and 3, so $x_2 = s$ and $x_4 = t$ are free.
- Rows give $x_3 = -x_4 = -t$ and $x_1 = -2x_2 - 2x_4 = -2s - 2t$.
- So $\bm{x} = s\begin{bmatrix} -2 \\ 1 \\ 0 \\ 0 \end{bmatrix} + t\begin{bmatrix} -2 \\ 0 \\ -1 \\ 1 \end{bmatrix}$.
- StretchFor which $k$ does $x + ky = 1,\ kx + y = 1$ have a unique solution, no solution, or infinitely many?Solution
- Augmented matrix: $\left[\begin{array}{cc|c} 1 & k & 1 \\ k & 1 & 1 \end{array}\right]$.
- $R_2 - kR_1$ gives $\left[\begin{array}{cc|c} 1 & k & 1 \\ 0 & 1 - k^2 & 1 - k \end{array}\right]$.
- If $1 - k^2 \ne 0$, i.e. $k \ne \pm1$, both columns have pivots: unique solution.
- If $k = 1$ the second row is $[\,0\ 0 \mid 0\,]$: one equation $x + y = 1$ remains, so infinitely many.
- If $k = -1$ the second row is $[\,0\ 0 \mid 2\,]$, which says $0 = 2$: no solution.
- ApplicationFind the parabola $y = a + bx + cx^2$ through $(1,4)$, $(2,9)$, $(3,16)$.Solution
- Each point gives a linear equation in $a, b, c$: $a + b + c = 4,\ a + 2b + 4c = 9,\ a + 3b + 9c = 16$.
- Row reduce:$$\begin{aligned} &\left[\begin{array}{ccc|c} 1 & 1 & 1 & 4 \\ 1 & 2 & 4 & 9 \\ 1 & 3 & 9 & 16 \end{array}\right] \xrightarrow{\substack{R_2 - R_1 \\ R_3 - R_1}} \left[\begin{array}{ccc|c} 1 & 1 & 1 & 4 \\ 0 & 1 & 3 & 5 \\ 0 & 2 & 8 & 12 \end{array}\right] \xrightarrow{\substack{R_1 - R_2 \\ R_3 - 2R_2}} \left[\begin{array}{ccc|c} 1 & 0 & -2 & -1 \\ 0 & 1 & 3 & 5 \\ 0 & 0 & 2 & 2 \end{array}\right] \\[6pt] \xrightarrow{\tfrac12 R_3} &\left[\begin{array}{ccc|c} 1 & 0 & -2 & -1 \\ 0 & 1 & 3 & 5 \\ 0 & 0 & 1 & 1 \end{array}\right] \xrightarrow{\substack{R_1 + 2R_3 \\ R_2 - 3R_3}} \left[\begin{array}{ccc|c} 1 & 0 & 0 & 1 \\ 0 & 1 & 0 & 2 \\ 0 & 0 & 1 & 1 \end{array}\right] \end{aligned}$$
- $a = 1,\ b = 2,\ c = 1$: the parabola is $y = 1 + 2x + x^2 = (x+1)^2$. Check: $(1+1)^2 = 4,\ (2+1)^2 = 9,\ (3+1)^2 = 16\;\checkmark$.
- Arithmetic slips with negatives. By far the most common error. Substitute the final answer back into the original equations, every time.
- Doing two row operations at once where one uses a row that has already been changed in the same step.
- Seeing a zero row $\left[\begin{array}{ccc|c} 0 & 0 & 0 & 0 \end{array}\right]$ and deciding there's no solution. That row is harmless ($0 = 0$); it just means one equation was redundant.
- Stopping at REF when the question says RREF, or calling something RREF when a pivot isn't 1 or has a non-zero entry above it.
- Forgetting to write the free variable as a parameter in the final answer.
A homogeneous system has 3 equations and 5 unknowns. At least how many free variables does it have?
Show answer
Test yourself
- Can a linear system have exactly two solutions? (No. If it has two, the whole line through them works too.)
- Can three planes in 3D have no common point even though no two are parallel? (Yes, like the three sides of a triangular prism. Great picture.)
- Why can a homogeneous system (all right-hand sides 0) never have "no solution"? ($\bm{x} = \bm{0}$ always works.)
- Why is it OK to add one equation to another? (If both are true, their sum is true.)
- Why may we multiply a row by 5 but not by 0? (Multiplying by 0 wipes out an equation and loses information.)
- Three equations, four unknowns: can there be exactly one solution? (No. At most 3 pivots, so at least one free variable.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Solve $x + 2y = 4$, $2x + 4y = 8$.
- Solve $x + 2y = 4$, $2x + 4y = 9$.
- Put $\left[\begin{array}{cc|c} 1 & 3 & 5 \\ 0 & 1 & 2 \end{array}\right]$ into RREF.
- Is $\left[\begin{array}{ccc|c} 1 & 0 & 2 & 3 \\ 0 & 1 & 0 & 1 \\ 0 & 0 & 0 & 0 \end{array}\right]$ in RREF? What's the solution?
- Solve $2x + y - z = 3,\ x - y + z = 0,\ 3x + 2y + z = 8$.
- Find the RREF and the general solution of $x + y + z + w = 4,\ x + 2y + 3z + 4w = 10$.
- For which $a$ and $b$ does $x + 2y = 3,\ 2x + ay = b$ have (i) a unique solution, (ii) no solution, (iii) infinitely many?
- Solve the homogeneous system $x + y - z = 0,\ 2x - y + z = 0,\ x + 2y - 2z = 0$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 2 Elimination with matrices; 7 Solving Ax = 0; 8 Solving Ax = b. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §2.1–2.2, 3.2–3.3.
- RD Sharma (Class 12): exercises in the chapters on Solution of Simultaneous Linear Equations.
Matrix algebra and the inverse
- Compute $A\bm{x}$ by rows and by columns, and see $A\bm{x} = \bm{b}$ as a system.
- Multiply matrices, using the size rule.
- Invert $2\times2$ matrices by formula and larger ones by $[\,A \mid I\,]$.
- Use inverses to solve systems and matrix equations.
A cake needs 3 eggs and 2 cups of flour; a batch of cookies needs 1 egg and 3 cups. How many eggs and cups for 2 cakes and 5 batches?
Show answer
Matrix–vector and matrix–matrix multiplication
A matrix is a machine: vector goes in, vector comes out.
The most useful idea: the column view
Multiplying a matrix by a vector means "take this much of column 1, plus this much of column 2". A bakery example makes it concrete. The columns are recipes (one cake, one batch of cookies); the rows are ingredients (eggs, cups of flour):
$$\begin{bmatrix} 3 & 1 \\ 2 & 3 \end{bmatrix}\begin{bmatrix} 2 \\ 5 \end{bmatrix} = 2\begin{bmatrix} 3 \\ 2 \end{bmatrix} + 5\begin{bmatrix} 1 \\ 3 \end{bmatrix} = \begin{bmatrix} 11 \\ 19 \end{bmatrix} \quad \begin{matrix} \text{eggs} \\ \text{cups of flour} \end{matrix}$$The vector says how many of each recipe you're making (2 cakes, 5 batches). The answer is your shopping list. That's a linear combination of the columns.
Two ways to compute $A\bm{x}$, same answer
Take $A = \begin{bmatrix} 1 & 0 & 2 \\ -1 & 3 & 1 \end{bmatrix}$ and $\bm{x} = \begin{bmatrix} 2 \\ 1 \\ 1 \end{bmatrix}$.
Row view (dot each row with $\bm{x}$), the fastest by hand:
$$A\bm{x} = \begin{bmatrix} 1(2) + 0(1) + 2(1) \\ -1(2) + 3(1) + 1(1) \end{bmatrix} = \begin{bmatrix} 4 \\ 2 \end{bmatrix}.$$Column view (weights times columns), which gives the meaning:
$$A\bm{x} = 2\begin{bmatrix} 1 \\ -1 \end{bmatrix} + 1\begin{bmatrix} 0 \\ 3 \end{bmatrix} + 1\begin{bmatrix} 2 \\ 1 \end{bmatrix} = \begin{bmatrix} 4 \\ 2 \end{bmatrix} \;\checkmark$$Size check: $A$ is $2\times3$ and $\bm{x}$ has 3 entries, so the answer has 2 entries. The number of columns of $A$ must equal the number of entries of $\bm{x}$.
That's the cinema problem from section 2.1. Once you see this, "solve $A\bm{x} = \bm{b}$" stops being scary.
Matrix times matrix
- Size rule: $(m\times n)(n\times p) = (m\times p)$. The inner numbers must match; the outer numbers give the answer's size.
- The $(i, j)$ entry of $AB$ is (row $i$ of $A$) $\cdot$ (column $j$ of $B$).
- Order matters. $AB$ is usually not $BA$. Socks-then-shoes is not shoes-then-socks.
Matrix algebra basics
- Adding, subtracting: the matrices must be the same size; work entry by entry.
- Scalar times matrix: multiply every entry.
- Transpose $A^T$: rows become columns, so a $2\times3$ becomes a $3\times2$: $\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}^T = \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}$.
- Identity $I$: 1s on the diagonal, 0s elsewhere. $AI = IA = A$, like multiplying by 1.
- Powers: $A^2 = AA$. Only square matrices have powers.
| Works like ordinary numbers | Does NOT work like ordinary numbers |
|---|---|
| $A + B = B + A$ | $AB \ne BA$ in general |
| $A(B + C) = AB + AC$ | $AB = 0$ does not force $A = 0$ or $B = 0$ |
| $(AB)C = A(BC)$ | $AB = AC$ does not force $B = C$ |
| $k(AB) = (kA)B$ | $(A + B)^2 = A^2 + AB + BA + B^2$, not $A^2 + 2AB + B^2$ |
A surprising example:
$$\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix},$$even though the matrix itself isn't zero.
Same two matrices, different order, different answer. This one example is worth more than the rule.
Matrix inverse
The undo button.
The idea
If $A$ is a machine, $A^{-1}$ is the machine that reverses it: $A^{-1}A = AA^{-1} = I$. You can't divide by a matrix, so to solve $A\bm{x} = \bm{b}$ you multiply both sides by the undo button: $\bm{x} = A^{-1}\bm{b}$.
Some matrices have no inverse. If $A$ squashes the whole plane onto a line, lots of different inputs land on the same output, and there's no way to know which one you started from. You can't unscramble an egg.
The $2\times2$ formula
$$\begin{bmatrix} a & b \\ c & d \end{bmatrix}^{-1} = \frac{1}{ad - bc}\begin{bmatrix} d & -b \\ -c & a \end{bmatrix}, \qquad \text{provided } ad - bc \ne 0.$$In words: swap $a$ and $d$, change the signs of $b$ and $c$, and divide by $ad - bc$. If $ad - bc = 0$, there is no inverse.
Check:
$$AA^{-1} = \begin{bmatrix} 2(3) + 1(-5) & 2(-1) + 1(2) \\ 5(3) + 3(-5) & 5(-1) + 3(2) \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \;\checkmark$$Solve $2x + y = 4$, $5x + 3y = 11$. This is $A\bm{x} = \bm{b}$ with the $A$ above, so
$$\bm{x} = A^{-1}\bm{b} = \begin{bmatrix} 3 & -1 \\ -5 & 2 \end{bmatrix}\begin{bmatrix} 4 \\ 11 \end{bmatrix} = \begin{bmatrix} 12 - 11 \\ -20 + 22 \end{bmatrix} = \begin{bmatrix} 1 \\ 2 \end{bmatrix}.$$Check: $2 + 2 = 4$ and $5 + 6 = 11$ $\checkmark$. Keep this system in mind; Cramer's rule (section 7.2) solves the same one.
The $[\,A \mid I\,]$ method (any size)
Write $A$ and $I$ side by side and row reduce until the left half is $I$. The right half is then $A^{-1}$:
$$\left[\begin{array}{c|c} A & I \end{array}\right] \;\longrightarrow\; \left[\begin{array}{c|c} I & A^{-1} \end{array}\right]$$Find the inverse of $A = \begin{bmatrix} 1 & 2 \\ 3 & 7 \end{bmatrix}$.
$$\begin{aligned} &\left[\begin{array}{cc|cc} 1 & 2 & 1 & 0 \\ 3 & 7 & 0 & 1 \end{array}\right] \xrightarrow{\;R_2 - 3R_1\;} \left[\begin{array}{cc|cc} 1 & 2 & 1 & 0 \\ 0 & 1 & -3 & 1 \end{array}\right] \\[6pt] \xrightarrow{\;R_1 - 2R_2\;} &\left[\begin{array}{cc|cc} 1 & 0 & 7 & -2 \\ 0 & 1 & -3 & 1 \end{array}\right] \end{aligned}$$So $A^{-1} = \begin{bmatrix} 7 & -2 \\ -3 & 1 \end{bmatrix}$. This matches the $2\times2$ formula, since $ad - bc = 7 - 6 = 1$ $\checkmark$. The same method works for $3\times3$. If a row of zeros appears on the left side, $A$ has no inverse, so stop there.
Rules worth knowing
- $(A^{-1})^{-1} = A$. Undoing the undo gets you back where you started.
- $(AB)^{-1} = B^{-1}A^{-1}$. The order reverses: to undo "socks then shoes", you take off the shoes first.
- $(A^T)^{-1} = (A^{-1})^T$.
- Only square matrices can have inverses.
Worked examples
- CoreLet $A = \begin{bmatrix} 1 & -1 \\ 2 & 0 \\ 0 & 3 \end{bmatrix}$ and $B = \begin{bmatrix} 2 & 1 & 0 \\ 1 & -1 & 4 \end{bmatrix}$. Compute $AB$ and $BA$.Solution
- Sizes: $(3\times2)(2\times3) = 3\times3$ for $AB$ and $(2\times3)(3\times2) = 2\times2$ for $BA$.
- Each entry of $AB$ is a row of $A$ dotted with a column of $B$. Row 1 of $A$ is $(1,-1)$: with the columns $(2,1)$, $(1,-1)$, $(0,4)$ of $B$ it gives $2-1 = 1,\ 1+1 = 2,\ 0-4 = -4$. Rows $(2,0)$ and $(0,3)$ give $4, 2, 0$ and $3, -3, 12$.
- $AB = \begin{bmatrix} 1 & 2 & -4 \\ 4 & 2 & 0 \\ 3 & -3 & 12 \end{bmatrix}$.
- For $BA$: row $(2,1,0)$ with columns $(1,2,0)$, $(-1,0,3)$ gives $2+2+0 = 4$ and $-2+0+0 = -2$; row $(1,-1,4)$ gives $1-2+0 = -1$ and $-1+0+12 = 11$. So $BA = \begin{bmatrix} 4 & -2 \\ -1 & 11 \end{bmatrix}$.
- CoreInvert $\begin{bmatrix} 3 & 5 \\ 1 & 2 \end{bmatrix}$.Solution
- Here $a = 3$, $b = 5$, $c = 1$, $d = 2$, so $ad - bc = 6 - 5 = 1$.
- Swap $a$ and $d$, change the signs of $b$ and $c$: $\begin{bmatrix} 2 & -5 \\ -1 & 3 \end{bmatrix}$.
- Divide by $ad - bc = 1$: the inverse is $\begin{bmatrix} 2 & -5 \\ -1 & 3 \end{bmatrix}$.
- Check: $\begin{bmatrix} 3 & 5 \\ 1 & 2 \end{bmatrix}\begin{bmatrix} 2 & -5 \\ -1 & 3 \end{bmatrix} = \begin{bmatrix} 6-5 & -15+15 \\ 2-2 & -5+6 \end{bmatrix} = I\;\checkmark$.
- CoreUse the previous answer to solve $3x + 5y = 4,\ x + 2y = 1$.Solution
- The system is $A\bm{x} = \bm{b}$ with $A = \begin{bmatrix} 3 & 5 \\ 1 & 2 \end{bmatrix}$ and $\bm{b} = (4,1)$.
- Multiply by the inverse: $\bm{x} = A^{-1}\bm{b} = \begin{bmatrix} 2 & -5 \\ -1 & 3 \end{bmatrix}\begin{bmatrix} 4 \\ 1 \end{bmatrix} = \begin{bmatrix} 8 - 5 \\ -4 + 3 \end{bmatrix} = \begin{bmatrix} 3 \\ -1 \end{bmatrix}$.
- Check: $3(3) + 5(-1) = 4$ and $3 + 2(-1) = 1\;\checkmark$.
- CoreUse $[\,A \mid I\,]$ to invert $A = \begin{bmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 3 & 4 & 1 \end{bmatrix}$.Solution
- Write $[\,A \mid I\,]$ and row reduce until the left side is $I$:$$\begin{aligned} &\left[\begin{array}{ccc|ccc} 1 & 0 & 0 & 1 & 0 & 0 \\ 2 & 1 & 0 & 0 & 1 & 0 \\ 3 & 4 & 1 & 0 & 0 & 1 \end{array}\right] \xrightarrow{\substack{R_2 - 2R_1 \\ R_3 - 3R_1}} \left[\begin{array}{ccc|ccc} 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & 1 & 0 & -2 & 1 & 0 \\ 0 & 4 & 1 & -3 & 0 & 1 \end{array}\right] \xrightarrow{R_3 - 4R_2} \left[\begin{array}{ccc|ccc} 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & 1 & 0 & -2 & 1 & 0 \\ 0 & 0 & 1 & 5 & -4 & 1 \end{array}\right] \end{aligned}$$
- The right half is the inverse: $A^{-1} = \begin{bmatrix} 1 & 0 & 0 \\ -2 & 1 & 0 \\ 5 & -4 & 1 \end{bmatrix}$.
- Check one entry: row 3 of $A$ times column 1 of $A^{-1}$ is $3(1) + 4(-2) + 1(5) = 0\;\checkmark$.
- StretchFind all matrices $X$ that commute with $A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}$.Solution
- Let $X = \begin{bmatrix} a & b \\ c & d \end{bmatrix}$ and compute both products: $AX = \begin{bmatrix} a+c & b+d \\ c & d \end{bmatrix}$, $XA = \begin{bmatrix} a & a+b \\ c & c+d \end{bmatrix}$.
- Set them equal entry by entry: $a + c = a \Rightarrow c = 0$; $b + d = a + b \Rightarrow d = a$; the bottom row gives nothing new.
- So $X = \begin{bmatrix} a & b \\ 0 & a \end{bmatrix}$ for any numbers $a$, $b$.
- ApplicationA message is encoded by multiplying pairs of numbers by $E = \begin{bmatrix} 2 & 1 \\ 1 & 1 \end{bmatrix}$. You receive $(21, 13)$. Decode it.Solution
- Encoding is $E\bm{x} = \bm{c}$, so decoding is $\bm{x} = E^{-1}\bm{c}$.
- $\det E = 2 - 1 = 1$, so $E^{-1} = \begin{bmatrix} 1 & -1 \\ -1 & 2 \end{bmatrix}$.
- $\bm{x} = \begin{bmatrix} 1 & -1 \\ -1 & 2 \end{bmatrix}\begin{bmatrix} 21 \\ 13 \end{bmatrix} = \begin{bmatrix} 21 - 13 \\ -21 + 26 \end{bmatrix} = \begin{bmatrix} 8 \\ 5 \end{bmatrix}$.
- Check: $E(8,5) = (16 + 5,\ 8 + 5) = (21,13)\;\checkmark$. With A = 1, B = 2, …, the pair 8, 5 spells "HE".
- Multiplying entry by entry. That isn't matrix multiplication.
- Cancelling: $AB = AC$ does not mean $B = C$ in general.
- The transpose of a product reverses the order: $(AB)^T = B^TA^T$.
- Forgetting the $\dfrac{1}{ad - bc}$ in front.
- Writing $\bm{b}/A$. Matrix division doesn't exist; it's always multiplication by $A^{-1}$, and on the correct side.
- Writing $(AB)^{-1} = A^{-1}B^{-1}$. The order must reverse.
If $A^2 = I$, what is $A^{-1}$?
Show answer
Test yourself
- $A$ is $2\times3$ and $B$ is $3\times4$. Which of $AB$ and $BA$ exist, and what size? ($AB$ is $2\times4$; $BA$ doesn't exist.)
- What does multiplying by $\begin{bmatrix} 1 \\ 0 \end{bmatrix}$ pull out of a $2\times2$ matrix? (The first column.)
- What does $I\bm{x}$ give? ($\bm{x}$ itself. It's the "do nothing" machine.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Compute $\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}\begin{bmatrix} 5 \\ 6 \end{bmatrix}$.
- Compute $\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}\begin{bmatrix} 2 & 0 \\ 1 & 1 \end{bmatrix}$.
- Write $x - y + 2z = 1$, $3y + z = 0$ in the form $A\bm{x} = \bm{b}$.
- Invert $\begin{bmatrix} 4 & 7 \\ 2 & 6 \end{bmatrix}$.
- Does $\begin{bmatrix} 2 & 4 \\ 1 & 2 \end{bmatrix}$ have an inverse?
- Let $A = \begin{bmatrix} 1 & 2 \\ 0 & -1 \end{bmatrix}$ and $B = \begin{bmatrix} 3 & 1 \\ 1 & 0 \end{bmatrix}$. Compute $AB$, $BA$ and $A^TB$.
- Invert $\begin{bmatrix} 2 & -1 \\ -3 & 2 \end{bmatrix}$.
- Use $[\,A \mid I\,]$ to invert $\begin{bmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 0 & 0 & 1 \end{bmatrix}$.
- Solve $XA = B$ for $X$, where $A = \begin{bmatrix} 1 & 2 \\ 1 & 3 \end{bmatrix}$ and $B = \begin{bmatrix} 2 & 1 \\ 0 & 1 \end{bmatrix}$.
- Show that $(A^{-1})^T$ is the inverse of $A^T$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 3 Multiplication and inverse matrices; 5 Transposes, permutations, spaces. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §2.4, 2.5, 2.7.
- RD Sharma (Class 12): exercises in the chapters on Algebra of Matrices; Adjoint and Inverse of a Matrix.
Span, independence, basis and dimension
- Describe a span geometrically and test whether a vector lies in it.
- Define linear independence and test it by row reduction or determinant.
- Decide whether a set is a basis, and extract a basis from a spanning set.
- Find the dimension of a span or a plane.
Using only steps along $(1,1)$ and $(1,-1)$, forwards or backwards, can you reach $(5,3)$? Can you reach anywhere in the plane?
Show answer
Span, independence and basis
Where can these vectors take you, and is any of them wasted?
Span: where can you get to?
Imagine you can only move along certain arrows, as far as you like, forwards or backwards. The span is every place you can reach, i.e. all the linear combinations:
$$\operatorname{span}\{\bm{v}_1, \dots, \bm{v}_k\} = \{\, c_1\bm{v}_1 + \cdots + c_k\bm{v}_k \;:\; c_1, \dots, c_k \in \R \,\}.$$- One non-zero arrow: you can reach a line through the origin.
- Two arrows pointing different ways: you can reach a plane through the origin (in 2D, that's everything).
- Two arrows pointing the same way (one a multiple of the other): still only a line. The second one added nothing.
Is $\bm{b}$ in the span? That asks "can I find weights that make $\bm{b}$?", which is a system. Put the vectors in as columns with $\bm{b}$ after the bar, and row reduce. Consistent means yes.
Independence: is anything redundant?
A set of vectors is linearly independent if none of them can be built from the others. Paint analogy: red, blue and yellow are independent. Add purple and the set becomes dependent, because you could already mix purple from red and blue.
The textbook definition: $\{\bm{v}_1, \dots, \bm{v}_k\}$ is independent if
$$c_1\bm{v}_1 + c_2\bm{v}_2 + \cdots + c_k\bm{v}_k = \bm{0} \quad\text{only when}\quad c_1 = c_2 = \cdots = c_k = 0.$$In words: the only way to walk along these arrows and end up back at the start is not to move at all.
How to test: put the vectors in as the columns of a matrix and row reduce. A pivot in every column means independent; any column without a pivot means dependent. For $n$ vectors in $\R^n$ you can instead check that the determinant is non-zero.
Basis and dimension
A basis of a space is a set of vectors that is independent (no waste) and spans the space (reaches everywhere). It's a coordinate system. The standard basis of $\R^2$ is $\left\{\begin{bmatrix} 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \end{bmatrix}\right\}$, but $\left\{\begin{bmatrix} 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 1 \\ 1 \end{bmatrix}\right\}$ works just as well.
Every basis of a space has the same number of vectors. That number is the dimension: $\dim\R^n = n$, a plane has dimension 2, a line has dimension 1.
The weights needed to build a vector from a basis are its coordinates in that basis. In section 1.2 we found $(7, 4) = 1(1, 1) + 3(2, 1)$, so in the basis $\{(1, 1), (2, 1)\}$ its coordinates are $(1, 3)$.
Are $(1, 2, 3)$, $(4, 5, 6)$ and $(7, 8, 9)$ independent? Row reducing the matrix with these as columns leaves only two pivots, so they are dependent. Indeed
$$\begin{bmatrix} 7 \\ 8 \\ 9 \end{bmatrix} = 2\begin{bmatrix} 4 \\ 5 \\ 6 \end{bmatrix} - \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} \;\checkmark,$$so the three vectors span only a plane in $\R^3$.
Is $\{(1, 0, 1), (0, 1, 1), (1, 1, 0)\}$ a basis of $\R^3$? It's three vectors in $\R^3$, so just check the determinant:
$$\begin{vmatrix} 1 & 0 & 1 \\ 0 & 1 & 1 \\ 1 & 1 & 0 \end{vmatrix} = 1(0 - 1) - 0 + 1(0 - 1) = -2 \ne 0.$$They're independent, and three independent vectors in $\R^3$ automatically span it. So yes.
Worked examples
- CoreIs $(2,1,5)$ in $\operatorname{span}\{(1,0,1),(0,1,2)\}$?Solution
- We need weights with $a(1,0,1) + b(0,1,2) = (2,1,5)$, i.e. $a = 2,\ b = 1,\ a + 2b = 5$.
- The first two equations force $a = 2$, $b = 1$.
- Then $a + 2b = 4 \ne 5$. The system is inconsistent, so $(2,1,5)$ is not in the span.
- CoreAre $(1,2,1)$, $(2,1,0)$, $(1,-1,-1)$ independent?Solution
- Put the vectors in as columns and row reduce:$$\begin{aligned} &\begin{bmatrix} 1 & 2 & 1 \\ 2 & 1 & -1 \\ 1 & 0 & -1 \end{bmatrix} \xrightarrow{\substack{R_2 - 2R_1 \\ R_3 - R_1}} \begin{bmatrix} 1 & 2 & 1 \\ 0 & -3 & -3 \\ 0 & -2 & -2 \end{bmatrix} \xrightarrow{-\tfrac13 R_2} \begin{bmatrix} 1 & 2 & 1 \\ 0 & 1 & 1 \\ 0 & -2 & -2 \end{bmatrix} \\[6pt] \xrightarrow{\substack{R_1 - 2R_2 \\ R_3 + 2R_2}} &\begin{bmatrix} 1 & 0 & -1 \\ 0 & 1 & 1 \\ 0 & 0 & 0 \end{bmatrix} \end{aligned}$$
- Column 3 has no pivot, so the vectors are dependent.
- The RREF says column 3 $= -$column 1 $+$ column 2, i.e. $(1,-1,-1) = -(1,2,1) + (2,1,0)$, so $(1,2,1) - (2,1,0) + (1,-1,-1) = \bm{0}$.
- CoreIs $\{(1,2),(3,4)\}$ a basis of $\R^2$? If so, find the coordinates of $(5,6)$.Solution
- Two vectors in $\R^2$ form a basis exactly when they're independent: $\det\begin{bmatrix} 1 & 3 \\ 2 & 4 \end{bmatrix} = 4 - 6 = -2 \ne 0$. So yes.
- Coordinates of $(5,6)$: solve $a(1,2) + b(3,4) = (5,6)$, i.e. $a + 3b = 5,\ 2a + 4b = 6$.
- $R_2 - 2R_1$: $-2b = -4 \Rightarrow b = 2$, then $a = 5 - 6 = -1$.
- Check: $-1(1,2) + 2(3,4) = (5,6)\;\checkmark$. The coordinates are $(-1,2)$.
- CoreFind a basis of $\operatorname{span}\{(1,2,3),(2,4,6),(1,0,1),(0,2,2)\}$ and its dimension.Solution
- Put the four vectors in as columns and row reduce:$$\begin{aligned} &\begin{bmatrix} 1 & 2 & 1 & 0 \\ 2 & 4 & 0 & 2 \\ 3 & 6 & 1 & 2 \end{bmatrix} \xrightarrow{\substack{R_2 - 2R_1 \\ R_3 - 3R_1}} \begin{bmatrix} 1 & 2 & 1 & 0 \\ 0 & 0 & -2 & 2 \\ 0 & 0 & -2 & 2 \end{bmatrix} \xrightarrow{\substack{-\tfrac12 R_2 \\ R_3 - R_2}} \begin{bmatrix} 1 & 2 & 1 & 0 \\ 0 & 0 & 1 & -1 \\ 0 & 0 & 0 & 0 \end{bmatrix} \\[6pt] \xrightarrow{R_1 - R_2} &\begin{bmatrix} 1 & 2 & 0 & 1 \\ 0 & 0 & 1 & -1 \\ 0 & 0 & 0 & 0 \end{bmatrix} \end{aligned}$$
- Pivots are in columns 1 and 3. Take those columns of the original list: $\{(1,2,3),(1,0,1)\}$.
- The RREF also shows the redundancies: column 2 $= 2\,\times$ column 1, and column 4 $=$ column 1 $-$ column 3.
- Dimension 2.
- StretchTrue or false: if $\{\bm{u},\bm{v}\}$ and $\{\bm{v},\bm{w}\}$ are both independent, then $\{\bm{u},\bm{v},\bm{w}\}$ is independent.Solution
- Look for a counterexample in $\R^2$: $\bm{u} = (1,0),\ \bm{v} = (0,1),\ \bm{w} = (1,1)$.
- $\{\bm{u},\bm{v}\}$ is independent (not multiples), and so is $\{\bm{v},\bm{w}\}$.
- But $\bm{u} + \bm{v} - \bm{w} = \bm{0}$, so $\{\bm{u},\bm{v},\bm{w}\}$ is dependent. (Three vectors in $\R^2$ always are.) False.
- ExtraExtend $\{(1,2,0),\ (0,1,1)\}$ to a basis of $\R^3$ by adding a standard basis vector, then find the coordinates of $(1,1,1)$ in your basis.Solution
- Try adding $\bm{e}_1 = (1,0,0)$. The matrix with columns $(1,2,0)$, $(0,1,1)$, $(1,0,0)$ has determinant $\begin{vmatrix} 1 & 0 & 1 \\ 2 & 1 & 0 \\ 0 & 1 & 0 \end{vmatrix} = 1(0 - 0) - 0 + 1(2 - 0) = 2 \ne 0$, so the three vectors form a basis.
- Coordinates: solve $a(1,2,0) + b(0,1,1) + c(1,0,0) = (a + c,\ 2a + b,\ b) = (1,1,1)$.
- The third entry gives $b = 1$; the second gives $2a + 1 = 1 \Rightarrow a = 0$; the first gives $c = 1$.
- Coordinates $(0,1,1)$. Check: $0(1,2,0) + 1(0,1,1) + 1(1,0,0) = (1,1,1)\;\checkmark$.
- Thinking more vectors always means a bigger span. Not if they're redundant.
- Believing a basis is unique. A space has infinitely many bases; they just all have the same size.
- Checking only that the vectors aren't multiples of each other in pairs. With three or more, one can be a combination of two others without being a multiple of either.
- Rule of thumb: more than $n$ vectors in $\R^n$ are always dependent, and fewer than $n$ can never span $\R^n$.
What is the dimension of $\operatorname{span}\{(1,1),(2,2),(-3,-3)\}$?
Show answer
Test yourself
- Can 2 vectors span $\R^3$? Why not, in picture terms? (Two arrows can only sweep out a plane.)
- Is any set containing the zero vector independent? (No.)
- If 3 vectors in $\R^3$ are independent, do you still need to check that they span? (No. The right number and independent means basis.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Are $(1, 2)$ and $(3, 6)$ independent?
- Are $(1, 1, 0)$, $(0, 1, 1)$ and $(1, 2, 1)$ independent?
- Is $(1, 1, 1)$ in $\operatorname{span}\{(1, 0, 1), (0, 1, 0)\}$?
- Is $(1,2,3)$ in $\operatorname{span}\{(1,1,1),(0,1,2)\}$?
- Are $(1,0,2)$, $(0,1,-1)$, $(2,3,1)$ independent?
- Find a basis and the dimension of $\operatorname{span}\{(1,1,0),(2,2,0),(0,1,1),(1,2,1)\}$.
- Find the coordinates of $(2,3)$ in the basis $\{(1,1),(1,-1)\}$.
- For which $h$ is $\{(1,2,3),(0,1,h),(1,3,5)\}$ dependent?
Further practice
- Strang, MIT 18.06 (OCW): lecture 9 Independence, basis and dimension. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §3.4.
Subspaces, null space, column space and rank
- Apply the subspace test, with examples and non-examples.
- Find a basis for the null space of a matrix.
- Compute rank, nullity and bases for the null, column and row spaces.
- Apply the rank–nullity theorem.
Which of these pass through the origin: the line $y = 2x$, the line $y = 2x + 1$, the parabola $y = x^2$? Which are "flat"?
Show answer
Subspaces of ℝⁿ
Flat things through the origin, and the two that every matrix comes with.
What counts as a subspace
A subspace $U$ of $\R^n$ is a flat thing through the origin: just $\{\bm{0}\}$, a line through $\bm{0}$, a plane through $\bm{0}$, and so on up to all of $\R^n$. The subspace test has three parts:
- $\bm{0} \in U$. (The fastest way to rule things out.)
- If $\bm{x}, \bm{y} \in U$, then $\bm{x} + \bm{y} \in U$. (Closed under addition.)
- If $\bm{x} \in U$ and $c \in \R$, then $c\bm{x} \in U$. (Closed under scalar multiplication.)
A useful shortcut: the span of any set of vectors is always a subspace. So if you can write the set as "all combinations of these vectors", you're done.
The two subspaces every matrix has
| Null space, $\operatorname{null}A$ | Column space, $\operatorname{col}A$ | |
|---|---|---|
| Plain English | Every input $A$ squashes to zero | Every output $A$ can produce |
| Definition | $\{\bm{x} : A\bm{x} = \bm{0}\}$ | The span of the columns of $A$ |
| Basis | Solve $A\bm{x} = \bm{0}$ by RREF; one vector per free variable | The original columns of $A$ that contain pivots |
| Dimension | Number of free variables (the nullity) | Number of pivots (the rank) |
The row space (the span of the rows) has the same dimension as the column space. A basis for it is the non-zero rows of the RREF.
Rank and the rank–nullity theorem
For an $m\times n$ matrix $A$,
$$\operatorname{rank}A + \dim(\operatorname{null}A) = n \quad (\text{the number of columns}).$$In words: every column is either a pivot column (a "decided" variable) or a free column (a free variable). Count both and you've counted every column.
Find the rank, the null space and the column space of $A = \begin{bmatrix} 1 & 2 & 1 \\ 2 & 4 & 3 \end{bmatrix}$.
$$\begin{bmatrix} 1 & 2 & 1 \\ 2 & 4 & 3 \end{bmatrix} \xrightarrow{\;R_2 - 2R_1\;} \begin{bmatrix} 1 & 2 & 1 \\ 0 & 0 & 1 \end{bmatrix} \xrightarrow{\;R_1 - R_2\;} \begin{bmatrix} 1 & 2 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$The pivots are in columns 1 and 3, so $\operatorname{rank}A = 2$. Column 2 is free, so the nullity is 1, and $2 + 1 = 3$ columns $\checkmark$.
Null space: with $x_2 = t$ we get $x_3 = 0$ and $x_1 = -2t$, so
$$\operatorname{null}A = \operatorname{span}\left\{\begin{bmatrix} -2 \\ 1 \\ 0 \end{bmatrix}\right\}, \qquad \text{check: } \begin{bmatrix} 1 & 2 & 1 \\ 2 & 4 & 3 \end{bmatrix}\begin{bmatrix} -2 \\ 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix} \;\checkmark$$Column space: take the original columns 1 and 3, so $\operatorname{col}A = \operatorname{span}\left\{\begin{bmatrix} 1 \\ 2 \end{bmatrix}, \begin{bmatrix} 1 \\ 3 \end{bmatrix}\right\}$. These are two independent vectors in $\R^2$, so $\operatorname{col}A = \R^2$.
Worked examples
- CoreWhich are subspaces of $\R^3$? (a) $x + y + z = 0$ (b) $x + y + z = 1$ (c) $x = 2z$ (d) $\{(t, t^2, 0)\}$.Solution
- (a) $\bm{0}$ satisfies $x + y + z = 0$. If two vectors satisfy it, so does their sum (add the equations) and any multiple (multiply by $c$). Subspace.
- (b) $0 + 0 + 0 \ne 1$, so $\bm{0}$ is missing. Not a subspace.
- (c) $\bm{0}$ satisfies $x = 2z$. If $x_1 = 2z_1$ and $x_2 = 2z_2$ then $x_1 + x_2 = 2(z_1 + z_2)$, and $cx_1 = 2(cz_1)$. Subspace (a plane through 0).
- (d) $(1,1,0)$ is in the set ($t = 1$), but $2(1,1,0) = (2,2,0)$ would need $t = 2$ and $t^2 = 2$. Not closed under scaling. Not a subspace.
- CoreFor $A = \begin{bmatrix} 1 & 2 & 0 & 1 \\ 2 & 4 & 1 & 4 \\ 3 & 6 & 1 & 5 \end{bmatrix}$, find the rank, a basis of each of the null, column and row spaces, and check rank–nullity.Solution
- Row reduce:$$\begin{aligned} &\begin{bmatrix} 1 & 2 & 0 & 1 \\ 2 & 4 & 1 & 4 \\ 3 & 6 & 1 & 5 \end{bmatrix} \xrightarrow{\substack{R_2 - 2R_1 \\ R_3 - 3R_1}} \begin{bmatrix} 1 & 2 & 0 & 1 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \end{bmatrix} \xrightarrow{R_3 - R_2} \begin{bmatrix} 1 & 2 & 0 & 1 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 0 & 0 \end{bmatrix} \end{aligned}$$
- Two pivots (columns 1 and 3), so $\operatorname{rank}A = 2$.
- Null space: free $x_2 = s,\ x_4 = t$; then $x_3 = -2t$ and $x_1 = -2s - t$. Basis $\{(-2,1,0,0),\ (-1,0,-2,1)\}$.
- Column space: the original pivot columns, $\{(1,2,3),\ (0,1,1)\}$. Row space: the non-zero RREF rows, $\{(1,2,0,1),\ (0,0,1,2)\}$.
- Rank–nullity: $2 + 2 = 4$ columns $\checkmark$.
- Core$A$ is $5\times7$ with rank 3. Find the nullity and the dimensions of the column and row spaces. Is $A\bm{x} = \bm{b}$ solvable for every $\bm{b} \in \R^5$?Solution
- Rank–nullity: $\text{nullity} = 7 - 3 = 4$.
- The column and row spaces both have dimension equal to the rank: 3.
- $\operatorname{col}A$ is a 3-dimensional subspace of $\R^5$, so it can't be all of $\R^5$. Some $\bm{b}$ are unreachable: not solvable for every $\bm{b}$.
- CoreLet $A = \begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}$. Is $(3,1)$ in $\operatorname{col}A$? Is $(3,6)$?Solution
- The second column is twice the first, so $\operatorname{col}A = \operatorname{span}\{(1,2)\}$.
- $(3,1) = c(1,2)$ would need $c = 3$ and $2c = 1$. Impossible, so no.
- $(3,6) = 3(1,2)$, so yes; for example $A(3,0) = (3,6)$.
- ExtraFor $A = \begin{bmatrix} 1 & 2 \\ 2 & 4 \\ 3 & 6 \end{bmatrix}$, describe $\operatorname{col}A$ and $\operatorname{null}A$, and find every $\bm{b}$ for which $A\bm{x} = \bm{b}$ is solvable.Solution
- Column 2 is twice column 1, so $\operatorname{col}A = \operatorname{span}\{(1,2,3)\}$: a line in $\R^3$. Rank 1.
- Rank–nullity: nullity $2 - 1 = 1$. From $x_1 + 2x_2 = 0$: $\operatorname{null}A = \operatorname{span}\{(-2,1)\}$.
- $A\bm{x} = \bm{b}$ is solvable exactly when $\bm{b}$ is in the column space: $\bm{b} = t(1,2,3)$, i.e. $b_2 = 2b_1$ and $b_3 = 3b_1$.
- Using the RREF's columns as the column space basis. Use the RREF only to find which columns have pivots, then take those columns from the original $A$.
- Calling the line $y = x + 1$ a subspace. It misses the origin.
- Passing the zero test and stopping. A set can contain $\bm{0}$ and still fail the addition test (see practice problem 1c).
A $3\times3$ matrix has a null space that is a line. What is its rank?
Show answer
Test yourself
- What's the null space of an invertible matrix? (Just $\{\bm{0}\}$. Nothing non-zero gets squashed.)
- $A$ is $3\times5$. What's the largest possible rank? Can the null space be $\{\bm{0}\}$? (The rank is at most 3, so the nullity is at least 2. No.)
- Is the solution set of $A\bm{x} = \bm{b}$ with $\bm{b} \ne \bm{0}$ a subspace? (No. It doesn't contain $\bm{0}$.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Which of these are subspaces of $\R^2$? (a) all $(x, y)$ with $y = 2x$; (b) all $(x, y)$ with $y = 2x + 1$; (c) all $(x, y)$ with $xy \ge 0$.
- Find a basis for the plane $x + y + z = 0$, which is the null space of $\begin{bmatrix} 1 & 1 & 1 \end{bmatrix}$.
- A $4\times6$ matrix has rank 4. What is its nullity?
- Which are subspaces? (a) $\{(x,y,z) : x = y = z\}$ in $\R^3$; (b) $\{(x,y) : x \ge 0\}$ in $\R^2$; (c) $\{(x,y,z) : z = xy\}$ in $\R^3$.
- Find a basis for the null space of $\begin{bmatrix} 1 & 2 & -1 \\ 2 & 4 & -2 \\ 1 & 3 & 0 \end{bmatrix}$.
- Find the rank and nullity of $\begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 1 & 1 & 1 \end{bmatrix}$, and a basis of its column space.
- $A$ is $6\times4$ with rank 4. What is its nullity? How many solutions can $A\bm{x} = \bm{b}$ have?
Further practice
- Strang, MIT 18.06 (OCW): lecture 6 Column space and nullspace; 10 The four fundamental subspaces. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §3.1, 3.2, 3.5.
Midterm review: Units 1–5
- Connect the first five units through $A\bm{x} = \bm{b}$.
- Practise exam-style problems under time pressure.
- Rehearse the checking habits.
Quick quiz: (1) Is $\{(1,2),(2,4)\}$ independent? (2) Size of $AB$ if $A$ is $2\times3$ and $B$ is $3\times4$? (3) Is $y = 3x - 1$ a subspace?
Show answer
Concept map on the board
- Everything in Units 1–5 connects to $A\bm{x} = \bm{b}$: linear combinations of columns (U1), row reduction (U2), inverse (U3), independence of columns (U4), null and column space (U5).
- Partial Invertible Matrix Theorem: invertible, a pivot in every column, independent columns, columns span, $\operatorname{null}A = \{\bm{0}\}$.
Exam technique
- Answer the question asked (number, vector, matrix, yes/no). Show the row operations. Check every answer: substitute back, dot with the originals, multiply out.
- Exams usually allow only a basic calculator, so practise the arithmetic by hand.
Worked examples
- Unit 1Find the plane through $(1,0,1)$ that contains the line $(2,1,0) + t(1,1,1)$.Solution
- Taking $t = 0$, the point $Q(2,1,0)$ is on the line, so it's on the plane.
- Two directions lying in the plane: $\overrightarrow{PQ} = (1,1,-1)$ and the line's direction $(1,1,1)$.
- Normal: $(1,1,-1)\times(1,1,1) = \big(1\cdot1 - (-1)\cdot1,\ -[1\cdot1 - (-1)\cdot1],\ 1\cdot1 - 1\cdot1\big) = (2,-2,0)$.
- Plane through $P(1,0,1)$: $2(x-1) - 2(y-0) + 0(z-1) = 0 \Rightarrow x - y = 1$.
- Check: $Q$ gives $2 - 1 = 1$ and $Q + (1,1,1) = (3,2,1)$ gives $3 - 2 = 1\;\checkmark$.
- Unit 1Find the distance from $(2,3,1)$ to the line through the origin with direction $(1,1,1)$.Solution
- Project $\bm{u} = (2,3,1)$ onto $\bm{d} = (1,1,1)$: $\bm{u}\cdot\bm{d} = 6$, $\bm{d}\cdot\bm{d} = 3$, so the projection is $2(1,1,1) = (2,2,2)$.
- Perpendicular part: $(2,3,1) - (2,2,2) = (0,1,-1)$.
- The distance to the line is its length: $\sqrt{0 + 1 + 1} = \sqrt2$.
- Unit 2Solve $x + y + 2z = 3,\ 2x + 3y + 5z = 8,\ x + 2y + 3z = 5$.Solution
- Row reduce the augmented matrix:$$\begin{aligned} &\left[\begin{array}{ccc|c} 1 & 1 & 2 & 3 \\ 2 & 3 & 5 & 8 \\ 1 & 2 & 3 & 5 \end{array}\right] \xrightarrow{\substack{R_2 - 2R_1 \\ R_3 - R_1}} \left[\begin{array}{ccc|c} 1 & 1 & 2 & 3 \\ 0 & 1 & 1 & 2 \\ 0 & 1 & 1 & 2 \end{array}\right] \xrightarrow{\substack{R_1 - R_2 \\ R_3 - R_2}} \left[\begin{array}{ccc|c} 1 & 0 & 1 & 1 \\ 0 & 1 & 1 & 2 \\ 0 & 0 & 0 & 0 \end{array}\right] \end{aligned}$$
- $z$ is free: let $z = t$. Then $x = 1 - t$ and $y = 2 - t$.
- $\bm{x} = (1,2,0) + t(-1,-1,1)$. Check $t = 0$ in the second equation: $2 + 6 + 0 = 8\;\checkmark$.
- Unit 3Solve $AX = B$ for $A = \begin{bmatrix} 2 & 3 \\ 1 & 2 \end{bmatrix}$ and $B = \begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix}$.Solution
- $\det A = 4 - 3 = 1$, so $A^{-1} = \begin{bmatrix} 2 & -3 \\ -1 & 2 \end{bmatrix}$.
- Multiply on the left: $X = A^{-1}B = \begin{bmatrix} 2 & -3 \\ -1 & 2 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix}$.
- Row 1: $(2 - 6,\ 0 - 3) = (-4,-3)$. Row 2: $(-1 + 4,\ 0 + 2) = (3,2)$. So $X = \begin{bmatrix} -4 & -3 \\ 3 & 2 \end{bmatrix}$.
- Check: $AX = \begin{bmatrix} 2 & 3 \\ 1 & 2 \end{bmatrix}\begin{bmatrix} -4 & -3 \\ 3 & 2 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix} = B\;\checkmark$.
- Units 4–5For $A = \begin{bmatrix} 1 & 1 & 2 \\ 1 & 2 & 3 \\ 2 & 3 & 5 \end{bmatrix}$, find the rank and a basis for the null space. Is $A$ invertible?Solution
- Look at the columns: $1 + 1 = 2,\ 1 + 2 = 3,\ 2 + 3 = 5$, so column 3 $=$ column 1 $+$ column 2.
- Columns 1 and 2 aren't multiples, so the rank is 2.
- The relation gives $A(1,1,-1) = \bm{0}$. The nullity is $3 - 2 = 1$, so $\operatorname{null}A = \operatorname{span}\{(1,1,-1)\}$.
- Rank $2 \lt 3$, so $A$ is not invertible.
- MixedTrue or false: (a) a homogeneous system with more unknowns than equations has infinitely many solutions; (b) if $A\bm{x} = \bm{0}$ has only the trivial solution then $A$ is invertible (for square $A$); (c) the union of two subspaces is a subspace.Solution
- (a) A homogeneous system is always consistent. With more unknowns than equations there are fewer pivots than variables, so there's a free variable: infinitely many solutions. True.
- (b) Only the trivial solution means a pivot in every column. For a square matrix that makes the RREF equal to $I$, so $A$ is invertible. True.
- (c) Take the $x$-axis and the $y$-axis: $(1,0)$ and $(0,1)$ are in the union but their sum $(1,1)$ isn't. False.
- MixedLet $A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$. Find $\det A$ and $A^{-1}$, solve $A\bm{x} = (1,1)$, and decide whether the columns of $A$ form a basis of $\R^2$.Solution
- $\det A = 4 - 6 = -2$.
- $A^{-1} = \tfrac{1}{-2}\begin{bmatrix} 4 & -2 \\ -3 & 1 \end{bmatrix} = \begin{bmatrix} -2 & 1 \\ \tfrac{3}{2} & -\tfrac{1}{2} \end{bmatrix}$.
- $\bm{x} = A^{-1}(1,1) = (-2 + 1,\ \tfrac32 - \tfrac12) = (-1,1)$. Check: $-1 + 2 = 1,\ -3 + 4 = 1\;\checkmark$.
- Since $\det A \ne 0$, the columns are independent; two independent vectors in $\R^2$ form a basis. Yes.
- Running out of time on one problem: move on and come back.
- Unchecked arithmetic in row reduction.
Write one thing you will practise before the midterm.
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Do the lines $(1,0,0) + t(1,1,0)$ and $(0,1,1) + s(1,0,-1)$ intersect?
- Solve $x + 2y - z = 1,\ 2x + 4y + z = 5,\ x + 2y + 2z = 4$.
- Is $\{(1,1,0,0),(0,1,1,0),(0,0,1,1),(1,0,0,1)\}$ a basis of $\R^4$?
- Find $\begin{bmatrix} 5 & 3 \\ 3 & 2 \end{bmatrix}^{-1}$ and use it to solve $5x + 3y = 1,\ 3x + 2y = 0$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 13 Quiz 1 review (plus the past exams on the course site). ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §Chapters 1–3.
- RD Sharma (Class 12): exercises in the chapters on Mixed exercises from the chapters above.
Linear transformations
- Test whether a map is linear.
- Build the matrix of a transformation from the images of $\bm{e}_1, \dots, \bm{e}_n$.
- Compose transformations, and find the kernel and image.
Apply the rule $(x, y) \mapsto (-y, x)$ to $(1,0)$, $(0,1)$ and $(1,1)$. Sketch before and after. What happened?
Show answer
Linear transformations
Moves that keep grid lines straight, parallel and evenly spaced, and keep the origin still.
The single most useful fact
The columns of the matrix are where the standard basis vectors land. For $T : \R^2 \to \R^2$,
$$A = \begin{bmatrix} T(\bm{e}_1) & T(\bm{e}_2) \end{bmatrix}, \qquad \bm{e}_1 = \begin{bmatrix} 1 \\ 0 \end{bmatrix},\ \bm{e}_2 = \begin{bmatrix} 0 \\ 1 \end{bmatrix}.$$To build any transformation matrix, just ask "where do $\bm{e}_1$ and $\bm{e}_2$ end up?" Real-world: every rotation, zoom and flip in a video game or photo editor is a matrix doing exactly this.
| Transformation | $T(\bm{e}_1)$ | $T(\bm{e}_2)$ | Matrix |
|---|---|---|---|
| Rotate $90^\circ$ counterclockwise | $(0, 1)$ | $(-1, 0)$ | $\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}$ |
| Reflect in the $x$-axis | $(1, 0)$ | $(0, -1)$ | $\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$ |
| Reflect in the line $y = x$ | $(0, 1)$ | $(1, 0)$ | $\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$ |
| Stretch $x$ by a factor of 3 | $(3, 0)$ | $(0, 1)$ | $\begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}$ |
| Horizontal shear | $(1, 0)$ | $(1, 1)$ | $\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}$ |
| Rotate by $\theta$ | $(\cos\theta, \sin\theta)$ | $(-\sin\theta, \cos\theta)$ | $\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}$ |
Is it linear?
Officially, $T$ is linear if for all vectors $\bm{u}, \bm{v}$ and scalars $c$:
$$T(\bm{u} + \bm{v}) = T(\bm{u}) + T(\bm{v}) \qquad\text{and}\qquad T(c\bm{u}) = c\,T(\bm{u}).$$Quick screening tests:
- Does $\bm{0}$ go to $\bm{0}$? If not, it's not linear. So "shift everything right by 1" is out.
- Any squares, products of variables, $\sin x$, or added constants? Not linear.
- If each output is just "numbers times variables, added up", it's linear, and you can read off the matrix.
Kernel and image
- The kernel of $T$ is every input sent to $\bm{0}$. It's the null space of $T$'s matrix (Unit 5).
- The image of $T$ is every output $T$ can produce. It's the column space of $T$'s matrix.
- $T$ is one-to-one (no two inputs share an output) exactly when $\ker T = \{\bm{0}\}$.
- $T$ is onto (every output can be reached) exactly when the image is the whole target space.
- Example: projecting 3D onto the floor, $T(x, y, z) = (x, y, 0)$. The kernel is the $z$-axis (everything squashed to $\bm{0}$), and the image is the floor. $T$ is neither one-to-one nor onto $\R^3$.
Worked examples
- CoreIs $T(x,y) = (2x - y,\ x + 3y,\ y)$ linear? If so, find its matrix.Solution
- Each output entry is a fixed combination of $x$ and $y$ (no constants, squares or products), so $T$ is linear.
- Images of the standard basis: $T(1,0) = (2,1,0)$ and $T(0,1) = (-1,3,1)$.
- These are the columns: $A = \begin{bmatrix} 2 & -1 \\ 1 & 3 \\ 0 & 1 \end{bmatrix}$, a $3\times2$ matrix.
- Core$T$ is linear with $T(1,0) = (2,5)$ and $T(0,1) = (-1,3)$. Find $T(3,-2)$.Solution
- Write the input in terms of the standard basis: $(3,-2) = 3\bm{e}_1 - 2\bm{e}_2$.
- Linearity: $T(3,-2) = 3T(\bm{e}_1) - 2T(\bm{e}_2)$.
- $= 3(2,5) - 2(-1,3) = (6,15) + (2,-6) = (8,9)$.
- CoreFind the matrix of the projection onto the line $y = x$, and apply it to $(3,1)$.Solution
- Projection onto the line with direction $\bm{d} = (1,1)$: $T(\bm{x}) = \dfrac{\bm{x}\cdot\bm{d}}{\bm{d}\cdot\bm{d}}\bm{d}$.
- $T(\bm{e}_1) = \tfrac12(1,1)$ and $T(\bm{e}_2) = \tfrac12(1,1)$.
- Matrix: $A = \tfrac12\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}$.
- Apply it: $A\begin{bmatrix} 3 \\ 1 \end{bmatrix} = \tfrac12\begin{bmatrix} 4 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \\ 2 \end{bmatrix}$.
- CoreFind the matrix that first reflects in the $x$-axis and then rotates $90^\circ$ counterclockwise. What single transformation is it?Solution
- Reflection in the $x$-axis: $F = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$. Rotation by $90^\circ$: $R = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}$.
- "First $F$, then $R$" means $RF$ (the matrix next to the vector acts first).
- $RF = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$.
- This swaps $x$ and $y$: it's the reflection in the line $y = x$. Check: $\bm{e}_1 \to (1,0) \to (0,1)\;\checkmark$.
- StretchFor $A = \begin{bmatrix} 1 & 0 & -1 \\ 0 & 1 & 2 \end{bmatrix}$, find $\ker T$. Is $T$ one-to-one? Onto $\R^2$?Solution
- The matrix is already in RREF. Solve $A\bm{x} = \bm{0}$: $x_1 - x_3 = 0$ and $x_2 + 2x_3 = 0$.
- With $x_3 = t$: $\bm{x} = t(1,-2,1)$, so $\ker T = \operatorname{span}\{(1,-2,1)\}$.
- The kernel isn't $\{\bm{0}\}$, so $T$ is not one-to-one.
- There are 2 pivots in 2 rows, so $\operatorname{col}A = \R^2$: $T$ is onto.
- ExtraFind the matrix of the reflection in the line $y = 2x$.Solution
- Projection onto the line (direction $(1,2)$): $P = \tfrac15\begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}$.
- Reflecting means going to the line and the same distance beyond it: $\text{reflection} = 2P - I$.
- $2P - I = \tfrac15\begin{bmatrix} 2 & 4 \\ 4 & 8 \end{bmatrix} - \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = \tfrac15\begin{bmatrix} -3 & 4 \\ 4 & 3 \end{bmatrix}$.
- Check: $(1,2)$ (on the line) is unchanged, $\tfrac15(-3 + 8,\ 4 + 6) = (1,2)$; and $(-2,1)$ (perpendicular) flips to $(2,-1)$ $\checkmark$.
- Doing "first $A$, then $B$" as $AB$. It's $BA$: the matrix closest to the vector acts first, so read right to left.
- Putting $T(\bm{e}_1)$ and $T(\bm{e}_2)$ in as rows instead of columns.
Find the matrix of $T(x,y,z) = (x + z,\ 2y)$.
Show answer
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Is $T(x, y) = (x + y,\, 2y)$ linear? If so, find its matrix.
- Is $T(x, y) = (x^2, y)$ linear?
- Find the matrix that rotates $90^\circ$ counterclockwise and then reflects in the $x$-axis.
- Find the matrix of the reflection in the line $y = -x$.
- Let $T(x,y,z) = (x - y,\ y - z,\ z - x)$. Find its matrix and kernel. Is $T$ onto $\R^3$?
- Write the matrix of rotation by $45^\circ$ and apply it to $(1,1)$.
- $T$ is linear with $T(1,1) = (3,1)$ and $T(1,-1) = (1,5)$. Find its matrix.
Further practice
- Strang, MIT 18.06 (OCW): lecture 30 Linear transformations and their matrices. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §8.1–8.2.
Determinants and Cramer's rule
- Compute determinants by cofactor expansion and by row reduction.
- Interpret the determinant as an area/volume scale factor and an invertibility test.
- Solve small systems with Cramer's rule.
Find the area of the parallelogram with sides $(3,0)$ and $(1,2)$ by drawing it.
Show answer
Determinants
How much the matrix stretches area (or volume).
The idea
Take the unit square and push it through the matrix. It becomes a parallelogram. The determinant is that parallelogram's (signed) area.
- $\det A = 6$: areas get 6 times bigger.
- $\det A \lt 0$: space got flipped over, like a mirror image.
- $\det A = 0$: everything got squashed flat. That's exactly why there's no inverse.
How to compute
$2\times2$:
$$\begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc.$$$3\times3$, cofactor expansion along the first row (signs alternate $+\,-\,+$):
$$\begin{vmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{vmatrix} = a_{11}\begin{vmatrix} a_{22} & a_{23} \\ a_{32} & a_{33} \end{vmatrix} - a_{12}\begin{vmatrix} a_{21} & a_{23} \\ a_{31} & a_{33} \end{vmatrix} + a_{13}\begin{vmatrix} a_{21} & a_{22} \\ a_{31} & a_{32} \end{vmatrix}.$$Tip: you may expand along any row or column. Choose the one with the most zeros.
Or row reduce to a triangular matrix, whose determinant is the product of the diagonal entries, keeping track of what the row operations did:
| Row operation | Effect on $\det$ |
|---|---|
| Interchange two rows | Sign flips |
| Multiply a row by $k$ | $\det$ is multiplied by $k$ |
| Add a multiple of one row to another | No change |
Expand along row 1 (it contains a zero):
$$\begin{vmatrix} 2 & 0 & 1 \\ 1 & 3 & 2 \\ 1 & 1 & 1 \end{vmatrix} = 2\begin{vmatrix} 3 & 2 \\ 1 & 1 \end{vmatrix} - 0 + 1\begin{vmatrix} 1 & 3 \\ 1 & 1 \end{vmatrix} = 2(1) + 1(-2) = 0.$$The determinant is 0, so the columns must be dependent. Sure enough, column 3 $= \tfrac12$ column 1 $+ \tfrac12$ column 2. Try to find that combination yourself.
Properties
- $\det(AB) = \det A \cdot \det B$ and $\det(A^T) = \det A$.
- $\det(A^{-1}) = \dfrac{1}{\det A}$.
- $A$ is invertible exactly when $\det A \ne 0$.
Cramer's rule
Solve for one variable at a time using determinants.
The rule
If $A$ is $n\times n$ with $\det A \ne 0$, the solution of $A\bm{x} = \bm{b}$ is
$$x_i = \frac{\det A_i(\bm{b})}{\det A}, \qquad i = 1, \dots, n,$$where $A_i(\bm{b})$ is $A$ with column $i$ replaced by $\bm{b}$. In words: to get a variable, swap the right-hand side into that variable's column, take the determinant, and divide by the original determinant.
Solve $2x + y = 4$, $5x + 3y = 11$. Here $\det A = \begin{vmatrix} 2 & 1 \\ 5 & 3 \end{vmatrix} = 1$, so
$$x = \frac{\begin{vmatrix} 4 & 1 \\ 11 & 3 \end{vmatrix}}{1} = 12 - 11 = 1, \qquad y = \frac{\begin{vmatrix} 2 & 4 \\ 5 & 11 \end{vmatrix}}{1} = 22 - 20 = 2.$$This is the same answer as the inverse method in section 3.2 $\checkmark$.
Solve $x + y + z = 6$, $2x + y - z = 1$, $x - y + z = 2$.
$$\det A = \begin{vmatrix} 1 & 1 & 1 \\ 2 & 1 & -1 \\ 1 & -1 & 1 \end{vmatrix} = 1(1 - 1) - 1(2 + 1) + 1(-2 - 1) = -6.$$ $$x = \frac{\begin{vmatrix} 6 & 1 & 1 \\ 1 & 1 & -1 \\ 2 & -1 & 1 \end{vmatrix}}{-6} = \frac{-6}{-6} = 1, \qquad y = \frac{\begin{vmatrix} 1 & 6 & 1 \\ 2 & 1 & -1 \\ 1 & 2 & 1 \end{vmatrix}}{-6} = \frac{-12}{-6} = 2,$$ $$z = \frac{\begin{vmatrix} 1 & 1 & 6 \\ 2 & 1 & 1 \\ 1 & -1 & 2 \end{vmatrix}}{-6} = \frac{-18}{-6} = 3.$$This is the same answer as the row reduction in section 2.2 $\checkmark$. Four $3\times3$ determinants is a lot of arithmetic. Solving one system three ways (row reduction, inverse, Cramer) and getting the same answer is a great confidence builder.
When to use it
Worked examples
- CoreCompute $\begin{vmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 1 & 0 & 6 \end{vmatrix}$.Solution
- Column 1 contains a zero, so expand down column 1 (signs $+,-,+$).
- $\begin{vmatrix} 1 & 2 & 3 \\ 0 & 4 & 5 \\ 1 & 0 & 6 \end{vmatrix} = 1\begin{vmatrix} 4 & 5 \\ 0 & 6 \end{vmatrix} - 0 + 1\begin{vmatrix} 2 & 3 \\ 4 & 5 \end{vmatrix}$.
- $= 1(24 - 0) + 1(10 - 12) = 24 - 2 = 22$.
- CoreCompute $\begin{vmatrix} 1 & 2 & 1 \\ 2 & 5 & 3 \\ 1 & 3 & 4 \end{vmatrix}$ by row reduction.Solution
- Use only row replacements, which don't change the determinant:$$\begin{aligned} &\begin{bmatrix} 1 & 2 & 1 \\ 2 & 5 & 3 \\ 1 & 3 & 4 \end{bmatrix} \xrightarrow{\substack{R_2 - 2R_1 \\ R_3 - R_1}} \begin{bmatrix} 1 & 2 & 1 \\ 0 & 1 & 1 \\ 0 & 1 & 3 \end{bmatrix} \xrightarrow{R_3 - R_2} \begin{bmatrix} 1 & 2 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 2 \end{bmatrix} \end{aligned}$$
- The result is triangular, so its determinant is the product of the diagonal: $1\cdot1\cdot2 = 2$.
- No swaps or scalings were used, so $\det A = 2$.
- Core$A$ is $3\times3$ with $\det A = 5$. Find $\det(2A)$, $\det(A^{-1})$, $\det(A^TA)$.Solution
- $\det(kA) = k^n\det A$ because each of the $n$ rows is scaled: $\det(2A) = 2^3\cdot5 = 40$.
- $\det(A^{-1}) = \dfrac{1}{\det A} = \dfrac15$.
- $\det(A^TA) = \det(A^T)\det(A) = 5\cdot5 = 25$.
- CoreSolve $2x - y = 3,\ x + 3y = 5$ by Cramer's rule.Solution
- Coefficient determinant: $\det A = \begin{vmatrix} 2 & -1 \\ 1 & 3 \end{vmatrix} = 6 + 1 = 7$.
- Replace column 1 by $\bm{b} = (3,5)$: $\begin{vmatrix} 3 & -1 \\ 5 & 3 \end{vmatrix} = 9 + 5 = 14$, so $x = \tfrac{14}{7} = 2$.
- Replace column 2 by $\bm{b}$: $\begin{vmatrix} 2 & 3 \\ 1 & 5 \end{vmatrix} = 10 - 3 = 7$, so $y = \tfrac77 = 1$.
- Check: $2(2) - 1 = 3$ and $2 + 3(1) = 5\;\checkmark$.
- StretchFor which $k$ is $\begin{bmatrix} 1 & 1 & 1 \\ 1 & k & 1 \\ 1 & 1 & k \end{bmatrix}$ invertible?Solution
- $R_2 - R_1$ and $R_3 - R_1$ (no change to the determinant) give $\begin{bmatrix} 1 & 1 & 1 \\ 0 & k-1 & 0 \\ 0 & 0 & k-1 \end{bmatrix}$.
- This is triangular: $\det = 1\cdot(k-1)\cdot(k-1) = (k-1)^2$.
- Invertible exactly when $(k-1)^2 \ne 0$, i.e. $k \ne 1$.
- ApplicationFind the area of the triangle with vertices $(1,1)$, $(4,2)$, $(2,5)$ using a determinant.Solution
- Edge vectors from $(1,1)$: $(4,2) - (1,1) = (3,1)$ and $(2,5) - (1,1) = (1,4)$.
- Parallelogram area: $\left|\begin{vmatrix} 3 & 1 \\ 1 & 4 \end{vmatrix}\right| = |12 - 1| = 11$.
- Triangle area: $\tfrac{11}{2}$.
- $\det(A + B) \ne \det A + \det B$ in general.
- $\det(kA) = k^n\det A$ for an $n\times n$ matrix, not $k\det A$. Every row gets scaled.
- Forgetting the alternating $+\,-\,+$ signs in cofactor expansion.
- Replacing a row with $\bm{b}$ instead of a column.
- Dividing upside down: it's $\det A_i(\bm{b}) / \det A$, with the original determinant on the bottom.
- Using it when $\det A = 0$ (division by zero).
- Sign slips in the $3\times3$ determinants. Check the final answer in the original equations.
Find the volume of the box spanned by $(1,0,0)$, $(1,2,0)$, $(1,1,3)$.
Show answer
Test yourself
- What's the determinant of a rotation matrix, without computing? (1. Rotating doesn't change area.)
- If two rows are identical, what's the determinant? (0. The shape is flat.)
- Why does Cramer's rule need $\det A \ne 0$? Connect it to section 7.1. (A zero determinant means $A$ squashes space flat, so there isn't one unique answer to find.)
- A test asks only for $y$ in a $3\times3$ system. How many determinants do you need? (Two: $\det A$ and $\det A_2(\bm{b})$.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Solve $3x - 2y = 1$, $x + 4y = 5$ by Cramer's rule.
- Can Cramer's rule solve $x + 2y = 4$, $2x + 4y = 8$? Explain.
- Compute $\begin{vmatrix} 2 & 0 & 1 \\ 1 & 3 & -1 \\ 0 & 5 & 4 \end{vmatrix}$.
- Compute $\begin{vmatrix} 1 & 1 & 1 & 1 \\ 1 & 2 & 2 & 2 \\ 1 & 2 & 3 & 3 \\ 1 & 2 & 3 & 4 \end{vmatrix}$.
- Solve $3x + 2y = 7,\ x - y = -1$ by Cramer's rule.
- $A$ and $B$ are $4\times4$ with $\det A = 3$ and $\det B = -2$. Find $\det(AB^{-1})$, $\det(-A)$, $\det(A^TB^2)$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 18 Properties of determinants; 19 Cofactors; 20 Cramer's rule, inverse and volume. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §5.1–5.3.
- RD Sharma (Class 12): exercises in the chapters on Determinants.
Eigenvalues and eigenvectors
- Explain $A\bm{v} = \lambda\bm{v}$ geometrically.
- Find eigenvalues from $\det(A - \lambda I) = 0$ and eigenvectors from the null space.
- Use the trace and determinant as checks.
What does $A = \begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix}$ do to $(1,0)$, $(0,1)$ and $(1,1)$? Which arrows keep their direction?
Show answer
Eigenvalues and eigenvectors
Find the directions a matrix only stretches, then use them as your axes.
Eigenvectors: the directions that don't turn
Most vectors get knocked off their line when a matrix acts on them. A few special ones stay on their own line and just get longer, shorter or flipped. A non-zero vector $\bm{v}$ is an eigenvector of $A$ with eigenvalue $\lambda$ if
$$A\bm{v} = \lambda\bm{v}.$$In words: "$A$ does to $\bm{v}$ what a plain number would." Picture spinning a globe: every point moves except those on the axis. The axis is an eigenvector with eigenvalue 1. Real uses include vibration modes of bridges and buildings, Google's original PageRank, and population models.
Recipe
- Solve the characteristic equation $\det(A - \lambda I) = 0$ for $\lambda$. Why: we need $(A - \lambda I)\bm{v} = \bm{0}$ to have a non-zero solution, so $A - \lambda I$ must squash something, so its determinant is 0.
- For each $\lambda$, solve $(A - \lambda I)\bm{v} = \bm{0}$ by row reduction. The solution set is the eigenspace; its basis vectors are the eigenvectors.
Let $A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}$. Then
$$\det(A - \lambda I) = \begin{vmatrix} 2 - \lambda & 1 \\ 1 & 2 - \lambda \end{vmatrix} = (2 - \lambda)^2 - 1 = 0 \quad\Longrightarrow\quad \lambda = 1 \text{ or } \lambda = 3.$$ $$\begin{aligned} \lambda = 3&: & A - 3I &= \begin{bmatrix} -1 & 1 \\ 1 & -1 \end{bmatrix} &&\Longrightarrow & \bm{v} &= \begin{bmatrix} 1 \\ 1 \end{bmatrix} \\[6pt] \lambda = 1&: & A - I &= \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} &&\Longrightarrow & \bm{v} &= \begin{bmatrix} 1 \\ -1 \end{bmatrix} \end{aligned}$$Check: $A\begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} 3 \\ 3 \end{bmatrix} = 3\begin{bmatrix} 1 \\ 1 \end{bmatrix}$ $\checkmark$ and $A\begin{bmatrix} 1 \\ -1 \end{bmatrix} = \begin{bmatrix} 1 \\ -1 \end{bmatrix}$ $\checkmark$.
Quick sanity check: the eigenvalues add up to the trace (the diagonal sum, $2 + 2 = 4 = 1 + 3$) and multiply to the determinant ($3 = 1\cdot3$).
Worked examples
- CoreFind the eigenvalues and eigenvectors of $\begin{bmatrix} 3 & 1 \\ 0 & 2 \end{bmatrix}$.Solution
- $\det(A - \lambda I) = \begin{vmatrix} 3-\lambda & 1 \\ 0 & 2-\lambda \end{vmatrix} = (3-\lambda)(2-\lambda)$, so $\lambda = 3$ or $\lambda = 2$.
- $\lambda = 3$: $A - 3I = \begin{bmatrix} 0 & 1 \\ 0 & -1 \end{bmatrix}$ forces $y = 0$, so $\bm{v} = (1,0)$.
- $\lambda = 2$: $A - 2I = \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix}$ gives $x + y = 0$, so $\bm{v} = (1,-1)$.
- Check: $A(1,-1) = (3 - 1,\ -2) = 2(1,-1)\;\checkmark$.
- CoreFind the eigenvalues and eigenvectors of $A = \begin{bmatrix} 5 & -2 \\ 6 & -2 \end{bmatrix}$.Solution
- Characteristic polynomial: $(5-\lambda)(-2-\lambda) - (-2)(6) = \lambda^2 - 3\lambda - 10 + 12 = \lambda^2 - 3\lambda + 2$.
- Factor: $(\lambda - 1)(\lambda - 2)$, so $\lambda = 1, 2$. (Check: sum 3 = trace, product 2 = det.)
- $\lambda = 1$: $A - I = \begin{bmatrix} 4 & -2 \\ 6 & -3 \end{bmatrix}$ gives $2x = y$, so $\bm{v} = (1,2)$.
- $\lambda = 2$: $A - 2I = \begin{bmatrix} 3 & -2 \\ 6 & -4 \end{bmatrix}$ gives $3x = 2y$, so $\bm{v} = (2,3)$.
- Check: $A(1,2) = (1,2)$ and $A(2,3) = (4,6) = 2(2,3)\;\checkmark$.
- CoreFind the eigenvalues of $\begin{bmatrix} 2 & 0 & 0 \\ 1 & 3 & 0 \\ -1 & 1 & 1 \end{bmatrix}$ and an eigenvector for $\lambda = 3$.Solution
- The matrix is lower triangular, so the eigenvalues are the diagonal entries: 2, 3, 1.
- $A - 3I = \begin{bmatrix} -1 & 0 & 0 \\ 1 & 0 & 0 \\ -1 & 1 & -2 \end{bmatrix}$.
- Row 1 gives $x = 0$. Row 3 then gives $y - 2z = 0$, so $y = 2z$. Take $z = 1$: $\bm{v} = (0,2,1)$.
- Check: $A(0,2,1) = (0,\ 6,\ 0 + 2 + 1) = 3(0,2,1)\;\checkmark$.
- StretchIs $(1,1,1)$ an eigenvector of $\begin{bmatrix} 1 & 2 & 3 \\ 3 & 2 & 1 \\ 2 & 2 & 2 \end{bmatrix}$?Solution
- Multiply: $A(1,1,1) = (1+2+3,\ 3+2+1,\ 2+2+2) = (6,6,6)$.
- This is $6(1,1,1)$, so yes: $(1,1,1)$ is an eigenvector with $\lambda = 6$. (Each row sums to 6.)
- ExtraFind all eigenvalues and eigenvectors of $\begin{bmatrix} 2 & 0 & 0 \\ 0 & 1 & 1 \\ 0 & 1 & 1 \end{bmatrix}$.Solution
- The first coordinate is separate: $A\bm{e}_1 = 2\bm{e}_1$, so $\lambda = 2$ with $(1,0,0)$.
- The lower block $\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}$ has $\det\left(\begin{bmatrix} 1-\lambda & 1 \\ 1 & 1-\lambda \end{bmatrix}\right) = (1-\lambda)^2 - 1 = \lambda(\lambda - 2)$: eigenvalues 2 and 0.
- $\lambda = 2$ in the block gives $(1,1)$, so $(0,1,1)$ in $\R^3$. $\lambda = 0$ gives $(0,1,-1)$.
- So $\lambda = 2$ (twice) with eigenvectors $(1,0,0)$, $(0,1,1)$, and $\lambda = 0$ with $(0,1,-1)$. Check: trace $4 = 2 + 2 + 0\;\checkmark$.
- Giving $\bm{v} = \bm{0}$ as an eigenvector. Zero never counts.
- Thinking the eigenvector is unique. Any non-zero multiple also works; $(2, 2)$ is as good as $(1, 1)$.
- Getting only the trivial solution when solving for $\bm{v}$. That means $\lambda$ is wrong; recheck step 1.
- Assuming every matrix is diagonalizable, or that every matrix has real eigenvalues. A $90^\circ$ rotation turns every direction, so it has no real eigenvectors at all.
If $A\bm{v} = 2\bm{v}$, what are $A^2\bm{v}$ and $A^{-1}\bm{v}$?
Show answer
Test yourself
- What are the eigenvalues of a diagonal matrix? (The diagonal entries. Nothing to compute.)
- Projection onto a line: what are its eigenvalues? (1 for vectors on the line, 0 for vectors perpendicular to it.)
- If 0 is an eigenvalue, is $A$ invertible? (No. Something non-zero gets squashed to $\bm{0}$.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Find the eigenvalues and eigenvectors of $\begin{bmatrix} 4 & -2 \\ 1 & 1 \end{bmatrix}$.
- Show that $\begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}$ has no real eigenvalues. What does it do geometrically?
- Find the eigenvalues and an eigenvector for each of $\begin{bmatrix} 1 & 0 & 0 \\ 0 & 2 & 1 \\ 0 & 0 & 3 \end{bmatrix}$.
- Show that $A$ and $A^T$ have the same eigenvalues.
Further practice
- Strang, MIT 18.06 (OCW): lecture 21 Eigenvalues and eigenvectors. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §6.1.
Diagonalization
- Write $A = PDP^{-1}$ and check it with $AP = PD$.
- Decide whether a matrix is diagonalizable, including with repeated eigenvalues.
- Use diagonalization to compute powers and long-term behaviour.
Compute $\begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix}^5$. Now imagine computing $\begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}^5$.
Show answer
Diagonalization
Diagonalization: switching to the matrix's favourite axes
Use the eigenvectors as your coordinate axes, and the matrix does nothing but stretch along each axis. In those coordinates it becomes a diagonal matrix, the simplest kind there is:
$$A = PDP^{-1}, \qquad P = \begin{bmatrix} \bm{v}_1 & \bm{v}_2 & \cdots & \bm{v}_n \end{bmatrix}, \qquad D = \begin{bmatrix} \lambda_1 & & \\ & \ddots & \\ & & \lambda_n \end{bmatrix},$$with the eigenvalues in $D$ in the same order as their eigenvectors in $P$.
Why bother? Powers. Computing $A^{100}$ directly takes 99 matrix multiplications. With diagonalization, $A^{100} = PD^{100}P^{-1}$, and powering a diagonal matrix just powers each diagonal entry. Engineers use this to predict where a system ends up after many steps.
When can you diagonalize?
- An $n\times n$ matrix is diagonalizable exactly when it has $n$ independent eigenvectors (enough to fill $P$).
- $n$ distinct eigenvalues: guaranteed yes.
- A repeated eigenvalue: check. If $\lambda$ is a root of multiplicity $k$, you need $k$ independent eigenvectors for it.
- The classic "no": the shear $\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}$. $\lambda = 1$ twice, but only one eigenvector direction, $(1, 0)$.
Let $A = \begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}$. Then $\det(A - \lambda I) = \lambda^2 - 7\lambda + 10 = (\lambda - 5)(\lambda - 2)$.
$$\begin{aligned} \lambda = 5&: & A - 5I &= \begin{bmatrix} -1 & 1 \\ 2 & -2 \end{bmatrix} &&\Longrightarrow & \bm{v}_1 &= \begin{bmatrix} 1 \\ 1 \end{bmatrix} \\[6pt] \lambda = 2&: & A - 2I &= \begin{bmatrix} 2 & 1 \\ 2 & 1 \end{bmatrix} &&\Longrightarrow & \bm{v}_2 &= \begin{bmatrix} 1 \\ -2 \end{bmatrix} \end{aligned}$$ $$P = \begin{bmatrix} 1 & 1 \\ 1 & -2 \end{bmatrix}, \qquad D = \begin{bmatrix} 5 & 0 \\ 0 & 2 \end{bmatrix}, \qquad P^{-1} = \frac13\begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix}.$$Check:
$$PDP^{-1} = \begin{bmatrix} 5 & 2 \\ 5 & -4 \end{bmatrix}\cdot\frac13\begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix} = \frac13\begin{bmatrix} 12 & 3 \\ 6 & 9 \end{bmatrix} = \begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix} = A \;\checkmark$$Now any power is easy. For example,
$$A^2 = PD^2P^{-1} = \begin{bmatrix} 1 & 1 \\ 1 & -2 \end{bmatrix}\begin{bmatrix} 25 & 0 \\ 0 & 4 \end{bmatrix}\cdot\frac13\begin{bmatrix} 2 & 1 \\ 1 & -1 \end{bmatrix} = \frac13\begin{bmatrix} 54 & 21 \\ 42 & 33 \end{bmatrix} = \begin{bmatrix} 18 & 7 \\ 14 & 11 \end{bmatrix},$$the same as multiplying $A\cdot A$ directly $\checkmark$. In general $A^k = P\begin{bmatrix} 5^k & 0 \\ 0 & 2^k \end{bmatrix}P^{-1}$: a formula for every power at once.
Worked examples
- CoreDiagonalize $A = \begin{bmatrix} 5 & -2 \\ 6 & -2 \end{bmatrix}$ (eigenvalues from Lecture 10) and check.Solution
- From Lecture 10: $\lambda_1 = 1,\ \bm{v}_1 = (1,2)$ and $\lambda_2 = 2,\ \bm{v}_2 = (2,3)$.
- Put the eigenvectors in as columns and the eigenvalues in the same order: $P = \begin{bmatrix} 1 & 2 \\ 2 & 3 \end{bmatrix},\ D = \begin{bmatrix} 1 & 0 \\ 0 & 2 \end{bmatrix}$.
- $\det P = 3 - 4 = -1 \ne 0$, so $P$ is invertible and $A = PDP^{-1}$.
- Check without inverting: $AP = \big[\,A\bm{v}_1\ \ A\bm{v}_2\,\big] = \begin{bmatrix} 1 & 4 \\ 2 & 6 \end{bmatrix}$ and $PD = \big[\,1\bm{v}_1\ \ 2\bm{v}_2\,\big] = \begin{bmatrix} 1 & 4 \\ 2 & 6 \end{bmatrix}\;\checkmark$.
- CoreUse the previous problem to find a formula for $A^k$ and compute $A^{10}$.Solution
- $P^{-1} = \tfrac{1}{-1}\begin{bmatrix} 3 & -2 \\ -2 & 1 \end{bmatrix} = \begin{bmatrix} -3 & 2 \\ 2 & -1 \end{bmatrix}$.
- $A^k = PD^kP^{-1}$ with $D^k = \begin{bmatrix} 1 & 0 \\ 0 & 2^k \end{bmatrix}$. First $PD^k = \begin{bmatrix} 1 & 2\cdot2^k \\ 2 & 3\cdot2^k \end{bmatrix}$.
- Then multiply by $P^{-1}$: $A^k = \begin{bmatrix} -3 + 4\cdot2^k & 2 - 2\cdot2^k \\ -6 + 6\cdot2^k & 4 - 3\cdot2^k \end{bmatrix}$.
- With $2^{10} = 1024$: $A^{10} = \begin{bmatrix} 4093 & -2046 \\ 6138 & -3068 \end{bmatrix}$.
- Check $k = 1$: $\begin{bmatrix} -3+8 & 2-4 \\ -6+12 & 4-6 \end{bmatrix} = \begin{bmatrix} 5 & -2 \\ 6 & -2 \end{bmatrix}\;\checkmark$.
- CoreIs $\begin{bmatrix} 2 & 1 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{bmatrix}$ diagonalizable?Solution
- Upper triangular, so the eigenvalues are 2, 2, 3.
- $A - 2I = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}$ has pivots in columns 2 and 3, so its rank is 2 and its nullity is 1.
- $\lambda = 2$ appears twice but gives only one independent eigenvector. With $\lambda = 3$ that's only 2 eigenvectors in total, not 3: not diagonalizable.
- CoreShow $\begin{bmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 1 & 1 & 3 \end{bmatrix}$ is diagonalizable and find $P$.Solution
- Lower triangular, so the eigenvalues are 2, 2, 3.
- $A - 2I = \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 1 & 1 & 1 \end{bmatrix}$ has rank 1, so the eigenspace is $x + y + z = 0$, which is 2-dimensional. Basis: $(1,-1,0),\ (1,0,-1)$.
- $A - 3I = \begin{bmatrix} -1 & 0 & 0 \\ 0 & -1 & 0 \\ 1 & 1 & 0 \end{bmatrix}$ forces $x = y = 0$, so $\bm{v} = (0,0,1)$.
- Three independent eigenvectors, so diagonalizable: $P = \begin{bmatrix} 1 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & -1 & 1 \end{bmatrix},\ D = \begin{bmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{bmatrix}$.
- StretchEach year 10% of city residents move to the suburbs and 20% of suburban residents move to the city: $A = \begin{bmatrix} \tfrac{9}{10} & \tfrac{1}{5} \\ \tfrac{1}{10} & \tfrac{4}{5} \end{bmatrix}$. What is the long-run split?Solution
- The long-run state satisfies $A\bm{x} = \bm{x}$, i.e. $(A - I)\bm{x} = \bm{0}$.
- $A - I = \begin{bmatrix} -\tfrac{1}{10} & \tfrac{1}{5} \\ \tfrac{1}{10} & -\tfrac{1}{5} \end{bmatrix}$ gives $-0.1x + 0.2y = 0$, so $x = 2y$: $\bm{x} = (2,1)$.
- Scale so the shares add to 1: $(\tfrac23, \tfrac13)$.
- The other eigenvalue is $\text{trace} - 1 = 1.7 - 1 = 0.7$. Its component shrinks like $0.7^k \to 0$, so the population settles at $\tfrac23$ city, $\tfrac13$ suburbs.
- ExtraFind a formula for $\begin{bmatrix} 1 & 2 \\ 2 & 1 \end{bmatrix}^n$.Solution
- Eigenvalues: $(1-\lambda)^2 - 4 = 0 \Rightarrow \lambda = 3, -1$, with eigenvectors $(1,1)$ and $(1,-1)$.
- $P = \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix},\ D = \begin{bmatrix} 3 & 0 \\ 0 & -1 \end{bmatrix},\ P^{-1} = \tfrac12\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$.
- $A^n = PD^nP^{-1} = \tfrac12\begin{bmatrix} 3^n & (-1)^n \\ 3^n & -(-1)^n \end{bmatrix}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} = \tfrac12\begin{bmatrix} 3^n + (-1)^n & 3^n - (-1)^n \\ 3^n - (-1)^n & 3^n + (-1)^n \end{bmatrix}$.
- Check $n = 2$: $\tfrac12\begin{bmatrix} 10 & 8 \\ 8 & 10 \end{bmatrix} = \begin{bmatrix} 5 & 4 \\ 4 & 5 \end{bmatrix} = A^2\;\checkmark$.
- Mismatched order: the first column of $P$ must go with the first diagonal entry of $D$, and so on.
- Assuming every matrix is diagonalizable, or that every matrix has real eigenvalues. A $90^\circ$ rotation turns every direction, so it has no real eigenvectors at all.
A $3\times3$ matrix has eigenvalues 1, 2, 3. Is it diagonalizable?
Show answer
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Diagonalize $\begin{bmatrix} 1 & 2 \\ 2 & 1 \end{bmatrix}$.
- Is $\begin{bmatrix} 2 & 1 \\ 0 & 2 \end{bmatrix}$ diagonalizable?
- Diagonalize $A = \begin{bmatrix} 4 & -2 \\ 1 & 1 \end{bmatrix}$ (from Lecture 10) and check $AP = PD$.
- Use the previous answer to compute $A^5$.
- Which are diagonalizable: $\begin{bmatrix} 3 & 1 \\ 0 & 3 \end{bmatrix}$, $\begin{bmatrix} 3 & 0 \\ 0 & 3 \end{bmatrix}$?
- A population moves between two regions with $A = \begin{bmatrix} \tfrac{4}{5} & \tfrac{3}{10} \\ \tfrac{1}{5} & \tfrac{7}{10} \end{bmatrix}$. Find the long-run split.
Further practice
- Strang, MIT 18.06 (OCW): lecture 22 Diagonalization and powers of A; 24 Markov matrices. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §6.2.
Orthonormal bases, Gram–Schmidt and projections
- Recognise orthogonal and orthonormal sets and find coordinates by dot products.
- Run the Gram–Schmidt process.
- Project onto a subspace and use orthogonal matrices ($Q^{-1} = Q^T$).
Write $(3,5)$ in the basis $(1,1)$, $(1,-1)$ two ways: by solving a system, and by computing $\frac{\bm{x}\cdot\bm{v}_i}{\bm{v}_i\cdot\bm{v}_i}$.
Show answer
Orthogonal and orthonormal bases
Bases where every direction is at right angles to the others, like the lines on graph paper.
The idea
- A set $\{\bm{v}_1, \dots, \bm{v}_k\}$ is orthogonal if $\bm{v}_i\cdot\bm{v}_j = 0$ whenever $i \ne j$.
- It is orthonormal if, in addition, every $\|\bm{v}_i\| = 1$.
- An orthogonal set of non-zero vectors is automatically independent. Perpendicular directions can't be built from each other.
Why they're so convenient: in an ordinary basis, finding coordinates means solving a system. In an orthogonal basis, each coordinate is a single projection:
$$\bm{x} = c_1\bm{v}_1 + \cdots + c_n\bm{v}_n, \qquad c_i = \frac{\bm{x}\cdot\bm{v}_i}{\bm{v}_i\cdot\bm{v}_i} = \frac{\bm{x}\cdot\bm{v}_i}{\|\bm{v}_i\|^2}.$$If the basis is orthonormal, this is simply $c_i = \bm{x}\cdot\bm{v}_i$.
$\bm{v}_1 = (1, 1)$ and $\bm{v}_2 = (1, -1)$ are orthogonal, since $\bm{v}_1\cdot\bm{v}_2 = 0$. Write $\bm{x} = (3, 5)$ in this basis:
$$c_1 = \frac{3 + 5}{2} = 4, \qquad c_2 = \frac{3 - 5}{2} = -1, \qquad 4\begin{bmatrix} 1 \\ 1 \end{bmatrix} - \begin{bmatrix} 1 \\ -1 \end{bmatrix} = \begin{bmatrix} 3 \\ 5 \end{bmatrix} \;\checkmark$$The Gram–Schmidt process
Given any basis $\{\bm{x}_1, \bm{x}_2, \dots\}$, Gram–Schmidt turns it into an orthogonal basis of the same space. The idea: keep the first vector; from each next vector, subtract its shadows on the ones you've already fixed. What's left is perpendicular to all of them.
$$\begin{aligned} \bm{v}_1 &= \bm{x}_1 \\ \bm{v}_2 &= \bm{x}_2 - \frac{\bm{x}_2\cdot\bm{v}_1}{\|\bm{v}_1\|^2}\bm{v}_1 \\ \bm{v}_3 &= \bm{x}_3 - \frac{\bm{x}_3\cdot\bm{v}_1}{\|\bm{v}_1\|^2}\bm{v}_1 - \frac{\bm{x}_3\cdot\bm{v}_2}{\|\bm{v}_2\|^2}\bm{v}_2 \end{aligned}$$and so on. Divide each $\bm{v}_i$ by its length at the end if you need an orthonormal basis.
Apply Gram–Schmidt to $\bm{x}_1 = (1, 1, 0)$ and $\bm{x}_2 = (1, 0, 1)$.
$$\bm{v}_1 = \begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix}, \qquad \bm{v}_2 = \begin{bmatrix} 1 \\ 0 \\ 1 \end{bmatrix} - \frac{1}{2}\begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 1/2 \\ -1/2 \\ 1 \end{bmatrix} \;\xrightarrow{\;\times 2\;}\; \begin{bmatrix} 1 \\ -1 \\ 2 \end{bmatrix}.$$Check: $\bm{v}_1\cdot\bm{v}_2 = 1 - 1 + 0 = 0$ $\checkmark$. The orthonormal basis is
$$\bm{q}_1 = \frac{1}{\sqrt2}\begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix}, \qquad \bm{q}_2 = \frac{1}{\sqrt6}\begin{bmatrix} 1 \\ -1 \\ 2 \end{bmatrix}.$$Scaling a vector mid-way (like the $\times2$ here) is allowed. It doesn't change the direction, and it keeps the arithmetic clean.
Orthogonal matrices
A square matrix $Q$ whose columns are orthonormal is called orthogonal. Its big perk:
$$Q^TQ = I, \qquad\text{so}\qquad Q^{-1} = Q^T.$$The inverse comes for free. Rotations and reflections are orthogonal matrices: they keep every length and angle the same, and $\det Q = \pm1$.
Projecting onto a subspace
If $\{\bm{v}_1, \dots, \bm{v}_k\}$ is an orthogonal basis of a subspace $U$, then
$$\operatorname{proj}_U\bm{x} = \frac{\bm{x}\cdot\bm{v}_1}{\|\bm{v}_1\|^2}\bm{v}_1 + \cdots + \frac{\bm{x}\cdot\bm{v}_k}{\|\bm{v}_k\|^2}\bm{v}_k.$$The leftover $\bm{x} - \operatorname{proj}_U\bm{x}$ is perpendicular to all of $U$. The set of all vectors perpendicular to $U$ is the orthogonal complement $U^\perp$.
Let $U = \operatorname{span}\{(1, 1, 0), (1, -1, 2)\}$ (the orthogonal basis found above) and $\bm{x} = (1, 2, 3)$.
$$\operatorname{proj}_U\bm{x} = \frac{3}{2}\begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix} + \frac{5}{6}\begin{bmatrix} 1 \\ -1 \\ 2 \end{bmatrix} = \begin{bmatrix} 7/3 \\ 2/3 \\ 5/3 \end{bmatrix}, \qquad \bm{x} - \operatorname{proj}_U\bm{x} = \begin{bmatrix} -4/3 \\ 4/3 \\ 4/3 \end{bmatrix}.$$Check: the leftover dotted with $(1, 1, 0)$ gives $-\tfrac43 + \tfrac43 = 0$ $\checkmark$, and dotted with $(1, -1, 2)$ gives $-\tfrac43 - \tfrac43 + \tfrac83 = 0$ $\checkmark$.
The leftover points along $(-1, 1, 1)$, and so does $(1, 1, 0)\times(1, -1, 2) = (2, -2, -2)$: that's the plane's normal. $U^\perp$ is the line in that direction.
Worked examples
- CoreShow $\{(1,1,1),(1,-1,0),(1,1,-2)\}$ is orthogonal, and write $(3,1,2)$ in this basis.Solution
- Pairwise dot products: $(1,1,1)\cdot(1,-1,0) = 0$, $(1,1,1)\cdot(1,1,-2) = 0$, $(1,-1,0)\cdot(1,1,-2) = 0$. Orthogonal.
- Each coordinate is $c_i = \dfrac{\bm{x}\cdot\bm{v}_i}{\|\bm{v}_i\|^2}$ with $\bm{x} = (3,1,2)$: $c_1 = \tfrac{6}{3} = 2$, $c_2 = \tfrac{2}{2} = 1$, $c_3 = \tfrac{3 + 1 - 4}{6} = 0$.
- Check: $2(1,1,1) + 1(1,-1,0) + 0 = (3,1,2)\;\checkmark$.
- CoreApply Gram–Schmidt to $(1,0,1)$, $(1,1,1)$, $(0,1,2)$.Solution
- $\bm{v}_1 = \bm{x}_1 = (1,0,1)$, with $\|\bm{v}_1\|^2 = 2$.
- $\bm{x}_2\cdot\bm{v}_1 = 2$, so $\bm{v}_2 = (1,1,1) - \tfrac22(1,0,1) = (0,1,0)$, with $\|\bm{v}_2\|^2 = 1$.
- $\bm{x}_3\cdot\bm{v}_1 = 2$ and $\bm{x}_3\cdot\bm{v}_2 = 1$, so $\bm{v}_3 = (0,1,2) - \tfrac22(1,0,1) - \tfrac11(0,1,0) = (-1,0,1)$.
- Check: $\bm{v}_1\cdot\bm{v}_2 = 0,\ \bm{v}_1\cdot\bm{v}_3 = -1 + 1 = 0,\ \bm{v}_2\cdot\bm{v}_3 = 0\;\checkmark$.
- CoreProject $(1,2,3)$ onto $U = \operatorname{span}\{(1,0,1),(0,1,0)\}$ and find the distance to $U$.Solution
- The spanning vectors are orthogonal: $(1,0,1)\cdot(0,1,0) = 0$. So we can project onto each and add.
- Coefficients: $\tfrac{(1,2,3)\cdot(1,0,1)}{2} = \tfrac42 = 2$ and $\tfrac{(1,2,3)\cdot(0,1,0)}{1} = 2$.
- $\operatorname{proj}_U(1,2,3) = 2(1,0,1) + 2(0,1,0) = (2,2,2)$.
- Leftover: $(1,2,3) - (2,2,2) = (-1,0,1)$, perpendicular to both spanning vectors $\checkmark$. Distance $\|(-1,0,1)\| = \sqrt2$.
- StretchIs $Q = \begin{bmatrix} \tfrac{3}{5} & -\tfrac{4}{5} \\ \tfrac{4}{5} & \tfrac{3}{5} \end{bmatrix}$ orthogonal? What is $Q^{-1}$, and what does $Q$ do geometrically?Solution
- Columns $\bm{c}_1 = (\tfrac35, \tfrac45)$, $\bm{c}_2 = (-\tfrac45, \tfrac35)$. Lengths: $\tfrac{9}{25} + \tfrac{16}{25} = 1$ for each. Dot product: $-\tfrac{12}{25} + \tfrac{12}{25} = 0$.
- Orthonormal columns, so $Q$ is orthogonal and $Q^{-1} = Q^T = \begin{bmatrix} \tfrac{3}{5} & \tfrac{4}{5} \\ -\tfrac{4}{5} & \tfrac{3}{5} \end{bmatrix}$.
- Compare with $\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}$: $\cos\theta = \tfrac35,\ \sin\theta = \tfrac45$. It's a rotation by $\theta \approx 53.1^\circ$.
- ExtraFind the matrix $P$ that projects onto the line through $(1,2,2)$, and use it to project $(1,0,0)$.Solution
- For a direction $\bm{v}$, $\operatorname{proj}_{\bm{v}}\bm{x} = \dfrac{\bm{v}\bm{v}^T}{\bm{v}^T\bm{v}}\bm{x}$, so $P = \dfrac{\bm{v}\bm{v}^T}{\bm{v}^T\bm{v}}$.
- $\bm{v}^T\bm{v} = 9$ and $\bm{v}\bm{v}^T = \begin{bmatrix} 1 & 2 & 2 \\ 2 & 4 & 4 \\ 2 & 4 & 4 \end{bmatrix}$, so $P = \tfrac19\begin{bmatrix} 1 & 2 & 2 \\ 2 & 4 & 4 \\ 2 & 4 & 4 \end{bmatrix}$.
- $P(1,0,0) = \tfrac19(1,2,2)$. Check with the dot-product formula: $\tfrac{(1,0,0)\cdot(1,2,2)}{9}(1,2,2) = \tfrac19(1,2,2)\;\checkmark$.
- Also $P^2 = P$: projecting twice changes nothing.
- In Gram–Schmidt, projecting onto the original $\bm{x}$'s instead of the new $\bm{v}$'s. Always subtract shadows on the vectors you've already fixed.
- Using the coordinate shortcut $c_i = \dfrac{\bm{x}\cdot\bm{v}_i}{\|\bm{v}_i\|^2}$ with a basis that isn't orthogonal. It only works when the basis is orthogonal.
- Calling a matrix orthogonal when its columns are perpendicular but not of length 1.
$Q$ is a $3\times3$ orthogonal matrix. What can $\det Q$ be?
Show answer
Test yourself
- Why must an orthogonal set of non-zero vectors be independent? (Dot $c_1\bm{v}_1 + \cdots + c_k\bm{v}_k = \bm{0}$ with $\bm{v}_1$: everything else vanishes, leaving $c_1\|\bm{v}_1\|^2 = 0$.)
- What's the inverse of a rotation matrix, without any computing? (Its transpose. Or: rotate back.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Apply Gram–Schmidt to $(3, 4)$, $(1, 0)$, then make the result orthonormal.
- Is $Q = \dfrac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$ orthogonal? What is $Q^{-1}$?
- Show that $\{(1,2,-1),(1,0,1),(1,-1,-1)\}$ is orthogonal and write $(2,1,0)$ in this basis.
- Apply Gram–Schmidt to $(1,1,0)$, $(0,1,1)$, $(1,0,1)$.
- Project $(1,1,1)$ onto $U = \operatorname{span}\{(1,2,0),(-2,1,0)\}$ and find the distance to $U$.
- Find an orthonormal basis of the plane $x + y + z = 0$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 14 Orthogonal vectors and subspaces; 15 Projections onto subspaces; 17 Orthogonal matrices and Gram–Schmidt. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §4.1, 4.2, 4.4.
Symmetric matrices and quadratic forms
- State the Principal Axes (Spectral) Theorem.
- Orthogonally diagonalize a symmetric matrix as $QDQ^T$.
- Write a quadratic form as $\bm{x}^TA\bm{x}$ and classify it by eigenvalues.
Find the eigenvectors of $\begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}$ (from Lecture 10). What do you notice about them?
Show answer
Symmetric matrices
Matrices that are pure stretching along perpendicular axes.
The idea
A matrix is symmetric if $A^T = A$: it's a mirror image of itself across the main diagonal. $\begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}$ is symmetric; $\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$ isn't.
They come up whenever "the effect of $i$ on $j$ equals the effect of $j$ on $i$": stiffness matrices in structures, stress in materials, covariance in data, distance tables.
The Principal Axes (Spectral) Theorem
For a real symmetric matrix $A$:
- All its eigenvalues are real.
- Eigenvectors for different eigenvalues are automatically orthogonal.
- $A$ is orthogonally diagonalizable: $A = QDQ^T$ with $Q$ orthogonal. Since $Q^{-1} = Q^T$, there's no inverse to compute.
In plain English: every symmetric matrix just stretches space along some set of perpendicular axes. Those axes are its eigenvectors.
Recipe for $A = QDQ^T$
- Find the eigenvalues and eigenvectors as usual.
- Normalize the eigenvectors to length 1. (If an eigenvalue repeats, run Gram–Schmidt on its eigenvectors first.)
- Put them in $Q$ as columns, and the eigenvalues in $D$ in the same order.
For $A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}$, section 8.1 gave $\lambda = 3$ with $\bm{v} = (1, 1)$ and $\lambda = 1$ with $\bm{v} = (1, -1)$. These are perpendicular, as promised. Normalizing,
$$Q = \frac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}, \qquad D = \begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}.$$Check:
$$QDQ^T = \frac12\begin{bmatrix} 3 & 1 \\ 3 & -1 \end{bmatrix}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix} = \frac12\begin{bmatrix} 4 & 2 \\ 2 & 4 \end{bmatrix} = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} \;\checkmark$$Quadratic forms
An expression like $2x^2 + 2xy + 2y^2$ can be written as $\bm{x}^TA\bm{x}$ with a symmetric $A$. The squared terms go on the diagonal, and the $xy$ coefficient is split in half between the two off-diagonal entries:
$$2x^2 + 2xy + 2y^2 = \begin{bmatrix} x & y \end{bmatrix}\begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix}.$$Switching to the eigenvector axes removes the cross term: the expression becomes $3u^2 + v^2$. If every eigenvalue is positive, the form is positive definite: it's positive for every $\bm{x} \ne \bm{0}$, and its level curves are ellipses like the one above.
Worked examples
- CoreOrthogonally diagonalize $\begin{bmatrix} 1 & 2 \\ 2 & -2 \end{bmatrix}$.Solution
- Characteristic polynomial: $(1-\lambda)(-2-\lambda) - 4 = \lambda^2 + \lambda - 6 = (\lambda - 2)(\lambda + 3)$.
- $\lambda = 2$: $A - 2I = \begin{bmatrix} -1 & 2 \\ 2 & -4 \end{bmatrix}$ gives $x = 2y$, so $(2,1)$.
- $\lambda = -3$: $A + 3I = \begin{bmatrix} 4 & 2 \\ 2 & 1 \end{bmatrix}$ gives $2x + y = 0$, so $(1,-2)$.
- These are orthogonal ($2 - 2 = 0$). Each has length $\sqrt5$; normalize and use them as columns: $Q = \tfrac{1}{\sqrt5}\begin{bmatrix} 2 & 1 \\ 1 & -2 \end{bmatrix},\ D = \begin{bmatrix} 2 & 0 \\ 0 & -3 \end{bmatrix}$.
- CoreOrthogonally diagonalize $\begin{bmatrix} 2 & 0 & 0 \\ 0 & 3 & 1 \\ 0 & 1 & 3 \end{bmatrix}$.Solution
- The first coordinate is separate: $A\bm{e}_1 = 2\bm{e}_1$, so $(1,0,0)$ is an eigenvector for $\lambda = 2$.
- The lower-right block $\begin{bmatrix} 3 & 1 \\ 1 & 3 \end{bmatrix}$ has eigenvalues 4 (vector $(1,1)$) and 2 (vector $(1,-1)$). In $\R^3$: $(0,1,1)$ for 4 and $(0,1,-1)$ for 2.
- For $\lambda = 2$ the eigenvectors $(1,0,0)$ and $(0,1,-1)$ are already orthogonal.
- Normalize: $Q = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \tfrac{1}{\sqrt2} & \tfrac{1}{\sqrt2} \\ 0 & -\tfrac{1}{\sqrt2} & \tfrac{1}{\sqrt2} \end{bmatrix},\ D = \begin{bmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 4 \end{bmatrix}$.
- CoreWrite $q = 3x^2 - 4xy + 6y^2$ as $\bm{x}^TA\bm{x}$ and classify it.Solution
- Squares on the diagonal, half the $xy$ coefficient off the diagonal: $A = \begin{bmatrix} 3 & -2 \\ -2 & 6 \end{bmatrix}$.
- Characteristic polynomial: $\lambda^2 - 9\lambda + (18 - 4) = (\lambda - 2)(\lambda - 7)$.
- Both eigenvalues are positive: positive definite.
- Eigenvectors: $\lambda = 2$ gives $(2,1)$ (from $x = 2y$), $\lambda = 7$ gives $(1,-2)$. Along these axes $q = 2u^2 + 7v^2$.
- StretchIdentify the curve $5x^2 - 4xy + 8y^2 = 36$.Solution
- $A = \begin{bmatrix} 5 & -2 \\ -2 & 8 \end{bmatrix}$. Characteristic polynomial $\lambda^2 - 13\lambda + 36 = (\lambda - 4)(\lambda - 9)$.
- Eigenvectors: $\lambda = 4$ gives $(2,1)$, $\lambda = 9$ gives $(1,-2)$.
- In those coordinates the equation is $4u^2 + 9v^2 = 36$. Divide by 36: $\dfrac{u^2}{9} + \dfrac{v^2}{4} = 1$.
- An ellipse with semi-axes 3 (along $(2,1)$) and 2 (along $(1,-2)$).
- ApplicationFind the largest and smallest values of $q = 3x^2 + 2xy + 3y^2$ on the unit circle $x^2 + y^2 = 1$, and where they occur.Solution
- $q = \bm{x}^TA\bm{x}$ with $A = \begin{bmatrix} 3 & 1 \\ 1 & 3 \end{bmatrix}$, whose eigenvalues are 4 (along $(1,1)$) and 2 (along $(1,-1)$).
- In eigenvector coordinates $q = 4u^2 + 2v^2$ with $u^2 + v^2 = 1$, so $q$ ranges from 2 to 4.
- Maximum 4 at $\pm\tfrac{1}{\sqrt2}(1,1)$; minimum 2 at $\pm\tfrac{1}{\sqrt2}(1,-1)$. Check: at $\tfrac{1}{\sqrt2}(1,1)$, $q = \tfrac32 + 1 + \tfrac32 = 4\;\checkmark$.
- Forgetting to normalize the eigenvectors, so $Q$ isn't orthogonal and $Q^T$ isn't its inverse.
- Putting the whole $xy$ coefficient in both off-diagonal entries instead of half in each.
- With a repeated eigenvalue, assuming its eigenvectors are already perpendicular. Only eigenvectors from different eigenvalues are guaranteed to be.
Classify $q = x^2 + 4xy + y^2$.
Show answer
Test yourself
- Can a $90^\circ$ rotation matrix be symmetric? (No. Symmetric matrices have real eigenvalues, and a $90^\circ$ rotation has none.)
- Is $A^TA$ always symmetric? (Yes, since $(A^TA)^T = A^TA$. It appears again in least squares.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Orthogonally diagonalize $\begin{bmatrix} 5 & 2 \\ 2 & 2 \end{bmatrix}$.
- Orthogonally diagonalize $\begin{bmatrix} 6 & 2 \\ 2 & 3 \end{bmatrix}$.
- Orthogonally diagonalize $\begin{bmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{bmatrix}$.
- Classify $q = 2x^2 + 6xy + 2y^2$.
- Identify the curve $3x^2 + 2xy + 3y^2 = 8$.
Further practice
- Strang, MIT 18.06 (OCW): lecture 25 Symmetric matrices and positive definiteness; 27 Positive definite matrices. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §6.4–6.5.
Least squares (with MATLAB)
- Explain least squares as projection onto the column space.
- Set up and solve the normal equations $A^TA\hat{\bm{x}} = A^T\bm{b}$.
- Fit lines and curves by hand and in MATLAB.
Plot $(1,1)$, $(2,3)$, $(3,4)$, $(4,4)$. Draw the line you think fits best. What makes one line "better" than another?
Show answer
Least squares
When there's no exact answer, find the closest one.
The idea
Real measurements are noisy. Fit a straight line through 4 lab data points and you get 4 equations in 2 unknowns, with no exact solution. A least-squares solution $\hat{\bm{x}}$ makes $A\hat{\bm{x}}$ as close as possible to $\bm{b}$, that is, it makes $\|A\bm{x} - \bm{b}\|$ as small as it can be.
Geometric picture: $A\bm{x}$ can only land in the column space of $A$. The closest point there to $\bm{b}$ is the projection of $\bm{b}$ onto the column space. The leftover error is perpendicular to every column, i.e. $A^T(\bm{b} - A\hat{\bm{x}}) = \bm{0}$, which gives the normal equations:
$$A^TA\,\hat{\bm{x}} = A^T\bm{b}.$$Recipe for a best-fit line $y = a + bx$
- Write one equation per data point: $a + bx_i = y_i$.
- $A$ has a column of 1s (for $a$) and a column of the $x$-values (for $b$). The vector $\bm{y}$ holds the $y$-values.
- Compute $A^TA$ and $A^T\bm{y}$, then solve the $2\times2$ system $A^TA\begin{bmatrix} a \\ b \end{bmatrix} = A^T\bm{y}$.
Fit $y = a + bx$ to the data $(0, 1)$, $(1, 2)$, $(2, 2)$, $(3, 4)$.
$$A = \begin{bmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{bmatrix}, \qquad \bm{y} = \begin{bmatrix} 1 \\ 2 \\ 2 \\ 4 \end{bmatrix}, \qquad A^TA = \begin{bmatrix} 4 & 6 \\ 6 & 14 \end{bmatrix}, \qquad A^T\bm{y} = \begin{bmatrix} 9 \\ 18 \end{bmatrix}.$$(In $A^TA$: 4 is the number of points, 6 the sum of the $x$'s, 14 the sum of the $x^2$'s. In $A^T\bm{y}$: 9 is the sum of the $y$'s, 18 the sum of the $xy$'s.) Solving
$$\begin{aligned} 4a + 6b &= 9 \\ 6a + 14b &= 18 \end{aligned} \qquad\Longrightarrow\qquad a = 0.9, \quad b = 0.9,$$so the best-fit line is $y = 0.9 + 0.9x$. Check: the errors (actual minus predicted) are $\bm{r} = (0.1, 0.2, -0.7, 0.4)$, and
$$A^T\bm{r} = \begin{bmatrix} 0.1 + 0.2 - 0.7 + 0.4 \\ 0 + 0.2 - 1.4 + 1.2 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix} \;\checkmark$$Worked examples
- CoreFit $y = a + bx$ to $(1,1)$, $(2,3)$, $(3,4)$, $(4,4)$.Solution
- One equation $a + bx_i = y_i$ per point: $A = \begin{bmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \\ 1 & 4 \end{bmatrix},\ \bm{y} = \begin{bmatrix} 1 \\ 3 \\ 4 \\ 4 \end{bmatrix}$.
- $A^TA = \begin{bmatrix} n & \sum x \\ \sum x & \sum x^2 \end{bmatrix} = \begin{bmatrix} 4 & 10 \\ 10 & 30 \end{bmatrix}$ and $A^T\bm{y} = \begin{bmatrix} \sum y \\ \sum xy \end{bmatrix} = \begin{bmatrix} 12 \\ 35 \end{bmatrix}$.
- Solve $4a + 10b = 12,\ 10a + 30b = 35$: multiply the first by 2.5 to get $10a + 25b = 30$, subtract: $5b = 5 \Rightarrow b = 1$, then $a = \tfrac{12 - 10}{4} = \tfrac12$.
- Best fit $y = \tfrac12 + x$. Check: errors $\bm{r} = (-\tfrac12, \tfrac12, \tfrac12, -\tfrac12)$ give $A^T\bm{r} = \bm{0}\;\checkmark$.
- CoreFind the least-squares solution of $x + y = 2,\ x - y = 0,\ x = 2$.Solution
- $A = \begin{bmatrix} 1 & 1 \\ 1 & -1 \\ 1 & 0 \end{bmatrix},\ \bm{b} = \begin{bmatrix} 2 \\ 0 \\ 2 \end{bmatrix}$.
- $A^TA = \begin{bmatrix} 3 & 0 \\ 0 & 2 \end{bmatrix}$ (column dot products) and $A^T\bm{b} = \begin{bmatrix} 4 \\ 2 \end{bmatrix}$.
- Solve: $3x = 4 \Rightarrow x = \tfrac43$ and $2y = 2 \Rightarrow y = 1$.
- CoreSet up the least-squares problem for fitting $y = a + bx + cx^2$ to $(-1,2)$, $(0,1)$, $(1,2)$, $(2,5)$. What do you expect?Solution
- One equation $a + bx + cx^2 = y$ per point. Rows $(1, x, x^2)$: $A = \begin{bmatrix} 1 & -1 & 1 \\ 1 & 0 & 0 \\ 1 & 1 & 1 \\ 1 & 2 & 4 \end{bmatrix},\ \bm{y} = \begin{bmatrix} 2 \\ 1 \\ 2 \\ 5 \end{bmatrix}$.
- Notice $y = 1 + x^2$ fits every point: $2, 1, 2, 5\;\checkmark$.
- So $A\bm{x} = \bm{y}$ is actually consistent, and least squares returns the exact solution $a = 1,\ b = 0,\ c = 1$ with zero error.
- CoreWrite the MATLAB commands for the first problem.Solution
- Enter the data as columns:
x = [1;2;3;4]; y = [1;3;4;4]; - Build the matrix with a column of ones:
A = [ones(4,1) x]; - Solve in the least-squares sense with backslash:
coef = A\yreturns0.5and1.
- Enter the data as columns:
- ApplicationLoads of 0, 1, 2, 3 N stretch a spring to lengths 10.0, 10.6, 11.0, 11.6 cm. Fit $L = a + bF$ and predict the length under 5 N.Solution
- $A = \begin{bmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 2 \\ 1 & 3 \end{bmatrix},\ \bm{y} = \begin{bmatrix} 10.0 \\ 10.6 \\ 11.0 \\ 11.6 \end{bmatrix}$.
- $A^TA = \begin{bmatrix} 4 & 6 \\ 6 & 14 \end{bmatrix},\ A^T\bm{y} = \begin{bmatrix} 43.2 \\ 67.4 \end{bmatrix}$.
- Solve $4a + 6b = 43.2,\ 6a + 14b = 67.4$: multiply the first by 1.5 to get $6a + 9b = 64.8$; subtract: $5b = 2.6 \Rightarrow b = 0.52$; then $a = \tfrac{43.2 - 3.12}{4} = 10.02$.
- $L = 10.02 + 0.52F$. At $F = 5$: $L \approx 12.62$ cm. (The slope 0.52 cm/N is the spring's stretchiness.)
- Trying to solve $A\bm{x} = \bm{y}$ directly. It's inconsistent; that's the whole point.
- Computing $AA^T$ instead of $A^TA$. Here $AA^T$ would be $4\times4$ instead of $2\times2$, a sure sign something is wrong.
- Forgetting the column of 1s, which forces the line through the origin.
Why does least squares use $A^TA$ and not $AA^T$?
Show answer
Test yourself
- If all the points lie exactly on a line, what does least squares give? (That exact line, with zero error.)
- Why "squares"? (We minimize the sum of the squared errors, which is $\|A\bm{x} - \bm{y}\|^2$.)
- How would you fit a parabola $y = a + bx + cx^2$? (Add a third column holding the $x^2$ values.)
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Fit $y = a + bx$ to $(0, 0)$, $(1, 1)$, $(2, 1)$.
- Fit $y = a + bx$ to $(0,1)$, $(1,1)$, $(2,2)$, $(3,2)$.
- Find the least-squares solution of $x = 1,\ y = 2,\ x + y = 4$.
- Fit a line through the origin, $y = bx$, to $(1,2)$, $(2,3)$, $(3,7)$.
- Write MATLAB commands to fit $y = a + bx + cx^2$ to data vectors
xandy(columns).
Further practice
- Strang, MIT 18.06 (OCW): lecture 16 Projection matrices and least squares. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §4.3.
Final review I: Units 6–8
- Connect transformations, determinants and eigenvalues.
- Practise exam-style problems on Units 6–8.
- Extend the Invertible Matrix Theorem.
True or false: (1) a reflection has determinant $-1$; (2) every $2\times2$ matrix has a real eigenvalue; (3) a projection matrix is invertible.
Show answer
One matrix, three lenses
- Take $A = \begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}$: as a transformation (where do $\bm{e}_1, \bm{e}_2$ go?), as an area scale ($\det = 10$), and by its eigenvectors (stretching by 5 and 2).
- Add to the Invertible Matrix Theorem: $\det A \ne 0$, 0 is not an eigenvalue, $T$ is one-to-one and onto.
Typical exam traps
- Composition order; $\det(kA) = k^n\det A$; mismatched $P$ and $D$; repeated eigenvalues.
Worked examples
- Unit 6Find the matrix of the projection onto the line $y = 2x$. Find its kernel, image and eigenvalues.Solution
- Direction $\bm{d} = (1,2)$, $\bm{d}\cdot\bm{d} = 5$. $T(\bm{e}_1) = \tfrac15(1,2)$ and $T(\bm{e}_2) = \tfrac25(1,2)$.
- Matrix: $P = \tfrac15\begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}$.
- Kernel: $P\bm{x} = \bm{0} \iff x + 2y = 0$, so $\operatorname{span}\{(-2,1)\}$ (the perpendicular direction). Image: $\operatorname{span}\{(1,2)\}$ (the line).
- Eigenvalues: $P(1,2) = (1,2)$ gives 1; $P(-2,1) = \bm{0}$ gives 0.
- Unit 7Let $A = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 2 & 1 \\ 0 & 1 & 2 \end{bmatrix}$ and $\bm{b} = (1,0,1)$. Find $\det A$ and use Cramer's rule to find $x_2$ only.Solution
- Expand along row 1: $\det A = 2\begin{vmatrix} 2 & 1 \\ 1 & 2 \end{vmatrix} - 1\begin{vmatrix} 1 & 1 \\ 0 & 2 \end{vmatrix} + 0 = 2(3) - 1(2) = 4$.
- Replace column 2 by $\bm{b} = (1,0,1)$: $A_2(\bm{b}) = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 1 & 2 \end{bmatrix}$.
- $\det A_2(\bm{b}) = 2(0 - 1) - 1(2 - 0) + 0 = -4$.
- $x_2 = \dfrac{-4}{4} = -1$.
- Unit 8Show that $(1,0,-1)$ is an eigenvector of the same $A$. Its other eigenvalues are $2 \pm \sqrt2$. Is $A$ diagonalizable?Solution
- Multiply: $A(1,0,-1) = (2 + 0 + 0,\ 1 + 0 - 1,\ 0 + 0 - 2) = (2,0,-2) = 2(1,0,-1)$, so $\lambda = 2$.
- Sanity check with the given eigenvalues: sum $2 + (2+\sqrt2) + (2-\sqrt2) = 6 = \text{trace}$; product $2(4 - 2) = 4 = \det A\;\checkmark$.
- Three distinct eigenvalues, so three independent eigenvectors: diagonalizable. Since $A$ is symmetric, it is even orthogonally diagonalizable.
- Unit 8Diagonalize $\begin{bmatrix} 1 & 1 \\ 0 & 2 \end{bmatrix}$ and find $A^k$.Solution
- Upper triangular: $\lambda = 1, 2$.
- $\lambda = 1$: $A - I = \begin{bmatrix} 0 & 1 \\ 0 & 1 \end{bmatrix}$ gives $y = 0$: $(1,0)$. $\lambda = 2$: $A - 2I = \begin{bmatrix} -1 & 1 \\ 0 & 0 \end{bmatrix}$ gives $x = y$: $(1,1)$.
- $P = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix},\ D = \begin{bmatrix} 1 & 0 \\ 0 & 2 \end{bmatrix},\ P^{-1} = \begin{bmatrix} 1 & -1 \\ 0 & 1 \end{bmatrix}$.
- $A^k = PD^kP^{-1} = \begin{bmatrix} 1 & 2^k \\ 0 & 2^k \end{bmatrix}\begin{bmatrix} 1 & -1 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} 1 & 2^k - 1 \\ 0 & 2^k \end{bmatrix}$.
- Check $k = 3$: $\begin{bmatrix} 1 & 7 \\ 0 & 8 \end{bmatrix} = A^3\;\checkmark$.
- MixedFor $A = \begin{bmatrix} 3 & 1 \\ 1 & 3 \end{bmatrix}$: describe it as a transformation, find its determinant, and find $A^n$.Solution
- Eigenvalues 4 (along $(1,1)$) and 2 (along $(1,-1)$): $A$ stretches by 4 along the line $y = x$ and by 2 along $y = -x$.
- $\det A = 9 - 1 = 8 = 4\cdot2$: areas scale by 8.
- $A^n = PD^nP^{-1}$ with $P = \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$: $A^n = \tfrac12\begin{bmatrix} 4^n + 2^n & 4^n - 2^n \\ 4^n - 2^n & 4^n + 2^n \end{bmatrix}$.
- Check $n = 1$: $\tfrac12\begin{bmatrix} 6 & 2 \\ 2 & 6 \end{bmatrix} = A\;\checkmark$.
- Spending too long on one determinant: choose the row with zeros.
Which topic from Units 6–8 do you most want to see again?
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Find the matrix that rotates $90^\circ$ counterclockwise and then doubles every length. What are its determinant and real eigenvalues?
- Is $\begin{bmatrix} 1 & 2 & 0 \\ 0 & 1 & 2 \\ 2 & 0 & 1 \end{bmatrix}$ invertible?
- Diagonalize $\begin{bmatrix} 2 & 3 \\ 0 & -1 \end{bmatrix}$.
- A matrix has eigenvector $(1,1)$ with eigenvalue 3 and $(1,-1)$ with eigenvalue 1. Find it.
Further practice
- Strang, MIT 18.06 (OCW): lecture 24b Quiz 2 review (plus the past exams on the course site). ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §Chapters 5–6, 8.
Final review II: Units 9–11 and the whole course
- Practise Gram–Schmidt, orthogonal diagonalization and least squares.
- See the whole course as one story about $A\bm{x} = \bm{b}$.
- Plan final-exam revision.
In one sentence each: what is a projection, an orthogonal matrix, and a least-squares solution?
Show answer
The course in one picture
- Unit by unit around $A\bm{x} = \bm{b}$: columns (U1), solving (U2–3), structure (U4–5), geometry of $A$ (U6–7), best axes (U8, U10), perpendicularity (U9), best approximation (U11).
- The full Invertible Matrix Theorem (Appendix B).
Revision plan
- Rework one problem per lecture; do the self-check table; MATLAB command sheet.
Worked examples
- Unit 9Apply Gram–Schmidt to $(1,2,2)$, $(1,0,1)$.Solution
- $\bm{v}_1 = (1,2,2)$, $\|\bm{v}_1\|^2 = 9$.
- $\bm{x}_2\cdot\bm{v}_1 = 1 + 0 + 2 = 3$, so $\bm{v}_2 = (1,0,1) - \tfrac39(1,2,2) = (\tfrac23, -\tfrac23, \tfrac13)$.
- Scale by 3: $(2,-2,1)$. Check: $(1,2,2)\cdot(2,-2,1) = 2 - 4 + 2 = 0\;\checkmark$.
- Orthonormal: $\tfrac13(1,2,2)$ and $\tfrac13(2,-2,1)$ (both have length 3 before dividing).
- Unit 10Orthogonally diagonalize $\begin{bmatrix} 3 & 1 \\ 1 & 3 \end{bmatrix}$.Solution
- Characteristic polynomial: $(3-\lambda)^2 - 1 = 0 \Rightarrow 3 - \lambda = \pm1 \Rightarrow \lambda = 2, 4$.
- $\lambda = 4$: $A - 4I = \begin{bmatrix} -1 & 1 \\ 1 & -1 \end{bmatrix}$ gives $(1,1)$. $\lambda = 2$: $A - 2I = \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}$ gives $(1,-1)$.
- Normalize (length $\sqrt2$): $Q = \tfrac{1}{\sqrt2}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix},\ D = \begin{bmatrix} 4 & 0 \\ 0 & 2 \end{bmatrix}$.
- Unit 11Fit $y = a + bx$ to $(0,0)$, $(1,2)$, $(2,3)$.Solution
- $A = \begin{bmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 2 \end{bmatrix},\ \bm{y} = \begin{bmatrix} 0 \\ 2 \\ 3 \end{bmatrix}$.
- $A^TA = \begin{bmatrix} 3 & 3 \\ 3 & 5 \end{bmatrix},\ A^T\bm{y} = \begin{bmatrix} 5 \\ 8 \end{bmatrix}$.
- Solve $3a + 3b = 5,\ 3a + 5b = 8$: subtract to get $2b = 3 \Rightarrow b = \tfrac32$, then $3a = 5 - \tfrac92 \Rightarrow a = \tfrac16$.
- $y = \tfrac16 + \tfrac32x$. Check: the errors $(-\tfrac16, \tfrac13, -\tfrac16)$ sum to 0 $\checkmark$.
- MixedTrue or false: (a) every symmetric matrix is diagonalizable; (b) eigenvectors of any matrix for distinct eigenvalues are orthogonal; (c) the least-squares solution is unique when the columns of $A$ are independent; (d) if $Q$ is orthogonal then $\|Q\bm{x}\| = \|\bm{x}\|$.Solution
- (a) The Principal Axes Theorem says every real symmetric matrix is orthogonally diagonalizable. True.
- (b) Counterexample: $\begin{bmatrix} 5 & -2 \\ 6 & -2 \end{bmatrix}$ has eigenvectors $(1,2)$ and $(2,3)$, whose dot product is 8. False (true only for symmetric matrices).
- (c) Independent columns make $A^TA$ invertible, so $A^TA\hat{\bm{x}} = A^T\bm{b}$ has exactly one solution. True.
- (d) $\|Q\bm{x}\|^2 = \bm{x}^TQ^TQ\bm{x} = \bm{x}^T\bm{x} = \|\bm{x}\|^2$. True.
- MixedFit $y = a + bx$ to $(-1,1)$, $(0,2)$, $(1,4)$. Why is $A^TA$ diagonal here?Solution
- $A = \begin{bmatrix} 1 & -1 \\ 1 & 0 \\ 1 & 1 \end{bmatrix},\ \bm{y} = \begin{bmatrix} 1 \\ 2 \\ 4 \end{bmatrix}$.
- The columns $(1,1,1)$ and $(-1,0,1)$ are orthogonal (dot product 0), so $A^TA = \begin{bmatrix} 3 & 0 \\ 0 & 2 \end{bmatrix}$ is diagonal.
- $A^T\bm{y} = \begin{bmatrix} 7 \\ 3 \end{bmatrix}$, so $a = \tfrac73$ and $b = \tfrac32$: $y = \tfrac73 + \tfrac32x$.
- Orthogonal columns make least squares as easy as projecting onto each column separately (Lecture 12).
- Leaving MATLAB until the night before: it is tested.
Write down the three topics you will revise first, and plan one unit per day ending with mixed practice.
Practice problems
Solutions are in the separate solutions booklet (PDF).
- Find an orthonormal basis for the column space of $\begin{bmatrix} 1 & 1 \\ 1 & 0 \\ 0 & 1 \end{bmatrix}$.
- Orthogonally diagonalize $\begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}$.
- Fit $y = a + bx$ to $(-1,0)$, $(0,1)$, $(1,3)$.
- True or false: (a) an orthogonal matrix is always symmetric; (b) the projection of $\bm{b}$ onto $\operatorname{col}A$ is $A\hat{\bm{x}}$; (c) Gram–Schmidt applied to a dependent set produces a zero vector.
Further practice
- Strang, MIT 18.06 (OCW): lecture 34 Final course review. ocw.mit.edu/courses/18-06-linear-algebra-spring-2010
- Strang, Introduction to Linear Algebra: problem sets in §Chapters 4 and 6.
Martian to English
Keep this handy. Most confusion is vocabulary.
| Textbook says | It means |
|---|---|
| scalar | Just a regular number. |
| vector in $\R^n$ | A list of $n$ numbers, or an arrow in $n$-dimensional space. |
| linear combination | A mix: $c_1\bm{v}_1 + c_2\bm{v}_2$, "some of this vector plus some of that one". |
| norm $\|\bm{v}\|$ | The length of the arrow. |
| unit vector | An arrow of length exactly 1. Pure direction. |
| projection | The shadow one arrow casts on another. |
| parametric form | "Start here, then move $t$ steps this way." The $t$ is the parameter. |
| hyperplane | What one equation describes in $\R^n$: a line in $\R^2$, a plane in $\R^3$, a 3D "slice" in $\R^4$. |
| augmented matrix | The system with the letters and $=$ signs stripped out. Just the numbers. |
| REF | Row echelon form: a staircase of zeros in the bottom-left. |
| RREF | Reduced REF: the fully tidied staircase, where you can read the answer straight off. |
| span | Everywhere you can reach by mixing the given vectors. |
| linearly independent | None of the vectors is redundant; none can be built from the others. |
| basis | The smallest set of directions that still reaches everywhere. |
| dimension | How many independent directions you have (degrees of freedom). |
| subspace | A flat thing through the origin: a line, a plane, and so on. |
| orthogonal | Perpendicular: $\bm{u}\cdot\bm{v} = 0$. |
| normal vector | An arrow sticking straight out of a plane. |
| consistent system | Has at least one solution. |
| homogeneous system | Every right-hand side is 0. Always has the "all zeros" answer. |
| trivial solution | The all-zeros answer, $\bm{x} = \bm{0}$. |
| pivot | The first non-zero entry in a row after elimination. Its variable is "decided". |
| free variable | A variable with no pivot. You get to pick its value. |
| identity matrix $I$ | The "do nothing" matrix. Like multiplying by 1. |
| invertible / non-singular | Has an undo button, $A^{-1}$. |
| singular | Squashes space flat. No undo button. |
| transpose $A^T$ | Flip the matrix so rows become columns. |
| null space / kernel | Every vector that the matrix squashes to zero. |
| column space | Everything $A\bm{x}$ can produce: all combinations of the columns. |
| rank | The number of pivots: how many truly independent columns (or rows) there are. |
| nullity | The dimension of the null space, which equals the number of free variables. |
| eigenvector | A direction the matrix only stretches, never turns: $A\bm{v} = \lambda\bm{v}$. |
| diagonalizable | Can be rewritten as pure stretching along its eigenvector axes: $A = PDP^{-1}$. |
| orthonormal | All perpendicular to each other, and each of length 1. |
| Gram–Schmidt | A recipe for straightening any basis into a perpendicular one. |
| orthogonal matrix | A square matrix with orthonormal columns. Its inverse is just its transpose. |
| symmetric matrix | Equal to its own transpose, $A^T = A$: a mirror image across the diagonal. |
| least squares | The best approximate answer when an exact one doesn't exist. |
How it all connects
Most of the course is one question asked in different ways.
For a square $n\times n$ matrix $A$, the statements below are either all true or all false. Try picking one example matrix and checking a few of them to see that they agree.
| Textbook version | Plain English |
|---|---|
| $A$ is invertible | $A$ has an undo button |
| $\det A \ne 0$ | $A$ doesn't squash space flat |
| $A\bm{x} = \bm{b}$ has exactly one solution for every $\bm{b}$ | Every output comes from exactly one input |
| $A\bm{x} = \bm{0}$ has only the trivial solution | Nothing non-zero gets squashed to zero |
| The columns of $A$ are linearly independent | No column is redundant |
| The columns of $A$ span $\R^n$ | The outputs reach everywhere |
| The columns of $A$ form a basis of $\R^n$ | A complete set of directions with nothing wasted |
| $\operatorname{rank}A = n$ | Every column has a pivot |
| The RREF of $A$ is $I$ | Row reduction gives a pivot in every row and column |
| Cramer's rule can be used on $A\bm{x} = \bm{b}$ | There's a unique answer to find, one variable at a time |
| 0 is not an eigenvalue of $A$ | No direction gets crushed to nothing |
True/false questions love this list. "If $\det A = 0$, can $A\bm{x} = \bm{b}$ have a unique solution?" becomes easy once you see these are all the same fact.
Self-check habits
Thirty seconds of checking is worth more marks than any trick.
| After finding… | Check by… |
|---|---|
| A solution to a system | Substituting it into the original equations |
| A linear combination's weights | Rebuilding the target vector from them |
| A unit vector | Its length should come out as exactly 1 |
| A projection | (Leftover part) $\cdot\,\bm{v} = 0$, and the two pieces add back to $\bm{u}$ |
| A cross product | Dotting it with both original vectors; both should give 0 |
| A plane's equation | Substituting the given point(s) |
| A line–plane intersection | Substituting the point into the plane's equation |
| An RREF | Every pivot is 1 and is the only non-zero entry in its column |
| An inverse | $AA^{-1}$ should equal $I$ |
| A null space basis | $A$ times each basis vector should give $\bm{0}$ |
| A rank | rank $+$ number of free variables $=$ number of columns |
| A determinant | Does 0 make sense? Are the columns obviously dependent? |
| A Cramer's rule answer | Substituting into the original equations (or solving another way) |
| An eigenvector | Computing $A\bm{v}$ and checking that it equals $\lambda\bm{v}$ |
| Eigenvalues | Sum $=$ trace, product $=$ determinant |
| A diagonalization | Checking $AP = PD$ (quicker than computing $P^{-1}$) |
| A transformation matrix | Feeding in $\bm{e}_1$ and $\bm{e}_2$ and seeing where they go |
| A Gram–Schmidt result | Every pair of new vectors should dot to 0 |
| An orthogonal matrix | $Q^TQ$ should equal $I$ |
| A least-squares fit | $A^T(\text{errors})$ should be the zero vector |
| Any answer at all | Is it the right type and size? Number, vector, matrix? |
MATLAB basics
Everything in this course, one line at a time.
MATLAB is short for "matrix laboratory", so linear algebra is what it does best. Use it to check hand calculations, and learn the commands, because the exam can ask about them.
Entering things
v = [1 2 3] % row vector (spaces or commas between entries) w = [1; 2; 3] % column vector (semicolons start new rows) A = [1 2; 3 4] % 2×2 matrix I = eye(3) % 3×3 identity Z = zeros(2, 3) % 2×3 matrix of zeros format rat % show answers as fractions, easier to compare with hand work
Command cheat sheet
| Math | MATLAB | Unit |
|---|---|---|
| $\bm{u}\cdot\bm{v}$, $\bm{u}\times\bm{v}$, $\|\bm{v}\|$ | dot(u,v) cross(u,v) norm(v) | 1 |
| RREF of $[\,A \mid \bm{b}\,]$ | rref([A b]) | 2 |
| $A^T$, $AB$, $A^{-1}$ | A' A*B inv(A) | 3 |
| Solve $A\bm{x} = \bm{b}$ | A\b | 2–3 |
| Rank, null space basis | rank(A) null(A,'r') | 4–5 |
| $\det A$ | det(A) | 7 |
| Eigenvalues only | eig(A) | 8 |
| Eigenvectors ($V$) and eigenvalues ($D$) | [V, D] = eig(A) | 8, 10 |
| Orthonormal basis of $\operatorname{col}A$ | orth(A) or [Q, R] = qr(A, 0) | 9 |
| Least-squares solution | A\b (when A is tall) | 11 |
% Unit 8: diagonalization A = [4 1; 2 3]; [V, D] = eig(A) % D holds 2 and 5. V's columns point along (1, -2) and (1, 1), % but scaled to length 1, e.g. 0.7071 0.7071 instead of 1 1. V*D/V % rebuilds A (X/V means X times inv(V)) % Unit 11: best-fit line through (0,1), (1,2), (2,2), (3,4) x = [0; 1; 2; 3]; y = [1; 2; 2; 4]; A = [ones(4,1) x]; % column of 1s, then the x-values coef = A\y % returns 0.9 and 0.9
A*Bis matrix multiplication;A.*Bmultiplies entry by entry. Mixing them up gives no error, just a wrong answer.- Row vs column vectors:
[1 2 3]is a row,[1; 2; 3]is a column.A*vneeds a column. eigreturns unit-length eigenvectors, possibly in a different order or with flipped signs. They're still correct; compare directions, not exact numbers.- Tiny numbers like
1.0e-15are rounding noise. Read them as 0. A\bis notb/A. Backslash is the one that solves $A\bm{x} = \bm{b}$.