CalcPath
ProgressProblem setsFeedback
← Question sheet

Linear Algebra · Solutions

Orthogonality and Least Squares

12 questions · about 108 minutes

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. 1.Computation

    Leave every square root exact. In each part say which property of the dot product, or which named theorem, you are using.

    1. (a)Let u=⟨2,3,−6⟩ and v=⟨6,−2,3⟩. Compute ∥u∥, ∥v∥, dist(u,v) and cosθ for the angle θ between them. Then confirm the distance a second way, using only the three numbers ∥u∥, ∥v∥ and u⋅v.
    2. (b)Find every real t for which a=⟨t,t,1⟩ and b=⟨t,2,−3⟩ are orthogonal, and check each value you find.
    3. (c)Let w=⟨2,−1,0,2⟩ and z=⟨1,2,2,0⟩ in R4. Show that w⊥z, then compute ∥w+z∥ twice: once from the entries of w+z and once without them. Explain why ∥w+z∥=∥w∥+∥z∥ is not a contradiction.

    Solution

    (a) Lengths and angle. ∥u∥2=4+9+36=49, so ∥u∥=7; likewise ∥v∥2=36+4+9=49 and ∥v∥=7. The dot product is u⋅v=12−6−18=−12, so

    cosθ=∥u∥∥v∥u⋅v​=−4912​,

    which is negative: the angle is obtuse. Cauchy–Schwarz is comfortably satisfied, ∣−12∣≤49, which is why a cosine came out.

    Distance directly. u−v=⟨−4,5,−9⟩, so ∥u−v∥2=16+25+81=122 and dist(u,v)=122​.

    Distance from the three numbers. Expand with linearity and symmetry of the dot product:

    ∥u−v∥2=u⋅u−2u⋅v+v⋅v=49+24+49=122. ✓

    (b) One scalar equation. a⋅b=t2+2t−3=(t+3)(t−1), which vanishes exactly for t=1 and t=−3. Check t=1: ⟨1,1,1⟩⋅⟨1,2,−3⟩=1+2−3=0 ✓. Check t=−3: ⟨−3,−3,1⟩⋅⟨−3,2,−3⟩=9−6−3=0 ✓. Orthogonality is a single scalar condition; here it happens to be quadratic in t, so it has two solutions rather than one.

    (c) Pythagoras. w⋅z=2−2+0+0=0, so w⊥z. From the entries, w+z=⟨3,1,2,2⟩ and ∥w+z∥2=9+1+4+4=18, so ∥w+z∥=32​.

    Without the entries: ∥w∥2=4+1+0+4=9 and ∥z∥2=1+4+4+0=9, and because the vectors are orthogonal the Pythagorean theorem gives ∥w+z∥2=9+9=18 ✓.

    Meanwhile ∥w∥+∥z∥=6=32​. There is no contradiction: Pythagoras is a statement about squared lengths. The equation ∥w+z∥=∥w∥+∥z∥ 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. 2.Computation

    Let W=Span{w1​,w2​}⊆R4 with w1​=⟨1,2,0,−1⟩ and w2​=⟨0,1,1,1⟩.

    1. (a)Find a basis for W⊥. State which result lets you replace the condition “orthogonal to every vector of W” by finitely many equations, and confirm that dimW+dimW⊥=4.
    2. (b)Decide whether y=⟨5,−2,1,1⟩ and y′=⟨1,0,1,1⟩ belong to W⊥. For whichever does, write it as a combination of your basis vectors from (a).
    3. (c)Let A be the 2×4 matrix whose rows are w1​ and w2​. Give the dimension of each of the four fundamental subspaces of A, identify which of them is W⊥, and explain what the dimension of NulAT tells you about the system Ax=b.

    Solution

    (a) Set up the equations. By the finite test for orthogonal complements — a vector is in W⊥ if and only if it is orthogonal to each vector of a spanning set of W — v=⟨v1​,v2​,v3​,v4​⟩ lies in W⊥ exactly when v⋅w1​=0 and v⋅w2​=0:

    v1​+2v2​−v4​=0,v2​+v3​+v4​=0.

    Row-reduce the coefficient matrix: subtracting twice the second row from the first turns (10​21​01​−11​) into (10​01​−21​−31​). Pivots sit in columns 1 and 2, so v3​=s and v4​=t are free, v1​=2s+3t and v2​=−s−t:

    v=s⟨2,−1,1,0⟩+t⟨3,−1,0,1⟩.

    A basis of W⊥ is {⟨2,−1,1,0⟩, ⟨3,−1,0,1⟩}; the two are independent because of the 1,0 and 0,1 pattern in the free positions. Check all four dot products: ⟨2,−1,1,0⟩⋅w1​=2−2+0+0=0, ⟨2,−1,1,0⟩⋅w2​=0−1+1+0=0, ⟨3,−1,0,1⟩⋅w1​=3−2+0−1=0, ⟨3,−1,0,1⟩⋅w2​=0−1+0+1=0 ✓.

    Since w1​,w2​ are not multiples of each other, dimW=2, and dimW⊥=2, so 2+2=4=n ✓, as the dimension theorem for complements requires.

    (b) Two membership tests. y⋅w1​=5−4+0−1=0 and y⋅w2​=0−2+1+1=0, so y∈W⊥. For y′: y′⋅w1​=1+0+0−1=0 but y′⋅w2​=0+0+1+1=2=0, so y′∈/W⊥ — one failed equation is enough.

    To express y, read the free positions: the third and fourth entries force s=1 and t=1, and indeed ⟨2,−1,1,0⟩+⟨3,−1,0,1⟩=⟨5,−2,1,1⟩ ✓.

    (c) The four subspaces. The rows are independent, so rankA=2, with m=2, n=4. Hence dimRowA=2 and dimNulA=4−2=2 in R4; dimColA=2 and dimNulAT=2−2=0 in R2.

    By the fundamental orthogonality relation (RowA)⊥=NulA, and RowA=W, so W⊥=NulA — which is exactly the homogeneous system solved in (a).

    NulAT={0} means (ColA)⊥={0}, so ColA is all of R2: every b∈R2 is reachable and Ax=b is consistent for every right-hand side. There is no direction in R2 that this matrix cannot reach, so least squares would never be needed for it.

  3. 3.Computation

    Let u1​=⟨2,2,1⟩, u2​=⟨1,−2,2⟩, u3​=⟨2,−1,−2⟩ and y=⟨4,4,−7⟩.

    1. (a)Show that {u1​,u2​,u3​} is an orthogonal basis of R3, quoting the theorem that spares you a row reduction, and write y as a combination of the three vectors without solving a linear system.
    2. (b)Let Q be the 3×3 matrix whose columns are u1​/3, u2​/3, u3​/3. Explain, without multiplying anything out, why QTQ=I and what Q−1 is. Then solve Qx=y and verify that ∥x∥=∥y∥.
    3. (c)A classmate writes y=(y⋅u1​)u1​+(y⋅u2​)u2​+(y⋅u3​)u3​. 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. u1​⋅u2​=2−4+2=0, u1​⋅u3​=4−2−2=0, u2​⋅u3​=2+2−4=0. 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 R3 form a basis.

    Coefficients. In an orthogonal basis cj​=uj​⋅uj​y⋅uj​​. All three denominators equal 9 (4+4+1, 1+4+4, 4+1+4). The numerators are

    y⋅u1​=8+8−7=9,y⋅u2​=4−8−14=−18,y⋅u3​=8−4+14=18,

    so c1​=1, c2​=−2, c3​=2 and y=u1​−2u2​+2u3​. Check: ⟨2−2+4, 2+4−2, 1−4−4⟩=⟨4,4,−7⟩ ✓.

    (b) An orthogonal matrix. Each column of Q has length 9​/3=1, and dividing by 3 leaves a zero dot product zero, so the columns are orthonormal. The (i,j) entry of QTQ is the dot product of columns i and j, hence QTQ=I. Because Q is square this makes it an orthogonal matrix, and Q−1=QT.

    So x=QTy, whose entries are the dot products of y with the columns: x=31​⟨9,−18,18⟩=⟨3,−6,6⟩. Check: Qx=31​(3u1​−6u2​+6u3​)=u1​−2u2​+2u3​=y ✓. Lengths: ∥x∥2=9+36+36=81 and ∥y∥2=16+16+49=81 ✓ — multiplication by a matrix with orthonormal columns preserves length. (x is just the coordinate vector of y in the orthonormal basis: each entry is 3cj​.)

    (c) The missing denominators. The right-hand side is 9u1​−18u2​+18u3​=9(u1​−2u2​+2u3​)=9y=⟨36,36,−63⟩, nine times too large. The formula cj​=y⋅uj​ requires an orthonormal basis. These vectors are orthogonal but each has length 3, so every coefficient is missing its denominator uj​⋅uj​=9.

  4. 4.Computation

    Let W=Span{u1​,u2​}⊆R3 with u1​=⟨1,0,−1⟩ and u2​=⟨1,1,1⟩, and let y=⟨2,0,4⟩.

    1. (a)Verify that {u1​,u2​} is an orthogonal basis of W, compute y^​=projW​y and z=y−y^​, and find dist(y,W). Check that z∈W⊥ and check the identity ∥y∥2=∥y^​∥2+∥z∥2.
    2. (b)Find a vector n spanning W⊥ and recompute z by projecting y onto the line through n. Explain why the two routes must agree, naming the theorem.
    3. (c)Write down the projection matrix P onto W using the orthonormal-columns formula P=UUT, confirm Py=y^​, and identify I−P in terms of n.

    Solution

    (a) Project with the orthogonal basis. u1​⋅u2​=1+0−1=0 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

    y^​=u1​⋅u1​y⋅u1​​u1​+u2​⋅u2​y⋅u2​​u2​=2−2​⟨1,0,−1⟩+36​⟨1,1,1⟩=⟨1,2,3⟩,

    using y⋅u1​=2+0−4=−2, u1​⋅u1​=2, y⋅u2​=2+0+4=6, u2​⋅u2​=3. Then z=⟨2,0,4⟩−⟨1,2,3⟩=⟨1,−2,1⟩ and, by the Best Approximation Theorem, dist(y,W)=∥z∥=6​.

    Checks: z⋅u1​=1−1=0 and z⋅u2​=1−2+1=0, so z∈W⊥ by the finite test ✓. Pythagoras: ∥y∥2=4+0+16=20, ∥y^​∥2=1+4+9=14, ∥z∥2=6, and 14+6=20 ✓.

    (b) The complement route. n⊥u1​ gives n1​−n3​=0 and n⊥u2​ gives n1​+n2​+n3​=0, so n1​=n3​=s and n2​=−2s: n=⟨1,−2,1⟩ spans W⊥, which has dimension 3−2=1. Projecting onto that line,

    projn​y=n⋅ny⋅n​n=62+0+4​⟨1,−2,1⟩=⟨1,−2,1⟩=z ✓,

    and y^​=y−z=⟨1,2,3⟩ again. The routes must agree by the uniqueness in the Orthogonal Decomposition Theorem: y=y^​+z with y^​∈W and z∈W⊥ can be done in only one way, and the W⊥-component of y is by definition projW⊥​y, which is the projection onto the line through n.

    (c) The matrix. With U=[u1​/2​  u2​/3​],

    P=UUT=2u1​u1T​​+3u2​u2T​​=61​​3​10−1​000​−101​​+2​111​111​111​​​=61​​52−1​222​−125​​.

    Then Py=61​⟨10+0−4, 4+0+8, −2+0+20⟩=61​⟨6,12,18⟩=⟨1,2,3⟩=y^​ ✓. P is visibly symmetric and trP=612​=2=dimW.

    Finally

    I−P=61​​1−21​−24−2​1−21​​=n⋅nnnT​,

    since n⋅n=6: it is the projection matrix onto the line W⊥, exactly as the theorem on symmetric idempotents promises.

  5. 5.Sketch

    Let A=(13​26​). This question is about drawing the four fundamental subspaces of A accurately: every line you draw must be labelled with a spanning vector, and every vector you place must be justified by a computation.

    1. (a)Find a basis for each of RowA, NulA, ColA and NulAT, state each dimension, and verify both fundamental orthogonality relations by a dot product.
    2. (b)Draw two copies of R2 side by side: the domain, showing RowA and NulA, and the codomain, showing ColA and NulAT. In the domain draw x=⟨3,1⟩ and its components xr​∈RowA and xn​∈NulA. In the codomain draw Ax, Axr​ and Axn​, and say what the picture shows about which part of x survives.
    3. (c)Add b=⟨1,1⟩ to the codomain picture together with its components in ColA and in NulAT. Explain from the picture why Ax=b has no solution, and find the vector of RowA that A sends to the ColA-component of b.

    Solution

    (a) Four bases. The second row is three times the first, so rankA=1 and each of the four subspaces is a line.

    RowA=Span{⟨1,2⟩}, dimension 1. NulA: x1​+2x2​=0, so Span{⟨−2,1⟩}, dimension 2−1=1. ColA=Span{⟨1,3⟩} (the second column is twice the first), dimension 1. NulAT: AT=(12​36​) gives y1​+3y2​=0, so Span{⟨−3,1⟩}, dimension 2−1=1.

    Orthogonality: ⟨1,2⟩⋅⟨−2,1⟩=−2+2=0, so RowA⊥NulA; and ⟨1,3⟩⋅⟨−3,1⟩=−3+3=0, so ColA⊥NulAT ✓. In each copy of R2 the dimensions add to 1+1=2.

    (b) The domain. Draw RowA as the line through the origin in direction ⟨1,2⟩ (slope 2) and NulA as the line in direction ⟨−2,1⟩ (slope −21​); the two are perpendicular. Project x onto the row line:

    xr​=⟨1,2⟩⋅⟨1,2⟩x⋅⟨1,2⟩​⟨1,2⟩=53+2​⟨1,2⟩=⟨1,2⟩,xn​=x−xr​=⟨2,−1⟩,

    and ⟨2,−1⟩=−⟨−2,1⟩ does lie in NulA ✓. Draw x from the origin to (3,1), xr​ along the row line to (1,2), xn​ along the null line to (2,−1); x is the diagonal of the rectangle they span.

    The codomain. Draw ColA in direction ⟨1,3⟩ (slope 3) and NulAT in direction ⟨−3,1⟩ (slope −31​), again perpendicular. Compute

    Ax=⟨3+2, 9+6⟩=⟨5,15⟩,Axr​=⟨1+4, 3+12⟩=⟨5,15⟩,Axn​=⟨2−2, 6−6⟩=⟨0,0⟩.

    So Ax and Axr​ are the same arrow, 5⟨1,3⟩, lying on the ColA line, and Axn​ is a dot at the origin. The picture says: the null-space component of x 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 (⟨1,2⟩↦5⟨1,3⟩).

    (c) An unreachable target. Project b onto ColA:

    b^=1+91+3​⟨1,3⟩=⟨52​,56​⟩,b−b^=⟨53​,−51​⟩=−51​⟨−3,1⟩∈NulAT ✓.

    Draw b to (1,1), b^ on the column line, and the short perpendicular leg from b^ to b running parallel to NulAT. Every vector Ax lies on the line ColA, and b does not: it has the nonzero component ⟨53​,−51​⟩ in the perpendicular direction NulAT, which no input can produce. That is what inconsistency looks like.

    For the last part write xr​=t⟨1,2⟩; then Axr​=t⟨5,15⟩, and this equals ⟨52​,56​⟩ when t=252​. So xr​=⟨252​,254​⟩. Check: Axr​=⟨252​+258​, 256​+2524​⟩=⟨52​,56​⟩ ✓. (Adding any multiple of ⟨−2,1⟩ gives another vector with the same image; the one in RowA is the shortest of them.)

  6. 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, {u1​,…,up​} is an orthonormal set in Rn.

    1. (a)Prove the polarization identity u⋅v=41​(∥u+v∥2−∥u−v∥2). Then prove: if a square matrix Q satisfies ∥Qx∥=∥x∥ for every x, then Q is an orthogonal matrix.
    2. (b)Prove Bessel's inequality: for every y∈Rn, j=1∑p​(y⋅uj​)2≤∥y∥2, with equality if and only if y∈Span{u1​,…,up​}.
    3. (c)Show that a matrix which is both orthogonal and symmetric satisfies Q2=I, and give a 2×2 example other than ±I.

    Solution

    (a) Polarization. Expand both squares using linearity in each slot and symmetry:

    ∥u+v∥2=u⋅u+2u⋅v+v⋅v,∥u−v∥2=u⋅u−2u⋅v+v⋅v.

    Subtracting, the squared lengths cancel and 4u⋅v remains; divide by 4. ■

    Length-preserving implies orthogonal. Let x,y be arbitrary. Apply polarization to Qx and Qy, use linearity of Q, then the hypothesis:

    (Qx)⋅(Qy)=41​(∥Q(x+y)∥2−∥Q(x−y)∥2)=41​(∥x+y∥2−∥x−y∥2)=x⋅y.

    Now the (i,j) entry of QTQ is the dot product of columns i and j of Q, that is (Qei​)⋅(Qej​)=ei​⋅ej​, which is 1 if i=j and 0 otherwise. Hence QTQ=I, and since Q 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 y^​=∑j​(y⋅uj​)uj​ and z=y−y^​. For each k,

    z⋅uk​=y⋅uk​−j∑​(y⋅uj​)(uj​⋅uk​)=y⋅uk​−(y⋅uk​)⋅1=0,

    because orthonormality kills every term with j=k and leaves uk​⋅uk​=1. As y^​ is a combination of the uj​, linearity gives z⋅y^​=0. By the Pythagorean theorem,

    ∥y∥2=∥y^​+z∥2=∥y^​∥2+∥z∥2.

    Expanding ∥y^​∥2=y^​⋅y^​=∑j​∑k​(y⋅uj​)(y⋅uk​)(uj​⋅uk​)=∑j​(y⋅uj​)2 by the same orthonormality. Therefore

    j=1∑p​(y⋅uj​)2=∥y∥2−∥z∥2≤∥y∥2.

    Equality holds if and only if ∥z∥2=0, if and only if z=0 (positive definiteness), if and only if y=y^​, which lies in the span. Conversely, if y=∑j​cj​uj​ is in the span, dotting with uk​ gives ck​=y⋅uk​ (the coefficient theorem for orthonormal bases), so y=y^​, z=0, and equality holds. ■

    (In the language of projections, y^​ is projW​y for W the span and z is the error; Bessel is Pythagoras for that decomposition.)

    (c) Symmetric orthogonal matrices. If QT=Q and QTQ=I then Q2=QQ=QTQ=I. Example: Q=(01​10​), which is symmetric and whose columns e2​,e1​ are orthonormal; indeed Q2=I. Geometrically it reflects the plane in the line y=x, and reflecting twice is the identity. (Another: diag(1,−1), reflection in the x-axis.)

  7. 7.Computation

    Let x1​=⟨2,1,2⟩, x2​=⟨1,1,0⟩ and x3​=⟨0,1,1⟩; you may take for granted that they form a basis of R3. Keep the arithmetic in integers by rescaling wherever it helps, and say each time why rescaling is legitimate.

    1. (a)Run the Gram–Schmidt process in the order x1​,x2​,x3​ to obtain an orthogonal basis {v1​,v2​,v3​} and then an orthonormal basis {u1​,u2​,u3​}. Check every orthogonality you claim.
    2. (b)Express x2​ and x3​ as combinations of u1​,u2​,u3​. Which of the uj​ does each one use, and which of those facts was guaranteed before you computed anything?
    3. (c)Now start again in the order x3​,x2​,x1​ 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 ⟨1,−1,1⟩.

    Solution

    (a) Step 1. v1​=x1​=⟨2,1,2⟩, with v1​⋅v1​=9.

    Step 2. x2​⋅v1​=2+1+0=3, so

    v2​=x2​−93​v1​=⟨1,1,0⟩−31​⟨2,1,2⟩=⟨31​,32​,−32​⟩.

    Rescale by 3 to v2​=⟨1,2,−2⟩: multiplying by a nonzero scalar changes neither the span nor orthogonality to v1​. Check v1​⋅v2​=2+2−4=0 ✓; note v2​⋅v2​=9.

    Step 3. x3​⋅v1​=0+1+2=3 and x3​⋅v2​=0+2−2=0, so

    v3​=x3​−93​v1​−90​v2​=⟨0,1,1⟩−31​⟨2,1,2⟩=⟨−32​,32​,31​⟩,

    rescaled to v3​=⟨−2,2,1⟩. Checks: v3​⋅v1​=−4+2+2=0 ✓ and v3​⋅v2​=−2+4−2=0 ✓. (Both projections were subtracted from the original x3​, even though one of them happened to be zero.)

    All three vectors have squared length 9, so the orthonormal basis is

    u1​=31​⟨2,1,2⟩,u2​=31​⟨1,2,−2⟩,u3​=31​⟨−2,2,1⟩.

    (b) Coordinates by dot products. In an orthonormal basis the coefficient of uj​ is the dot product with uj​. For x2​: x2​⋅u1​=33​=1, x2​⋅u2​=31+2+0​=1, x2​⋅u3​=3−2+2+0​=0, so x2​=u1​+u2​. For x3​: x3​⋅u1​=1, x3​⋅u2​=0, x3​⋅u3​=30+2+1​=1, so x3​=u1​+u3​. Checks: u1​+u2​=31​⟨3,3,0⟩=⟨1,1,0⟩ ✓ and u1​+u3​=31​⟨0,3,3⟩=⟨0,1,1⟩ ✓.

    That x2​ uses no u3​ was guaranteed in advance: the correctness theorem says Span{v1​,v2​}=Span{x1​,x2​}, so x2​∈Span{u1​,u2​} — this is the triangular pattern that becomes the matrix R in the QR factorization. That x3​ uses no u2​ was not guaranteed; it is the accident x3​⊥v2​ discovered in step 3.

    (c) Reversed order. v1​=x3​=⟨0,1,1⟩, v1​⋅v1​=2, and x2​⋅v1​=0+1+0=1, so

    v2​=⟨1,1,0⟩−21​⟨0,1,1⟩=⟨1,21​,−21​⟩ ⟶ ⟨2,1,−1⟩,

    with ⟨2,1,−1⟩⋅⟨0,1,1⟩=0+1−1=0 ✓. Neither vector appeared in (a): the first output is always a multiple of the first input, so the order matters.

    Third step without computing: v3​ is x1​ minus its projection onto Span{v1​,v2​}=Span{x3​,x2​}, so by the correctness theorem v3​ lies in Span{x2​,x3​}⊥, a subspace of dimension 3−2=1. Since ⟨1,−1,1⟩⋅⟨1,1,0⟩=0 and ⟨1,−1,1⟩⋅⟨0,1,1⟩=0, that vector spans the line, and v3​=0 by the theorem's first claim. Hence v3​ is a nonzero multiple of ⟨1,−1,1⟩. (Carrying the step out gives exactly ⟨1,−1,1⟩.) The two orthogonal bases share no vector, but both span R3: only the subspace is order-independent.

  8. 8.Computation

    Let A=​221​131​​.

    1. (a)Find the QR factorization of A with positive diagonal in R. Give both factors exactly.
    2. (b)Verify R=QTA by computing all four entries of QTA directly, confirm that the diagonal entries of R are the lengths of the un-normalised Gram–Schmidt vectors, and multiply QR out to recover A.
    3. (c)Explain why Q−1 does not exist. Then, without forming QQT, compute QQTx1​ for the first column x1​ of A and QQTn for n=⟨1,1,−4⟩, and say what QQT is.

    Solution

    (a) Gram–Schmidt on the columns. x1​=⟨2,2,1⟩ and x2​=⟨1,3,1⟩ are not proportional, so the columns are independent and the theorem applies. v1​=x1​, ∥v1​∥=4+4+1​=3, u1​=31​⟨2,2,1⟩. Then x2​⋅v1​=2+6+1=9 and v1​⋅v1​=9, so

    v2​=x2​−99​v1​=⟨−1,1,0⟩,∥v2​∥=2​,u2​=2​1​⟨−1,1,0⟩.

    Check u1​⋅u2​=32​−2+2+0​=0 ✓.

    The factors. rjk​=xk​⋅uj​ for j≤k: r11​=x1​⋅u1​=39​=3, r12​=x2​⋅u1​=39​=3, r22​=x2​⋅u2​=2​−1+3+0​=2​2​=2​. So

    Q=​2/32/31/3​−1/2​1/2​0​​,R=(30​32​​).

    (b) Checks. The rows of QT are u1T​ and u2T​, so QTA has entries u1​⋅x1​=3, u1​⋅x2​=3, u2​⋅x1​=2​−2+2+0​=0, u2​⋅x2​=2​. That is R ✓, and the zero below the diagonal is exactly the statement x1​⊥u2​. The diagonal: r11​=3=∥v1​∥ and r22​=2​=∥v2​∥ ✓, both positive as the theorem requires.

    Multiplying out, column 1 of QR is 3u1​+0⋅u2​=⟨2,2,1⟩ ✓ and column 2 is 3u1​+2​u2​=⟨2,2,1⟩+⟨−1,1,0⟩=⟨1,3,1⟩ ✓.

    (c) A tall Q. Q is 3×2; only square matrices have inverses. Concretely, its two columns span a plane in R3, so Q is not onto and no matrix can undo it. What Q does satisfy is QTQ=I2​.

    Now QTx1​=⟨u1​⋅x1​, u2​⋅x1​⟩=⟨3,0⟩, so QQTx1​=Q⟨3,0⟩=3u1​=x1​: the matrix fixes x1​. And QTn=⟨32+2−4​, 2​−1+1+0​⟩=⟨0,0⟩, so QQTn=0.

    Since n is orthogonal to both columns of A, it spans (ColA)⊥, which has dimension 3−2=1. A matrix that fixes ColA (it fixes x1​, and likewise x2​=Q⟨3,2​⟩) and annihilates (ColA)⊥ is the orthogonal projection onto ColA — which is also what the formula P=UUT for orthonormal columns says. For the record,

    QQT=u1​u1T​+u2​u2T​=181​​17−14​−1174​442​​,

    symmetric with trace 1836​=2=dimColA, and certainly not I3​.

  9. 9.Critique

    A student is asked for the least-squares solution of Ax=b, where

    A=​112​1−10​​,b=​132​​,

    and submits the following.

    Step 1. The columns a1​=⟨1,1,2⟩ and a2​=⟨1,−1,0⟩ are orthogonal, so ATA is diagonal: ATA=diag(6,2).

    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: x^1​=b⋅a1​=1+3+4=8 and x^2​=b⋅a2​=1−3+0=−2.

    Step 3. Check: Ax^=⟨6,10,16⟩, which is not b. But a least-squares solution is not supposed to satisfy Ax=b, so this is expected and confirms that nothing is wrong.

    Step 4. The least-squares error is ∥b−Ax^∥2=25+49+196=270.

    Step 1 is correct. Each of the other three steps contains an error.

    1. (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.
    2. (b)Solve the problem correctly: find x^, 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 x^ consists of the coefficients of projColA​b in the orthogonal basis {a1​,a2​}. But that coefficient formula is cj​=aj​⋅aj​b⋅aj​​; the version with no denominator is for orthonormal vectors only. Here a1​⋅a1​=6 and a2​⋅a2​=2, so 8 and −2 are too large by exactly those factors. The student's own Step 1 contained the denominators: the normal equations read diag(6,2)x^=ATb=⟨8,−2⟩, which forces x^=⟨68​,2−2​⟩.

    Step 3 — a non-check. The statement Ax^=b 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 AT(b−Ax^)=0: the residual must be orthogonal to every column. With the student's x^ the residual is r=b−Ax^=⟨−5,−7,−14⟩ and

    ATr=⟨−5−7−28, −5+7⟩=⟨−40,2⟩=0,

    which would have exposed Step 2 at once. A cruder detector was also available: the student's error ∥r∥=270​ exceeds ∥b∥=14​, yet x=0 already achieves error ∥b∥, so no minimiser can do worse than that.

    Step 4 — off by a square root. The least-squares error is the length ∥b−Ax^∥. The squared length is the quantity being minimised, but the error reported is the norm. (And 270 is built from the wrong x^ in any case.)

    (b) The correct solution. Normal equations: ATA=diag(6,2) and ATb=⟨8,−2⟩, so x^=⟨34​,−1⟩. Then

    Ax^=⟨34​−1, 34​+1, 38​⟩=⟨31​,37​,38​⟩,r=b−Ax^=⟨32​,32​,−32​⟩.

    The certifying check: ATr=⟨32​+32​−34​, 32​−32​⟩=⟨0,0⟩ ✓. The error is

    ∥r∥=3⋅94​​=3​2​=323​​.

    Cross-check by the Pythagorean shortcut: ∥b∥2=14 and ∥Ax^∥2=91+49+64​=338​, and 14−338​=34​=∥r∥2 ✓.

  10. 10.Computation

    Four measurements are taken: (x,y)=(0,1), (1,3), (2,2), (3,6). All arithmetic is exact; keep fractions.

    1. (a)Set up the design matrix X for the model y=β0​+β1​x, form XTX and XTy, and solve the normal equations for β^​0​ and β^​1​.
    2. (b)Compute the four residuals and verify the identities ∑ri​=0 and ∑xi​ri​=0, explaining where each comes from. Then find the least-squares error two ways: directly from the residuals, and from ∥y∥2−∥Xβ^​∥2.
    3. (c)A colleague proposes the richer model y=β0​+β1​x+β2​(2x+1). Without solving anything new, explain what happens to XTX, 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:

    X=​1111​0123​​,y=​1326​​.

    The sums are m=4, ∑xi​=6, ∑xi2​=0+1+4+9=14, ∑yi​=12, ∑xi​yi​=0+3+4+18=25, so

    XTX=(46​614​),XTy=(1225​).

    The determinant is 56−36=20, so (XTX)−1=201​(14−6​−64​) and

    β^​=201​(14⋅12−6⋅25−6⋅12+4⋅25​)=201​(1828​)=(9/107/5​).

    The fitted line is y=109​+57​x. Check the first normal equation: 4⋅109​+6⋅57​=518​+542​=12 ✓.

    (b) Residuals. The fitted values at x=0,1,2,3 are 109​,1023​,1037​,1051​, so

    r=y−Xβ^​=⟨101​, 107​, −1017​, 109​⟩.

    ∑ri​=101+7−17+9​=0 ✓ and ∑xi​ri​=100+7−34+27​=0 ✓. Both come from the normal equations in the form XTr=0: the first row of XT is the column of ones, giving ∑ri​=0, and the second row is the column of x-values, giving ∑xi​ri​=0. The residual is orthogonal to every column of the design matrix.

    Error, directly. ∥r∥2=1001+49+289+81​=100420​=521​, so the least-squares error is 21/5​=5105​​.

    Error, by Pythagoras. ∥y∥2=1+9+4+36=50 and ∥Xβ^​∥2=10081+529+1369+2601​=1004580​=5229​, and 50−5229​=521​ ✓. The identity holds because Xβ^​⊥r.

    (c) A redundant column. The new column has entries 2xi​+1, which is twice the x-column plus the column of ones: the three columns are linearly dependent. By the lemma on ATA, XTX (now 3×3) 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 y=(β0​+β2​)+(β1​+2β2​)x: it is the same family of lines. So the least-squares solutions are exactly the triples with β0​+β2​=109​ and β1​+2β2​=57​, the line

    β^​=⟨109​,57​,0⟩+t⟨−1,−2,1⟩,t∈R,

    where ⟨−1,−2,1⟩ spans NulX (each row gives −1−2xi​+(2xi​+1)=0 ✓).

    The fitted values are Xβ^​=projColX​y, and this depends only on the subspace ColX. Adding a column that already lies in the span of the old ones leaves ColX 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. 11.Proof

    Let W be a subspace of Rn and let P be the matrix of orthogonal projection onto W. You may use that P is symmetric and idempotent, and the Orthogonal Decomposition Theorem.

    1. (a)Prove that ∥Py∥≤∥y∥ for every y, with equality if and only if y∈W.
    2. (b)Let Q=I−P. Prove that PQ=QP=0 and that F=P−Q is symmetric and orthogonal. Determine Fw for w∈W and Fz for z∈W⊥, and describe F geometrically.
    3. (c)Take W=Span{u} with u a unit vector, and let H=Q−P=I−2uuT. For u=31​⟨2,−1,2⟩ write H out as a 3×3 matrix, verify Hu=−u and Hw=w for w=⟨1,2,0⟩, and compute Hy for y=⟨3,0,3⟩ together with a check that its length is preserved.

    Solution

    (a) Projection shrinks. Write y=Py+(y−Py). The first piece lies in W. The second lies in W⊥: for any w=Pu∈W,

    (y−Py)⋅Pu=yT(I−P)TPu=yT(P−P2)u=0,

    using symmetry and then idempotence. (Equivalently: this is the orthogonal decomposition of y, with Py=projW​y.) The two pieces are orthogonal, so by the Pythagorean theorem

    ∥y∥2=∥Py∥2+∥y−Py∥2 ≥ ∥Py∥2,

    and taking square roots gives ∥Py∥≤∥y∥.

    Equality holds if and only if ∥y−Py∥=0, i.e. y=Py, which places y in W. Conversely, if y∈W then y=y+0 is a decomposition with y∈W and 0∈W⊥, so by uniqueness in the Orthogonal Decomposition Theorem Py=y and equality holds. ■

    (b) A reflection. PQ=P(I−P)=P−P2=P−P=0 and QP=(I−P)P=P−P2=0. Next F=P−(I−P)=2P−I. Symmetry: FT=2PT−I=2P−I=F. Orthogonality:

    FTF=F2=(2P−I)2=4P2−4P+I=4P−4P+I=I. ■

    For w∈W, Pw=w as in (a), so Fw=2w−w=w. For z∈W⊥ the decomposition z=0+z gives Pz=0, so Fz=−z. Hence for a general y=y^​+z we get Fy=y^​−z: F keeps the component in W and reverses the component in W⊥. It is the reflection of Rn through W. Being orthogonal it preserves lengths, which agrees with ∥y^​−z∥2=∥y^​∥2+∥z∥2=∥y^​+z∥2, and F2=I says reflecting twice is the identity. (Along the way: Q=I−P is symmetric and idempotent with Qz=z, Qw=0, so it is the projection onto W⊥.)

    (c) A Householder reflection. For a line, P=uuT, so H=Q−P=I−2uuT=−F. It is symmetric and orthogonal with H2=I, and by (b) it sends u↦−u while fixing every vector orthogonal to u: the reflection in the plane u⊥.

    Numerically, uuT=91​​4−24​−21−2​4−24​​, so

    H=I−92​​4−24​−21−2​4−24​​=91​​14−8​474​−841​​.

    Hu=91​⋅31​⟨2−4−16, 8−7+8, −16−4+2⟩=271​⟨−18,9,−18⟩=31​⟨−2,1,−2⟩=−u ✓. For w: w⋅u=32−2+0​=0, so w∈u⊥, and Hw=91​⟨1+8, 4+14, −8+8⟩=⟨1,2,0⟩=w ✓.

    For y use Hy=y−2(u⋅y)u with u⋅y=36+0+6​=4:

    Hy=⟨3,0,3⟩−38​⟨2,−1,2⟩=⟨−37​,38​,−37​⟩.

    (Matrix check: 91​⟨3−24, 12+12, −24+3⟩=91​⟨−21,24,−21⟩, the same.) Lengths: ∥y∥2=18 and ∥Hy∥2=949+64+49​=9162​=18 ✓, as an orthogonal matrix requires.

  12. 12.Proof

    Let A be an m×n matrix and b∈Rm. Do not assume the columns of A 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).

    1. (a)Prove that Nul(ATA)=NulA, and deduce that Col(ATA)=Col(AT). Conclude that the normal equations ATAx=ATb are consistent for every b.
    2. (b)Prove that if x^1​ and x^2​ are both least-squares solutions then Ax^1​=Ax^2​. 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.
    3. (c)Let x^ be a least-squares solution and r=b−Ax^. Prove that ∥b∥2=∥Ax^∥2+∥r∥2, and deduce that the least-squares error equals ∥b∥ exactly when b∈NulAT.

    Solution

    (a) Null spaces. If Ax=0 then ATAx=AT0=0, so NulA⊆Nul(ATA). Conversely, if ATAx=0, multiply on the left by xT:

    0=xTATAx=(Ax)⋅(Ax)=∥Ax∥2,

    so Ax=0 by positive definiteness. Hence Nul(ATA)=NulA.

    Column spaces. ATA is n×n and AT is n×m, so both column spaces live inside Rn and can be compared. By Rank–Nullity applied to the two n-column matrices ATA and A,

    rank(ATA)=n−dimNul(ATA)=n−dimNulA=rankA,

    and rankA=rankAT because row rank equals column rank. Every vector of Col(ATA) has the form ATAx=AT(Ax), so Col(ATA)⊆Col(AT). A subspace contained in another of the same finite dimension equals it: Col(ATA)=Col(AT).

    Consistency. ATb∈Col(AT)=Col(ATA), and membership in Col(ATA) is exactly the statement that ATAx=ATb has a solution. ■ (The projection proof of the same fact argues through b^∈ColA; this one never mentions a projection.)

    (b) The projection is unique. By the normal-equations theorem, least-squares solutions are exactly the solutions of ATAx=ATb. Subtracting the two equations, ATA(x^1​−x^2​)=0, so x^1​−x^2​∈Nul(ATA)=NulA by (a), i.e. Ax^1​=Ax^2​. ■

    The same computation read backwards describes the whole set: if x^ is one least-squares solution and v∈NulA, then ATA(x^+v)=ATAx^=ATb, so x^+v is another; and every other differs from x^ by an element of NulA. The set is the translate x^+NulA. It is a single point exactly when NulA={0}, i.e. when the columns of A are independent — which by the lemma on ATA is also exactly when ATA is invertible and x^=(ATA)−1ATb.

    (c) Pythagoras for the residual. The normal equations say ATr=ATb−ATAx^=0. Therefore

    (Ax^)⋅r=(Ax^)Tr=x^T(ATr)=x^T0=0,

    so Ax^⊥r. Since b=Ax^+r, the Pythagorean theorem gives ∥b∥2=∥Ax^∥2+∥r∥2. ■ (In particular ∥r∥≤∥b∥ always, as it must be, since x=0 is a competitor with error ∥b∥.)

    When the error is as bad as possible. By the identity, ∥r∥=∥b∥ if and only if ∥Ax^∥2=0, i.e. Ax^=0. If that holds, then ATb=ATAx^=0, so b∈NulAT. Conversely, if ATb=0 then x^=0 solves the normal equations, so by (b) every least-squares solution has Ax^=0 and the error is ∥b∥. By the fundamental orthogonality relation NulAT=(ColA)⊥, so this is the case in which b has no component in any direction the columns of A can reach: the best the model can do is predict 0, and it explains nothing.

← Back to the question sheet

CalcPath·Free university mathematics

SubjectsProblem setsProgressFeedbackAbout