Linear Algebra · Solutions
Orthogonality and Least Squares
Work this sheet on paper and show every step — the solutions are written as methods, so you can check your route and not merely your final vector. Name each theorem as you use it (“by the Orthogonal Decomposition Theorem”, “by the fundamental orthogonality relation”, “by Cauchy–Schwarz”), and whenever a formula needs an orthogonal or orthonormal set, say which it needs and why you have it. No calculator is needed anywhere: every length is an exact square root and every coefficient an exact fraction, and full worked solutions are on a separate page with a separate reveal for each question.
- 1.Computation
Leave every square root exact. In each part say which property of the dot product, or which named theorem, you are using.
- (a)Let and . Compute , , and for the angle between them. Then confirm the distance a second way, using only the three numbers , and .
- (b)Find every real for which and are orthogonal, and check each value you find.
- (c)Let and in . Show that , then compute twice: once from the entries of and once without them. Explain why is not a contradiction.
Solution
(a) Lengths and angle. , so ; likewise and . The dot product is , so
which is negative: the angle is obtuse. Cauchy–Schwarz is comfortably satisfied, , which is why a cosine came out.
Distance directly. , so and .
Distance from the three numbers. Expand with linearity and symmetry of the dot product:
(b) One scalar equation. , which vanishes exactly for and . Check : ✓. Check : ✓. Orthogonality is a single scalar condition; here it happens to be quadratic in , so it has two solutions rather than one.
(c) Pythagoras. , so . From the entries, and , so .
Without the entries: and , and because the vectors are orthogonal the Pythagorean theorem gives ✓.
Meanwhile . There is no contradiction: Pythagoras is a statement about squared lengths. The equation is the equality case of the triangle inequality, which holds only when one vector is a non-negative multiple of the other — and two nonzero orthogonal vectors are as far from parallel as vectors can be.
- 2.Computation
Let with and .
- (a)Find a basis for . State which result lets you replace the condition “orthogonal to every vector of ” by finitely many equations, and confirm that .
- (b)Decide whether and belong to . For whichever does, write it as a combination of your basis vectors from (a).
- (c)Let be the matrix whose rows are and . Give the dimension of each of the four fundamental subspaces of , identify which of them is , and explain what the dimension of tells you about the system .
Solution
(a) Set up the equations. By the finite test for orthogonal complements — a vector is in if and only if it is orthogonal to each vector of a spanning set of — lies in exactly when and :
Row-reduce the coefficient matrix: subtracting twice the second row from the first turns into . Pivots sit in columns 1 and 2, so and are free, and :
A basis of is ; the two are independent because of the and pattern in the free positions. Check all four dot products: , , , ✓.
Since are not multiples of each other, , and , so ✓, as the dimension theorem for complements requires.
(b) Two membership tests. and , so . For : but , so — one failed equation is enough.
To express , read the free positions: the third and fourth entries force and , and indeed ✓.
(c) The four subspaces. The rows are independent, so , with , . Hence and in ; and in .
By the fundamental orthogonality relation , and , so — which is exactly the homogeneous system solved in (a).
means , so is all of : every is reachable and is consistent for every right-hand side. There is no direction in that this matrix cannot reach, so least squares would never be needed for it.
- 3.Computation
Let , , and .
- (a)Show that is an orthogonal basis of , quoting the theorem that spares you a row reduction, and write as a combination of the three vectors without solving a linear system.
- (b)Let be the matrix whose columns are , , . Explain, without multiplying anything out, why and what is. Then solve and verify that .
- (c)A classmate writes . Compute what the right-hand side actually equals, and say precisely which hypothesis of the formula they used is missing.
Solution
(a) Three dot products. , , . The set is orthogonal and every vector is nonzero, so by the theorem that orthogonal sets of nonzero vectors are linearly independent, it is independent; three independent vectors in form a basis.
Coefficients. In an orthogonal basis . All three denominators equal (, , ). The numerators are
so , , and . Check: ✓.
(b) An orthogonal matrix. Each column of has length , and dividing by leaves a zero dot product zero, so the columns are orthonormal. The entry of is the dot product of columns and , hence . Because is square this makes it an orthogonal matrix, and .
So , whose entries are the dot products of with the columns: . Check: ✓. Lengths: and ✓ — multiplication by a matrix with orthonormal columns preserves length. ( is just the coordinate vector of in the orthonormal basis: each entry is .)
(c) The missing denominators. The right-hand side is , nine times too large. The formula requires an orthonormal basis. These vectors are orthogonal but each has length , so every coefficient is missing its denominator .
- 4.Computation
Let with and , and let .
- (a)Verify that is an orthogonal basis of , compute and , and find . Check that and check the identity .
- (b)Find a vector spanning and recompute by projecting onto the line through . Explain why the two routes must agree, naming the theorem.
- (c)Write down the projection matrix onto using the orthonormal-columns formula , confirm , and identify in terms of .
Solution
(a) Project with the orthogonal basis. and both are nonzero, so they form an orthogonal set, hence an independent one, hence an orthogonal basis of the plane they span. The Orthogonal Decomposition Theorem then gives
using , , , . Then and, by the Best Approximation Theorem, .
Checks: and , so by the finite test ✓. Pythagoras: , , , and ✓.
(b) The complement route. gives and gives , so and : spans , which has dimension . Projecting onto that line,
and again. The routes must agree by the uniqueness in the Orthogonal Decomposition Theorem: with and can be done in only one way, and the -component of is by definition , which is the projection onto the line through .
(c) The matrix. With ,
Then ✓. is visibly symmetric and .
Finally
since : it is the projection matrix onto the line , exactly as the theorem on symmetric idempotents promises.
- 5.Sketch
Let . This question is about drawing the four fundamental subspaces of accurately: every line you draw must be labelled with a spanning vector, and every vector you place must be justified by a computation.
- (a)Find a basis for each of , , and , state each dimension, and verify both fundamental orthogonality relations by a dot product.
- (b)Draw two copies of side by side: the domain, showing and , and the codomain, showing and . In the domain draw and its components and . In the codomain draw , and , and say what the picture shows about which part of survives.
- (c)Add to the codomain picture together with its components in and in . Explain from the picture why has no solution, and find the vector of that sends to the -component of .
Solution
(a) Four bases. The second row is three times the first, so and each of the four subspaces is a line.
, dimension . : , so , dimension . (the second column is twice the first), dimension . : gives , so , dimension .
Orthogonality: , so ; and , so ✓. In each copy of the dimensions add to .
(b) The domain. Draw as the line through the origin in direction (slope ) and as the line in direction (slope ); the two are perpendicular. Project onto the row line:
and does lie in ✓. Draw from the origin to , along the row line to , along the null line to ; is the diagonal of the rectangle they span.
The codomain. Draw in direction (slope ) and in direction (slope ), again perpendicular. Compute
So and are the same arrow, , lying on the line, and is a dot at the origin. The picture says: the null-space component of is crushed to zero, the row-space component carries everything, and its image lands in the column space. The row line is carried one-to-one onto the column line ().
(c) An unreachable target. Project onto :
Draw to , on the column line, and the short perpendicular leg from to running parallel to . Every vector lies on the line , and does not: it has the nonzero component in the perpendicular direction , which no input can produce. That is what inconsistency looks like.
For the last part write ; then , and this equals when . So . Check: ✓. (Adding any multiple of gives another vector with the same image; the one in is the shortest of them.)
- 6.Proof
Work from the algebraic properties of the dot product (symmetry, linearity in each slot, positive definiteness) and from theorems you name explicitly. Throughout, is an orthonormal set in .
- (a)Prove the polarization identity . Then prove: if a square matrix satisfies for every , then is an orthogonal matrix.
- (b)Prove Bessel's inequality: for every , , with equality if and only if .
- (c)Show that a matrix which is both orthogonal and symmetric satisfies , and give a example other than .
Solution
(a) Polarization. Expand both squares using linearity in each slot and symmetry:
Subtracting, the squared lengths cancel and remains; divide by .
Length-preserving implies orthogonal. Let be arbitrary. Apply polarization to and , use linearity of , then the hypothesis:
Now the entry of is the dot product of columns and of , that is , which is if and otherwise. Hence , and since is square this is the definition of an orthogonal matrix. Together with the theorem on matrices with orthonormal columns, this says the orthogonal matrices are exactly the length-preserving ones.
(b) Bessel. Put and . For each ,
because orthonormality kills every term with and leaves . As is a combination of the , linearity gives . By the Pythagorean theorem,
Expanding by the same orthonormality. Therefore
Equality holds if and only if , if and only if (positive definiteness), if and only if , which lies in the span. Conversely, if is in the span, dotting with gives (the coefficient theorem for orthonormal bases), so , , and equality holds.
(In the language of projections, is for the span and is the error; Bessel is Pythagoras for that decomposition.)
(c) Symmetric orthogonal matrices. If and then . Example: , which is symmetric and whose columns are orthonormal; indeed . Geometrically it reflects the plane in the line , and reflecting twice is the identity. (Another: , reflection in the -axis.)
- 7.Computation
Let , and ; you may take for granted that they form a basis of . Keep the arithmetic in integers by rescaling wherever it helps, and say each time why rescaling is legitimate.
- (a)Run the Gram–Schmidt process in the order to obtain an orthogonal basis and then an orthonormal basis . Check every orthogonality you claim.
- (b)Express and as combinations of . Which of the does each one use, and which of those facts was guaranteed before you computed anything?
- (c)Now start again in the order and compute the first two Gram–Schmidt vectors. Then explain, without carrying out the third step, why the third vector must be a multiple of .
Solution
(a) Step 1. , with .
Step 2. , so
Rescale by to : multiplying by a nonzero scalar changes neither the span nor orthogonality to . Check ✓; note .
Step 3. and , so
rescaled to . Checks: ✓ and ✓. (Both projections were subtracted from the original , even though one of them happened to be zero.)
All three vectors have squared length , so the orthonormal basis is
(b) Coordinates by dot products. In an orthonormal basis the coefficient of is the dot product with . For : , , , so . For : , , , so . Checks: ✓ and ✓.
That uses no was guaranteed in advance: the correctness theorem says , so — this is the triangular pattern that becomes the matrix in the factorization. That uses no was not guaranteed; it is the accident discovered in step 3.
(c) Reversed order. , , and , so
with ✓. Neither vector appeared in (a): the first output is always a multiple of the first input, so the order matters.
Third step without computing: is minus its projection onto , so by the correctness theorem lies in , a subspace of dimension . Since and , that vector spans the line, and by the theorem's first claim. Hence is a nonzero multiple of . (Carrying the step out gives exactly .) The two orthogonal bases share no vector, but both span : only the subspace is order-independent.
- 8.Computation
Let .
- (a)Find the factorization of with positive diagonal in . Give both factors exactly.
- (b)Verify by computing all four entries of directly, confirm that the diagonal entries of are the lengths of the un-normalised Gram–Schmidt vectors, and multiply out to recover .
- (c)Explain why does not exist. Then, without forming , compute for the first column of and for , and say what is.
Solution
(a) Gram–Schmidt on the columns. and are not proportional, so the columns are independent and the theorem applies. , , . Then and , so
Check ✓.
The factors. for : , , . So
(b) Checks. The rows of are and , so has entries , , , . That is ✓, and the zero below the diagonal is exactly the statement . The diagonal: and ✓, both positive as the theorem requires.
Multiplying out, column of is ✓ and column is ✓.
(c) A tall . is ; only square matrices have inverses. Concretely, its two columns span a plane in , so is not onto and no matrix can undo it. What does satisfy is .
Now , so : the matrix fixes . And , so .
Since is orthogonal to both columns of , it spans , which has dimension . A matrix that fixes (it fixes , and likewise ) and annihilates is the orthogonal projection onto — which is also what the formula for orthonormal columns says. For the record,
symmetric with trace , and certainly not .
- 9.Critique
A student is asked for the least-squares solution of , where
and submits the following.
Step 1. The columns and are orthogonal, so is diagonal: .
Step 2. Because the columns are orthogonal, the least-squares solution can be read off by dot products, just as coordinates in an orthogonal basis are: and .
Step 3. Check: , which is not . But a least-squares solution is not supposed to satisfy , so this is expected and confirms that nothing is wrong.
Step 4. The least-squares error is .
Step 1 is correct. Each of the other three steps contains an error.
- (a)For Steps 2, 3 and 4, name the error, state the correct principle that was misapplied, and say how the student could have detected the error of Step 2 from their own numbers.
- (b)Solve the problem correctly: find , the residual and the least-squares error, and perform the check that actually certifies a least-squares solution.
Solution
(a) Step 2 — the missing denominators. The principle is right: with orthogonal columns the normal equations decouple and consists of the coefficients of in the orthogonal basis . But that coefficient formula is ; the version with no denominator is for orthonormal vectors only. Here and , so and are too large by exactly those factors. The student's own Step 1 contained the denominators: the normal equations read , which forces .
Step 3 — a non-check. The statement is true of every least-squares solution of an inconsistent system, so observing it cannot tell a right answer from a wrong one. The check that certifies a least-squares solution is : the residual must be orthogonal to every column. With the student's the residual is and
which would have exposed Step 2 at once. A cruder detector was also available: the student's error exceeds , yet already achieves error , so no minimiser can do worse than that.
Step 4 — off by a square root. The least-squares error is the length . The squared length is the quantity being minimised, but the error reported is the norm. (And is built from the wrong in any case.)
(b) The correct solution. Normal equations: and , so . Then
The certifying check: ✓. The error is
Cross-check by the Pythagorean shortcut: and , and ✓.
- 10.Computation
Four measurements are taken: . All arithmetic is exact; keep fractions.
- (a)Set up the design matrix for the model , form and , and solve the normal equations for and .
- (b)Compute the four residuals and verify the identities and , explaining where each comes from. Then find the least-squares error two ways: directly from the residuals, and from .
- (c)A colleague proposes the richer model . Without solving anything new, explain what happens to , describe the full set of least-squares solutions, and explain why the fitted values are the same as in (a).
Solution
(a) The normal equations. One row per observation, one column per parameter:
The sums are , , , , , so
The determinant is , so and
The fitted line is . Check the first normal equation: ✓.
(b) Residuals. The fitted values at are , so
✓ and ✓. Both come from the normal equations in the form : the first row of is the column of ones, giving , and the second row is the column of -values, giving . The residual is orthogonal to every column of the design matrix.
Error, directly. , so the least-squares error is .
Error, by Pythagoras. and , and ✓. The identity holds because .
(c) A redundant column. The new column has entries , which is twice the -column plus the column of ones: the three columns are linearly dependent. By the lemma on , (now ) is invertible if and only if the columns are independent, so it is singular. The normal equations are still consistent — they always are — but have infinitely many solutions.
To describe them, rewrite the model as : it is the same family of lines. So the least-squares solutions are exactly the triples with and , the line
where spans (each row gives ✓).
The fitted values are , and this depends only on the subspace . Adding a column that already lies in the span of the old ones leaves unchanged, so the projection, the residuals and the error are all identical to (a). The projection is unique even when the coefficient vector is not.
- 11.Proof
Let be a subspace of and let be the matrix of orthogonal projection onto . You may use that is symmetric and idempotent, and the Orthogonal Decomposition Theorem.
- (a)Prove that for every , with equality if and only if .
- (b)Let . Prove that and that is symmetric and orthogonal. Determine for and for , and describe geometrically.
- (c)Take with a unit vector, and let . For write out as a matrix, verify and for , and compute for together with a check that its length is preserved.
Solution
(a) Projection shrinks. Write . The first piece lies in . The second lies in : for any ,
using symmetry and then idempotence. (Equivalently: this is the orthogonal decomposition of , with .) The two pieces are orthogonal, so by the Pythagorean theorem
and taking square roots gives .
Equality holds if and only if , i.e. , which places in . Conversely, if then is a decomposition with and , so by uniqueness in the Orthogonal Decomposition Theorem and equality holds.
(b) A reflection. and . Next . Symmetry: . Orthogonality:
For , as in (a), so . For the decomposition gives , so . Hence for a general we get : keeps the component in and reverses the component in . It is the reflection of through . Being orthogonal it preserves lengths, which agrees with , and says reflecting twice is the identity. (Along the way: is symmetric and idempotent with , , so it is the projection onto .)
(c) A Householder reflection. For a line, , so . It is symmetric and orthogonal with , and by (b) it sends while fixing every vector orthogonal to : the reflection in the plane .
Numerically, , so
✓. For : , so , and ✓.
For use with :
(Matrix check: , the same.) Lengths: and ✓, as an orthogonal matrix requires.
- 12.Proof
Let be an matrix and . Do not assume the columns of are independent unless a part says so. Name every theorem you use (Rank–Nullity, the fundamental orthogonality relations, the Pythagorean theorem, the normal-equations theorem).
- (a)Prove that , and deduce that . Conclude that the normal equations are consistent for every .
- (b)Prove that if and are both least-squares solutions then . Describe the complete set of least-squares solutions in terms of one of them and a subspace, and say when it is a single point.
- (c)Let be a least-squares solution and . Prove that , and deduce that the least-squares error equals exactly when .
Solution
(a) Null spaces. If then , so . Conversely, if , multiply on the left by :
so by positive definiteness. Hence .
Column spaces. is and is , so both column spaces live inside and can be compared. By Rank–Nullity applied to the two -column matrices and ,
and because row rank equals column rank. Every vector of has the form , so . A subspace contained in another of the same finite dimension equals it: .
Consistency. , and membership in is exactly the statement that has a solution. (The projection proof of the same fact argues through ; this one never mentions a projection.)
(b) The projection is unique. By the normal-equations theorem, least-squares solutions are exactly the solutions of . Subtracting the two equations, , so by (a), i.e. .
The same computation read backwards describes the whole set: if is one least-squares solution and , then , so is another; and every other differs from by an element of . The set is the translate . It is a single point exactly when , i.e. when the columns of are independent — which by the lemma on is also exactly when is invertible and .
(c) Pythagoras for the residual. The normal equations say . Therefore
so . Since , the Pythagorean theorem gives . (In particular always, as it must be, since is a competitor with error .)
When the error is as bad as possible. By the identity, if and only if , i.e. . If that holds, then , so . Conversely, if then solves the normal equations, so by (b) every least-squares solution has and the error is . By the fundamental orthogonality relation , so this is the case in which has no component in any direction the columns of can reach: the best the model can do is predict , and it explains nothing.