This set practises three lessons: projections onto subspaces (Lecture 15), projection matrices and least squares (Lecture 16) and orthogonal matrices and Gram–Schmidt (Lecture 17). Orthogonal subspaces and complements (Lecture 14) belong to Problem Set 5, and determinants start in Problem Set 7, so nothing here uses a determinant.
MIT's 18.06 problem sets assign exercises from a textbook that is not openly licensed, so this set is made of our own problems on the same lectures, in MIT's lecture order. No MIT or textbook problem is used: every matrix and every number below is ours, and so are the hints and the solutions. The formulas come from the lessons and from the lecture transcripts they cite.
How to answer#
Work each problem on paper first. Then type or choose your result in the answer box and press Check.
A number box wants a decimal number, not a fraction or a root: write , not . Every number box accepts any value within of the exact one, so give at least two decimal places when the answer is not a whole number. A matrix or a vector cannot be typed: a box asks for one of its entries, a length or a single number, or you choose from a list. Entries are numbered by row, then column, starting from 1: "row 1, column 2" is the entry in the first row and the second column. A vector is written as a list, , and its "second entry" is the second number in that list.
A formula box takes plain typing, for example (5 + beta^2)/3, and accepts every correct way of writing the answer. Type as beta.
Some parts ask you to show something. They have no answer box: write your argument, then open the solution and mark yourself. MIT gives no points for these problems: the points here (100 in all) and their split between the parts are ours. If you are stuck, open the hints one at a time. Each part ends with its full solution. Try before you open it: an answer given after its solution was opened earns no points. Your score is kept in this browser only.
What you need from the lessons#
Projecting onto a line (Lecture 15). The point on the line through closest to leaves an error perpendicular to . That right angle gives , and is a matrix times :
In words
a^ capital T the quantity b minus x hat a, equals 0, x hat equals a^ capital T b over the quantity a^ capital T a, p equals capital P b, capital P equals a a^ capital T over the quantity a^ capital T a
Projecting onto a subspace (Lecture 15). Put a basis of the subspace in the columns of . The error must be perpendicular to every column, which gives the normal equations and three answers:
In words
capital A ^ capital T the quantity b minus capital A x hat, equals 0, capital A ^ capital T capital A x hat equals capital A ^ capital T b, p equals capital A x hat, capital P equals capital A ( capital A ^ capital T capital A ) to the power minus 1 capital A ^ capital T
Every projection matrix has the two properties
In words
capital P ^ capital T equals capital P, capital P squared equals capital P
The two projections (Lecture 16). for in the column space and for in , the space perpendicular to it. Every splits into the two parts, and is the projection onto the perpendicular space:
In words
b equals capital P b plus the quantity capital I minus capital P, b equals p plus e
Least squares (Lecture 16). To fit points by a line , write the equations for all the points as with ; the first column of is all ones and the second holds the times . The best line makes , the sum of the squared vertical errors, as small as possible. It solves the normal equations (pp. 5–11 of the transcript). is invertible when the columns of are independent, because
In words
capital A ^ capital T capital A x equals 0 which gives x^ capital T capital A ^ capital T capital A x equals the norm of capital A x squared equals 0 which gives capital A x equals 0 which gives x equals 0
Orthonormal vectors (Lecture 17). Orthonormal columns of give . A square with orthonormal columns is an orthogonal matrix, and then (pp. 2–4). With orthonormal columns the projection needs no inverse, and each component is a dot product:
In words
capital P equals capital Q capital Q ^ capital T, x hat equals capital Q ^ capital T b, x sub i hat equals q sub i ^ capital T b
Gram–Schmidt (Lecture 17). From independent , keep and subtract from each later vector its components along the earlier directions; then divide each by its length:
In words
capital B equals b minus capital A ^ capital T b over the quantity capital A ^ capital T capital A, times capital A, capital C equals c minus capital A ^ capital T c over the quantity capital A ^ capital T capital A, times capital A minus capital B ^ capital T c over the quantity capital B ^ capital T capital B, times capital B, q one equals capital A over the quantity the norm of capital A, q two equals capital B over the quantity the norm of capital B, q three equals capital C over the quantity the norm of capital C
In matrix language the original matrix is , with upper triangular; the entry of in row and column is times column (pp. 22–24).
Problem 1#
Projecting onto a line
Take and in .
(a)5 points
Project onto the line through : find , the projection and the error . Give and the second entry of .
Hint
Two dot products give : one of with , one of with itself.
Hint
Then is times , and is what is left of . Check that is perpendicular to .
Solution
The idea. The error must be perpendicular to the line, and that one condition fixes .
The number x̂
and , so
In words
x hat equals a^ capital T b over the quantity a^ capital T a, equals 18 over 9 equals 2, p equals 2 a equals (2, 4, 4), e equals b minus p equals (2, minus 3, 2)
Check
: the error is perpendicular to . And , the right triangle of the lecture's picture.
(b)6 points
Write the projection matrix onto the line through . Give its entry in row 2, column 3 and its entry in row 1, column 1. Then find for .
Hint
is a column times a row: its entry in row , column is the -th entry of times the -th. Do not forget the division.
Hint
For , look at before multiplying out.
Solution
The idea. is a rank-one matrix, and it sends every vector to a multiple of .
The matrix
In words
capital P equals a a^ capital T over the quantity a^ capital T a, equals one ninth 1 2 2; 2 4 4; 2 4 4
Row 2, column 3 is , and row 1, column 1 is .
Pw
, so : is perpendicular to the line, and its projection is the zero vector.
Check
, the of part (a). is symmetric, every column is a multiple of (rank one), and the diagonal adds to .
(c)3 points
Show, without multiplying out the matrices, that for the of part (b). Show also that the line through has the same projection matrix.
This part has no answer box. Write your argument, then open the solution and mark yourself.
Hint
In , group the middle together: it is a number.
Solution
The idea. A row times a column in the middle of a product is a number, and it cancels.
P squared
In words
capital P squared equals a (a^ capital T a) a^ capital T over (a^ capital T a) squared equals a a^ capital T over the quantity a^ capital T a, equals capital P
Projecting a second time leaves where it is: is already on the line.
The line through −3a
With in place of , the top becomes and the bottom . The cancels, so the matrix is the same : the line has not changed (Lecture 15 transcript, pp. 3–4).
Check
Numerically: has row 1, column 1 equal to , the same entry as .
Problem 2#
Projecting onto a plane
The columns and of span a plane in . Take .
(a)7 points
Solve the normal equations for , then find and the error . Give both entries of and the length squared .
Hint
The entries of are the dot products of the columns with each other; the entries of are the dot products of the columns with .
Hint
The two normal equations form a system: eliminate one unknown.
Solution
The idea. The error is perpendicular to both columns, , and that is a square system for .
The normal equations
In words
capital A ^ capital T capital A equals 2 2; 2 5, capital A ^ capital T b equals 2; minus 1 : 2 x one hat plus 2 x two hat equals 2, 2 x one hat plus 5 x two hat equals minus 1
Subtracting the first equation from the second leaves , so , and then .
Projection and error
and , so .
Check
and : is perpendicular to the plane, so it lies in .
(b)7 points
Find the projection matrix onto the plane. Do it the short way: find a nonzero vector perpendicular to both columns, write the projection onto the line through , and use that the projection onto the plane is minus that one. Give the entry of in row 1, column 1 and the entry in row 1, column 2.
Hint
solves : two equations in three unknowns. Choose its last entry and solve for the other two.
Hint
The projection onto the line through is . The plane and that line are perpendicular, so the two projections add up to .
Solution
The idea. In the space perpendicular to a plane is a line, and splits between the two.
The perpendicular line
says and . With : , and .
The matrix
In words
capital P equals capital I minus n n^ capital T over the quantity n^ capital T n, equals capital I minus one sixth 1 2 minus 1; 2 4 minus 2; minus 1 minus 2 1 equals one sixth 5 minus 2 1; minus 2 2 2; 1 2 5
Row 1, column 1 is and row 1, column 2 is .
Check
The long way gives the same matrix: elimination gives (multiply back: times it is ), and has row 1, column 1 equal to . Also , and , .
(c)4 points
Show that really is the point of the plane closest to : for every ,
In words
the norm of b minus capital A x squared equals the norm of b minus capital A x hat squared plus the norm of capital A the quantity x hat minus x, squared
so no is closer to than .
This part has no answer box. Write your argument, then open the solution and mark yourself.
Hint
Write and expand the length squared of a sum.
Hint
The cross term contains . What do the normal equations say about ?
Solution
The idea. The error is perpendicular to the whole column space, so Pythagoras applies.
Expand
With and , . And , because the normal equations say (Lecture 15 transcript, p. 13).
Conclude
So , with equality only when , that is (the columns being independent) only for .
Check
For : , and .
Problem 3#
The best straight line
Four measurements are , , and . Fit them by a straight line in the least-squares sense.
(a)7 points
Write the four equations as with . Compute and , and solve the normal equations. Give the entry of in row 2, column 2, the second entry of , and the best and .
Hint
has a column of ones and a column of times. So holds the number of points, the sum of the times and the sum of their squares; holds the sum of the 's and the sum of the products .
Hint
Eliminate from the two normal equations to find first.
Solution
The idea. Four equations in two unknowns have no solution; the normal equations give the best one.
The matrices
In words
capital A equals 1 minus 1; 1 0; 1 1; 1 2, b equals 0; 1; 3; 2, capital A ^ capital T capital A equals 4 2; 2 6, capital A ^ capital T b equals 6; 7
The sum of the squared times is , and the sum of the products is .
Solve
The normal equations are and . Twice the second minus the first gives , so , and then , so . The best line is .
Check
Put the numbers back: and . Part (b) checks that the errors are perpendicular to both columns.
(b)5 points
Find the heights of the best line at the four times and the errors . Give the error at and the total squared error .
Hint
: put each time into with the and of part (a).
Solution
The idea. with in the column space and perpendicular to it.
Heights and errors
In words
p equals capital A x hat equals 0.3; 1.1; 1.9; 2.7, e equals b minus p equals minus 0.3; minus 0.1; 1.1; minus 0.7
The error at is , and .
Check
is perpendicular to the column of ones, , and to the column of times, , as in the lecture's example (Lecture 16 transcript, pp. 13–14).
(c)5 points
Now suppose the last measurement had been instead of , with the other three unchanged. Find the best slope as a formula in . Then take the outlier and give the error of the new best line at .
Hint
Only changes: its entries become the sum of the 's and the sum of the products , now with in them. is the same as in part (a).
Hint
Solve the same way as in part (a). For the error at , you also need for .
Solution
The idea. A change in changes only the right-hand side of the normal equations; the matrix stays.
The new normal equations
Now :
In words
4 capital C plus 2 capital D equals 4 plus beta, 2 capital C plus 6 capital D equals 3 plus 2 beta
Twice the second minus the first: , so ; then .
The outlier
For : and . The line gives at , so the error there is . The point moved up by , but its error grew only from to : the line itself tilted to follow the outlier, the slope going from to . This is the worry about outliers in the lecture (Lecture 16 transcript, pp. 7–8).
Check
At the formulas give and , the line of part (a). For the line gives the heights and the errors : they add to zero, and so do the errors times the times, .
(d)3 points
Show that for every least-squares line , through any number of points, the errors add up to zero, and so do the errors each multiplied by its time .
This part has no answer box. Write your argument, then open the solution and mark yourself.
Hint
What do the normal equations say, one row of at a time?
Solution
The idea. The normal equations say that is perpendicular to each column of .
Row by row
The rows of are the columns of : all ones, and the times. So says
In words
(1, 1, and so on, 1) e equals 0, ( t one, t two, and so on, t sub m ) e equals 0
The first is the sum of the errors, the second the sum of the errors times their times.
Check
Part (b) found both sums zero for the four points.
Problem 4#
The other projection and a reflection
Let be the projection matrix onto the line through in .
(a)4 points
Find . Which line does project onto? Give the entry of in row 1, column 2.
Hint
. keeps the part of a vector that removes, the part perpendicular to .
Solution
The idea. : the second part is the error, perpendicular to .
The matrices
In words
capital P equals 1 over 25 9 12; 12 16, capital I minus capital P equals 1 over 25 16 minus 12; minus 12 9
Row 1, column 2 of is .
The line
is for : and . And , so it is the line perpendicular to .
Check
and . The line through is not perpendicular to : .
(b)6 points
The matrix reflects every vector across the line through . Give its entry in row 1, column 2, and the second entry of for . Then take the line through instead, for a number , and give the entry of its in row 1, column 2 as a formula in .
Hint
Write . Then keeps the part along the line and reverses the other part.
Hint
For the line through , the dot product of the vector with itself is . The in changes only the diagonal.
Solution
The idea. : keep the projection, reverse the error.
The reflection
In words
capital R equals 2 capital P minus capital I equals 1 over 25 18 minus 25 24; 24 32 minus 25 equals 1 over 25 minus 7 24; 24 7
Row 1, column 2 is , and .
A general line
With , , so row 1, column 2 of is .
Check
The line through is the line through , and . Lengths stay: . And : the line itself does not move.
(c)3 points
Show that for every projection matrix the matrix satisfies and , and conclude that is an orthogonal matrix.
This part has no answer box. Write your argument, then open the solution and mark yourself.
Hint
Use only and . Expand .
Solution
The idea. The two properties of a projection are all that is needed.
Symmetric
.
Its square
In words
capital R squared equals 4 capital P squared minus 4 capital P plus capital I equals 4 capital P minus 4 capital P plus capital I equals capital I
Orthogonal
So : the columns of are orthonormal and is square, which makes it an orthogonal matrix with (Lecture 17 transcript, pp. 3–4). Reflecting twice brings every vector back.
Check
For part (b), the columns and have length and dot product .
(d)3 points
Let be the matrix with columns and , for a number . For which is invertible?
Hint
is invertible exactly when the columns of are independent. When is the second column a multiple of the first?
Solution
The idea. Independent columns make invertible, and dependent columns make it singular.
Independence
Two nonzero columns are dependent only when one is a multiple of the other. is a multiple of only if its three entries are equal: and , so . For every other the columns are independent and is invertible (Lecture 16 transcript, pp. 15–17).
The case
Then gives and so with : is not invertible.
Check
For the columns and are independent; for the columns and are too. At , , whose second row is the first again.
Problem 5#
Gram–Schmidt and A = QR
Apply Gram–Schmidt to the columns , and of the matrix . As in the lecture, , and are the orthogonal vectors before they are divided by their lengths. (The matrix is called here because the letter is taken by the first of those vectors.)
(a)7 points
Find , and , and the orthonormal vectors . Give the first entry of , the fourth entry of , and the length .
Hint
. For , subtract from its projection onto . For , subtract from its projections onto and onto , using the you found.
Hint
Check each new vector by its dot products with the earlier ones: they must be zero.
Solution
The idea. Each new vector loses its components along the directions already chosen; what is left is perpendicular to them.
A and B
and . , so
In words
capital B equals b minus capital A ^ capital T b over the quantity capital A ^ capital T capital A, times capital A equals (1, 3, 1, 3) minus 2(1, 1, 1, 1) equals (-1, 1, minus 1, 1)
C
, so the coefficient of is ; and , so the coefficient of is :
In words
capital C equals c minus capital A ^ capital T c over the quantity capital A ^ capital T capital A, times capital A minus capital B ^ capital T c over the quantity capital B ^ capital T capital B, times capital B equals (2, 2, 0, 4) minus (2, 2, 2, 2) minus (-1, 1, minus 1, 1) equals (1, minus 1, minus 1, 1)
Normalize
All three vectors have length , so , , .
Check
and . , as it must be for independent .
(b)5 points
Write with and upper triangular. Give the entry of in row 1, column 2 and the entry in row 2, column 3.
Hint
Since , multiplying on the left by gives : each entry is a dot product of a with a column of .
Solution
The idea. Column of is a combination of only, and the coefficients are the dot products.
The entries
In words
capital R equals capital Q ^ capital T capital M equals q one ^ capital T a q one ^ capital T b q one ^ capital T c; 0 q two ^ capital T b q two ^ capital T c; 0 0 q three ^ capital T c equals 2 4 4; 0 2 2; 0 0 2
For instance and . The zeros below the diagonal are there because is along and is a combination of and , both perpendicular to the later 's.
Check
Column 3 of is . Column 2 is .
(c)6 points
Project onto the column space of , using : the coefficients are . Give , the fourth entry of the projection , and .
Hint
. No system needs to be solved.
Solution
The idea. With orthonormal columns, and the normal equations become .
The coefficients
In words
x hat equals capital Q ^ capital T d equals one half 1 plus 2 plus 3 plus 4; minus 1 plus 2 minus 3 plus 4; 1 minus 2 minus 3 plus 4 equals 5; 1; 0
The projection
. Then and .
Check
is perpendicular to all three 's: , and (times ). The same comes from applied to , without any inverse (Lecture 17 transcript, p. 9).
Problem 6#
An orthogonal matrix
Take .
(a)4 points
Check that the columns of are orthonormal (this check has no box). Then give the entry of in row 1, column 2.
Hint
Each column has entries that are sevenths: add their squares. For the dot products, multiply two columns entry by entry.
Hint
For a square matrix with orthonormal columns, the inverse needs no elimination.
Solution
The idea. collects all the dot products of the columns; for a square it makes the inverse.
Orthonormal
Each column has as the sum of the squares of its entries, before the factor : length . The dot products: columns 1 and 2, ; columns 1 and 3, ; columns 2 and 3, .
The inverse
In words
capital Q to the power minus 1 equals capital Q ^ capital T equals one seventh 2 3 6; 6 2 minus 3; 3 minus 6 2
Row 1, column 2 of is row 2, column 1 of : .
Check
Row 1 of times column 2 of is , and row 1 times column 1 is , as needs. Row 1, column 2 of itself, , is a different number: is not symmetric.
(b)4 points
Solve . Give the third entry of .
Hint
Multiply both sides by , which you found in part (a) without any work.
Solution
The idea. : one matrix times a vector, no elimination.
Solve
is times column 2 of , which is times row 2 of : .
Check
. And : part (c) explains why the lengths agree.
(c)3 points
Show that every orthogonal matrix keeps lengths: for every vector .
This part has no answer box. Write your argument, then open the solution and mark yourself.
Hint
Write the length squared as a vector's transpose times the vector, and use .
Solution
The idea. sits in the middle of .
The length
In words
the norm of capital Q x squared equals ( capital Q x)^ capital T ( capital Q x) equals x^ capital T capital Q ^ capital T capital Q x equals x^ capital T x equals the norm of x squared
Both lengths are positive or zero, so . Only was used, so this holds for orthonormal columns in a rectangular too.
Check
With : and .
(d)3 points
Which of these are orthogonal matrices?
In words
capital M sub 1 equals 0.6 0.8; 0.8 minus 0.6, capital M sub 2 equals one half 1 1; 1 minus 1, capital M sub 3 equals one third 2 1; 1 2; 2 minus 2
Hint
An orthogonal matrix is square and has orthonormal columns. Compute for each.
Solution
The idea. Check the two conditions: square, and .
Each matrix
: columns of length and dot product , and it is square: orthogonal. : the columns are perpendicular but of length , so : not orthogonal (it would need the factor , Lecture 17 transcript, p. 5). : the columns have length and dot product , so , but it is , not square: it has orthonormal columns, and is a projection onto a plane, not .
Check
is a reflection like the of Problem 4: it is symmetric with .