Unfinished learning resource · TMP-SCI-132. Units 1–8 are available; whole-course validation remains unfinished. This is not a completed semester, registered course, degree credit or accreditation. The teaching has received bounded assistant review, not subject-specialist or learner validation. Workload estimates and rubrics remain unpiloted. All application data are fictional. No account, installation, purchase or private upload is needed.
Study route and outcomes
Unit 1 could diagnose that exact equations contradict one another, but contradiction does not choose a substitute answer. A least-squares problem makes an additional choice: minimize the sum of squared residuals. Geometry explains the solution, when its coefficients are unique, and why a best fit does not identify which observation or assumption was wrong.
Preparation: real vector spaces, bases, kernels and images; exact elimination; matrix multiplication and inverses; coordinate changes. Unit 5's complex bridge is not a prerequisite here: this entire unit uses real vectors with the ordinary Euclidean dot product. Complex inner products need conjugation and are outside this unit. No calculus, probability or optimization software is assumed.
The retained two-week allocation is 18 hours: six teaching/guided, four practice/corrections, two homework, two quiz/delayed work and four project hours. It is an unpiloted design budget, not observed time. Spread four sessions across several sittings. Attempt problems before opening the explained answers; keep original work and corrections distinct. Written, typed or recorded explanations with a transcript are acceptable. Diagram descriptions contain all needed information, without colour or drawing requirements.
Outcomes
- O1. Use dot products, Euclidean norms, orthogonality and their hypotheses in calculations and proofs.
- O2. Construct orthogonal/orthonormal bases by Gram–Schmidt, including a dependent-list failure case.
- O3. Derive orthogonal projection and justify its unique nearest-vector property.
- O4. Derive and solve normal equations, distinguishing unique fitted vectors from unique coefficients.
- O5. Explain thin QR, triangular least-squares solution and the limits of normal equations in finite precision.
- O6. Interpret residuals, constraints, duplicated observations and model assumptions without unsupported causal claims.
Readiness
R1. For A=[1 1;1 0;0 1], find rank and a column-space basis. Is b=(2,1,0) in that column space? Justify by the exact equations.
R2. Solve [2 1;1 2]x=(3,2) and verify the result.
R3. For B=[1 1;1 1], find its kernel and every solution of Bx=(4,4). Which part of the output determines the sum of the two inputs?
R4. Prove that two nonzero independent vectors spanning a subspace of R³ form a basis of that subspace. Does this say they span all R³?
Session A. Length and perpendicularity in real coordinate space
A1. Dot product, norm and the zero-vector caveat
For u,v in Rⁿ, define u·v=Σu_iv_i and ||u||=sqrt(u·u). The dot product is symmetric and distributes over sums and real scalar multiples. Also u·u≥0, with equality exactly when every coordinate is zero. Thus the norm is nonnegative, is zero exactly at zero, and obeys ||cu||=|c| ||u||. The distance from u to v is ||u−v||.
Vectors are orthogonal when u·v=0. Zero is orthogonal to every vector, but zero cannot be a basis vector. For orthogonal u,v, expansion gives the Pythagorean identity
||u+v||²=||u||²+2u·v+||v||²=||u||²+||v||².
An orthogonal list of nonzero vectors is independent: if Σc_ju_j=0, dotting with u_i gives c_i||u_i||²=0, hence c_i=0. The nonzero condition permits that last conclusion. An orthonormal list is orthogonal and every vector has norm 1. Orthogonal does not automatically mean normalized.
For an orthogonal basis u₁,…,u_r of W and w=Σc_ju_j, dotting with u_i gives
c_i=(w·u_i)/(u_i·u_i).
For an orthonormal basis the denominator is 1. Omitting the denominator for a merely orthogonal basis usually gives the wrong coordinates.
A2. Cauchy–Schwarz, with a proof
For real vectors, |u·v|≤||u|| ||v||. If v=0, both sides are zero. Otherwise put t=(u·v)/(v·v). Expanding a nonnegative square gives
0≤||u−tv||²=||u||²−(u·v)²/||v||².
Multiply by the positive ||v||² and take nonnegative square roots to obtain the inequality. Equality holds exactly when u−tv=0, that is, u is a multiple of v when v≠0. Together with the zero case, equality holds exactly when the pair is linearly dependent. Expanding ||u+v||² and applying this bound also proves ||u+v||≤||u||+||v||, the triangle inequality. We did not divide by a possibly zero norm.
G1. For u=(1,2,2), v=(2,−1,0), compute u·v, both norms and ||u+v||. Check Pythagoras and explain why the two vectors are independent.
G2. The vectors (2,0),(0,3) are an orthogonal basis of R². Find the basis coefficients of (4,6) using the correct formula. Compare them with the raw dot products and explain the difference.
Session B. The nearest point in a subspace
B1. Projection onto a line
For a nonzero u, a candidate point on its span is tu. Expanding and completing the square gives
||b−tu||² = ||b||²−(b·u)²/||u||²
+ ||u||²(t−(b·u)/||u||²)².
The unique minimum occurs at t=(b·u)/||u||². Therefore
p=proj_span(u)(b)=((b·u)/(u·u))u, r=b−p.
The residual r is orthogonal to u by substitution. For u=(1,1), b=(2,0), p=(1,1), r=(1,−1) and ||r||²=2. The coefficient t=1 is a scalar; the projection p is a vector. Replacing u by a nonzero multiple changes the coordinate coefficient but not the projected vector.
B2. Gram–Schmidt builds the basis projection needs
Given an independent list a₁,…,a_r, set u₁=a₁ and recursively subtract the already accounted-for directions:
u_j=a_j−Σ_(i<j) ((a_j·u_i)/(u_i·u_i))u_i.
Dotting this formula with any earlier u_i gives zero, because the preceding u_i are mutually orthogonal. At each stage span{u₁,…,u_j}=span{a₁,…,a_j}: the new vector is the old one minus earlier-span terms, and the old one can be recovered by adding them. If u_j=0, then a_j belongs to the earlier span, contradicting independence. Thus an independent input list produces nonzero orthogonal vectors. Divide each u_j by its norm to obtain q_j.
For a spanning list that is not independent, a zero remainder is a signal to skip that vector, not divide by zero. Continue subtracting projections onto the nonzero vectors retained so far. This also constructs an orthonormal basis for any nonzero finite-dimensional subspace. The zero subspace has the empty basis.
Take a₁=(1,1,0), a₂=(1,0,1). Then u₁=a₁ and u₂=a₂−(1/2)a₁=(1/2,−1/2,1). Equivalent orthogonal directions are u₁ and (1,−1,2). Normalizing gives
q₁=(1,1,0)/sqrt(2), q₂=(1,−1,2)/sqrt(6).
Check q₁·q₂=0 and each squared norm is 1. The algorithm preserves the span but does not normally preserve each original vector or its coordinates.
B3. Projection onto a whole subspace
For an orthonormal basis q₁,…,q_r of W, define p=Σ(b·q_i)q_i. Then p is in W, and r=b−p is orthogonal to every q_i and hence every vector of W. For any other z in W, p−z is in W, so
||b−z||²=||r+(p−z)||²=||r||²+||p−z||².
This proves p is the unique nearest vector in W: equality with the minimum occurs exactly when z=p. It also proves the decomposition b=p+r is independent of the chosen orthonormal basis. For W={0}, the empty sum gives p=0 and the same result holds.
For the preceding plane W=span{(1,1,0),(1,0,1)} and b=(2,1,0), the two dot products are 3/sqrt(2) and 1/sqrt(6). Thus
p=(5/3,4/3,1/3), r=(1/3,−1/3,−1/3), ||r||²=1/3.
The transpose Qᵀ interchanges rows and columns of the matrix Q whose columns are the q_i. The vector of dot products is Qᵀb, and p=QQᵀb. Since QᵀQ=I_r, P=QQᵀ satisfies P²=P and Pᵀ=P. It is an orthogonal projection matrix, not generally invertible. Idempotence alone, as studied in Unit 3, does not guarantee perpendicular residuals; homework tests that distinction.
Diagram A, text equivalent. A point b lies away from the plane W through the origin. Its projection p lies in W, and the arrow from p to b is perpendicular to every direction in W. For any other z in the plane, the triangle with edges b−p and p−z is right-angled; its squared hypotenuse is the residual square plus ||p−z||². The formula proves nearestness without relying on a drawing.
G3. Project b=(2,1,0) onto span{(1,1,0)}. Give the residual, its squared norm and an orthogonality check. Explain why this is different from projection onto the larger plane in B3.
G4. Apply Gram–Schmidt to a₁=(1,0,1), a₂=(1,1,0), a₃=(2,1,1). Give an orthonormal basis of their span and explain the zero-remainder step.
Session C. Least squares is projection in the output space
C1. Define the objective before solving
For A with m rows and n columns and b in Rᵐ, a least-squares coefficient vector minimizes
||Ax−b||²=Σ_(i=1 to m) ((Ax)_i−b_i)²
over all x in Rⁿ. We define residual r=b−Ax; changing its sign would not change its squared norm, but use one convention consistently. This objective gives every listed coordinate equal weight in its stated units. That is a modeling choice, not a consequence of contradictory equations. An integer or nonnegative restriction creates a different optimization problem and is not silently handled by the unrestricted formula.
As x varies, Ax ranges over W=im A. Projection gives a unique closest fitted vector p in W, and at least one coefficient vector producing it exists by the definition of image. Hence a least-squares solution always exists in this finite-dimensional unrestricted real problem, whether or not the columns are independent. Its fitted vector is unique; its coefficients need not be.
C2. Derive the normal equations and their converse
At a minimizing x, the fitted vector must be p, so r=b−Ax is orthogonal to every column of A. Dotting with columns is Aᵀr, giving
Aᵀ(b−Ax)=0, or AᵀAx=Aᵀb.
These are the normal equations. Conversely, if x satisfies them, its residual is orthogonal to im A, and for any h,
||b−A(x+h)||²=||r−Ah||²=||r||²+||Ah||²≥||r||².
Thus every normal-equation solution is a minimizer. This is both necessity and sufficiency, not merely a recipe. The normal system is consistent even when the original Ax=b is not.
For A=[1 1;1 0;0 1] and b=(2,1,0),
AᵀA=[2 1;1 2], Aᵀb=(3,2).
Solving gives x̂=(4/3,1/3). Its fitted vector Ax̂=(5/3,4/3,1/3) and residual match the geometric projection above. Directly Aᵀr=0. The original equations would require x₁=1, x₂=0 but x₁+x₂=2, so they had no exact solution. The least-squares answer has not made that contradiction disappear; it solves a different, explicit objective.
C3. Precisely when are coefficients unique?
For any z in Rⁿ,
zᵀAᵀAz=(Az)ᵀ(Az)=||Az||².
Therefore ker(AᵀA)=ker A: one inclusion follows immediately from Az=0; for the other, AᵀAz=0 forces the displayed squared norm to vanish, hence Az=0. Consequently AᵀA is invertible exactly when A has full column rank n. In that case x̂=(AᵀA)⁻¹Aᵀb is a valid exact mathematical formula. It is not a recommendation to form that inverse in floating-point software.
If x̂ is one minimizer, all minimizers are x̂+ker A. Adding a kernel vector preserves the fitted vector; conversely every minimizer produces the unique p, so subtracting their coefficients gives a kernel vector. Thus deficient column rank gives nonunique coefficients while the nearest fitted vector remains unique. More observations than coefficients alone does not imply full column rank.
G5. With the same A but b=(0,1,1), solve the normal equations. Compute the fitted vector, residual and squared residual norm, and verify Aᵀr=0.
G6. For A=[1 1;1 1] and b=(1,3), find every least-squares coefficient vector, the unique fitted vector and the minimum squared residual. Explain why an inverse of AᵀA is unavailable but a best fit still exists.
Session D. QR and honest numerical/model limits
D1. Thin QR avoids an unnecessary inverse
For an m-by-n matrix with independent columns, Gram–Schmidt gives Q with n orthonormal columns and an n-by-n upper triangular R such that A=QR. Define R_ij=q_i·a_j for i≤j and zero below the diagonal. Each a_j is reconstructed from q₁,…,q_j, so this column equation holds. With the usual normalization, R_jj is the positive norm of the jth nonzero remainder, hence R is invertible.
The fitted vector is QQᵀb. To obtain its coefficients, solve the triangular system
R x̂=Qᵀb.
Then Ax̂=QRx̂=QQᵀb, the projection. This is a derivation of the least-squares solution without explicitly forming AᵀA or an inverse. Thin Q is rectangular when m>n: QᵀQ=I_n does not imply QQᵀ=I_m.
For the worked A, the q columns from B2 give
R=[sqrt(2) 1/sqrt(2); 0 sqrt(3/2)].
With b=(2,1,0), Qᵀb=(3/sqrt(2),1/sqrt(6)). Back-substitution yields x₂=1/3 then x₁=4/3, agreeing with projection and normal equations. These are three explanations of the same exact answer, not three unrelated estimators.
D2. Exact algebra is not finite-precision reliability
Consider A_ε=[1 1;0 ε] with ε≠0. It is invertible, but for ε=1/1000, outputs b=(2,1/1000) and b'=(2,2/1000) recover inputs (1,1) and (0,2). The output change is small in these coordinates while the recovered inputs change substantially. This is intrinsic sensitivity of the problem, not evidence that an algebraically correct solver is defective.
Here A_εᵀA_ε=[1 1;1 1+ε²]. If limited arithmetic rounds 1+ε² to 1, forming the normal matrix discards the distinction that made it full rank. This is a conditional illustration of rounding, not a claim that a particular machine necessarily rounds this chosen ε that way. It shows why squaring a small directional distinction can be numerically troublesome. Normal equations are valuable for derivation, but numerical work commonly uses carefully implemented QR or singular-value methods instead of explicitly forming (AᵀA)⁻¹. Classical Gram–Schmidt can itself lose orthogonality in finite precision; this unit derives exact QR algebra, not a production numerical algorithm or error bound. A better solver cannot create information absent from sensitive or noisy measurements.
D3. Revisit what a conflicting log can establish
Unit 1's workshop logged red=13, blue=12 and red+blue=26. The exact contradiction is 13+12≠26. Suppose we now seek real-valued reconciled red/blue totals (r,b) minimizing the three equally weighted squared reporting discrepancies. This is a new approximation model, not a discovery of actual kit counts and not a proof that equal weights are appropriate.
The project asks for that explicit fit, examines a duplicated sum record and then overparameterizes the same fitted totals. Duplicating an observation changes its weight in the squared objective; it does not by itself add independent information. Changing units can likewise change the unweighted objective. A small residual, an orthogonal residual or a unique coefficient vector does not identify a faulty person, instrument or causal mechanism.
G7. For the worked A and its displayed Q,R, verify A=QR and QᵀQ=I₂. Use QR to solve the changed b=(0,1,1) and compare with G5. Why is QQᵀ not I₃?
G8. Verify the two A_ε reconstructions at ε=1/1000, compute the output/input changes, and calculate det(A_εᵀA_ε). Explain both the conditional rounding problem and why QR does not remove intrinsic measurement sensitivity.
Independent practice
I1. For u=(1,2,−2), v=(3,6,−6), check Cauchy–Schwarz with exact norms and explain equality. Contrast with w=(2,−1,0), which is orthogonal to u.
I2. Project b=(1,2,0) onto span{(2,−1,2)}. Explain how a nonzero input can have zero projection without having zero residual.
I3. Let W={(x,y,z):x+y+z=0}. Project b=(1,2,3) onto W by removing its component along n=(1,1,1). Prove your candidate lies in W, its residual is perpendicular to W, and give the distance to W.
I4. Apply Gram–Schmidt to (1,1),(2,0) and normalize. Then explain what happens if (3,1) is appended, and why dividing the final remainder by its norm is invalid.
I5. For A=[1 0;0 1;1 1], b=(1,2,2), find the least-squares coefficients, fitted vector, residual and minimum squared residual. Verify both normal equations and uniqueness.
I6. Fit y≈c+dt to the three records (t,y)=(0,1),(1,2),(2,2) by ordinary equal-weight least squares in y. Form A, solve for c,d, and give all residuals and their squared sum. State what this criterion assumes and what it does not prove about a real relationship.
I7. For A=[1 2;2 4;0 0], b=(1,0,3), find the unique fitted vector and every minimizing coefficient vector. Compute the minimum squared residual and explain the unavoidable third residual.
I8. For any orthogonal projection p of b with residual r=b−p, prove b·r=||r||². Give a nonzero-residual example showing that r is perpendicular to the fitted vector but generally not to b itself.
Homework: proofs and modeling
H1. Derive the line-projection coefficient by completing the squared-distance expression. Explain the requirement u≠0 and prove the projected vector is unchanged if u is replaced by a nonzero multiple.
H2. For an orthonormal-column matrix Q, prove P=QQᵀ is symmetric and idempotent and that (I−P)b is orthogonal to im Q. Compare B=[1 1;0 0]: show B²=B but use b=(0,1) to show B is not the orthogonal projection onto its image.
H3. Prove ker(AᵀA)=ker A and use it to explain exactly when least-squares coefficients are unique. Include why a minimizer exists and why the fitted vector remains unique even in the deficient-rank case.
H4. Explain why duplicating a record or changing one measurement's units can change an unweighted least-squares fit. Distinguish deliberate justified weighting from treating a copied record as new evidence. Why do normal equations not establish a cause for conflicting records?
Formative quiz: 30 points
These changed instances rehearse taught methods. They are not a validated unseen-transfer test; points are separate from the project and are not a semester mark.
Q1 (8). Project b=(2,1,0) onto span{u}, u=(1,2,2). Give p,r, check r·u=0, calculate squared distance, and justify that p is the unique nearest vector on the line.
Q2 (8). Apply Gram–Schmidt to a₁=(1,0,1), a₂=(0,1,1). Give Q and upper triangular R with A=[a₁ a₂]=QR; verify the orthonormal columns and the reconstruction.
Q3 (8). Fit y≈c+dt to (−1,0),(0,1),(1,3) using equal-weight squared y residuals. Give coefficients, fitted values, residuals and their squared sum, and verify Aᵀr=0 and coefficient uniqueness.
Q4 (6). For A=[1 1;0 0] and b=(3,2), find every minimizing coefficient vector, the fitted vector, residual and minimum squared residual. Explain why a singular AᵀA does not prevent the fit.
Formative project: reconciling conflicting logs, 40 points
Use Unit 1's fictional red=13, blue=12 and red+blue=26 logs. For this project only, r,b are real-valued reconciled totals and the objective is the sum of the three equally weighted squared reporting discrepancies. These are approximation variables, not integer kit counts or established true totals.
P1 (10). Form Ax≈y for x=(r,b). Explain the row meanings, show exact inconsistency and state the chosen domain/objective. Derive and solve the normal equations.
P2 (10). Give the fitted three-record vector, residual y−Ax, squared residual and an explicit Aᵀr_residual=0 check. Prove uniqueness of both the fitted vector and coefficients. Explain why this does not reveal the actual true totals or which record/assumption failed.
P3 (10). Copy the sum record so the observations become (13,12,26,26), with two identical sum rows in the design matrix. Refit using all four rows with equal coordinate weight. Compare the reconciled totals with the first fit and express the new objective as a weighted version of the old three-term one. Does the copy add independent information? Explain what must be justified before choosing this changed weighting.
P4 (10). Return to the original three records but write the same total variables as r=α+γ and b=β+γ. Construct the new 3-by-3 design matrix. Find its kernel and every least-squares coefficient triple (α,β,γ); show why the fitted records and minimum objective do not change. If the three coefficients must be nonnegative, find the allowed parameter interval and state whether the same minimum is attainable.
Delayed follow-through
D1. After a pause, a different fictional logger models records (x,y,x−y) and reports (4,1,1). Show exact inconsistency, find the equal-weight least-squares input, fitted vector, residual and squared residual, and check residual orthogonality. State what the calculation cannot establish about the cause. This is changed-representation near transfer, not measured learning transfer. D2. Correct an unsupported step from your own work, retaining the original. If none occurred, critique “AᵀA is singular, so there is no closest fitted vector.” Give a counterexample that separates fitted-vector uniqueness from coefficient nonuniqueness.
Feedback and next step
Mark the first unsupported step: zero denominator, unnormalized projection coefficients, dependent Gram–Schmidt input, residual sign inconsistency, incorrect transpose dimensions, fitting in the coefficient space rather than output space, singular inverse assumed, changed weights hidden, or a causal claim from residuals. Repair the reason, then solve a changed instance.
Unit 7, symmetric matrices and quadratic forms, is available in this reader. This unit supplies exact real Euclidean projection and least-squares foundations, not general statistical inference, constrained optimization, a robust numerical implementation or a completed semester. Specialist review, learner attempts/timing, rubric calibration and rendered/device/assistive-technology checks remain unperformed for this unit.