Mathematics · Article
Orthogonality, projections and least squares
Split a vector into a part a subspace can represent and a perpendicular residual. Build orthogonal coordinates, derive least-squares equations, and distinguish a unique best-fit vector from possibly nonunique coefficients.
Back to MathematicsAfter reading, you can
- State an inner product and use it to define length, orthogonality and distance with the required positivity conditions.
- Find an orthogonal complement and project onto a line or a subspace using an orthogonal basis.
- Explain and prove why an orthogonal projection is the unique closest vector in a finite-dimensional subspace.
- Carry out Gram–Schmidt without treating a zero residual as a new basis direction, and connect orthonormal columns to QR.
- Derive the normal equations and distinguish uniqueness of fitted values from uniqueness of least-squares coefficients.
- Fit and check an exact small data set, including its residual, rather than judging a fit by appearance alone.
- Separate ordinary, weighted and complex inner products, and state the numerical and modelling limits of least squares.
What can a line represent?
Let u=(2,1) and b=(1,3). A point on the line W=span(u) has the form cu. Choosing c=1 gives p=(2,1), with residual r=b−p=(−1,2). The dot product u·r=2(−1)+1(2)=0 says that the error points perpendicular to the line. The decomposition b=p+r separates a part the line can represent from a part it cannot.
This is a different question from solving cu=b exactly: that equation is inconsistent, since its two coordinates would require c=1/2 and c=3. A projection chooses the best representable vector according to a stated distance. It does not make the original inconsistent equation exact. Least squares will apply the same idea to several columns and many observations.
Preparation: Vectors 121 for dot products and lengths, Matrices 122 for systems and kernels, Vector spaces 123 for spans and independence, and Bases 124 for coordinate recipes. Eigenvalues 126 is useful when we later interpret a projection matrix, but the nearest-vector argument does not require finding eigenvalues. We begin over the real numbers in finite dimension; a later section states the weighted and complex variants explicitly.
Specify the geometry before measuring an error
For x,y∈Rᵐ, the ordinary dot product is x·y=xᵀy=Σ xi yi. An inner product is a scalar-valued operation with symmetry, linearity in each real argument, and positive definiteness: ⟨x,x⟩≥0, with equality exactly when x=0. Positivity makes the operation a geometry rather than just a bilinear formula. For example, x₁y₁−x₂y₂ is bilinear and symmetric, but it is not a real inner product because (0,1) has squared value −1.
The induced norm is ‖x‖=√⟨x,x⟩, and distance is ‖x−y‖. Two vectors are orthogonal when ⟨x,y⟩=0. Zero is orthogonal to every vector, but cannot be normalized and cannot appear as a vector of an orthogonal basis. An orthonormal list is an orthogonal list whose vectors all have length 1.
Coordinates carrying metres, seconds or different kinds of observations do not automatically belong in one unweighted sum of squares. First choose compatible units or a justified scaling. Changing those choices changes the distance and can change which approximation is best. The ordinary coordinate dot product is a stated convention, not a universal rule for comparing every measured quantity.
Use orthogonality to separate squared lengths
Expanding the inner product gives ‖x+y‖²=‖x‖²+2⟨x,y⟩+‖y‖². If x and y are orthogonal, the cross term vanishes, leaving Pythagoras: ‖x+y‖²=‖x‖²+‖y‖². Conversely, in a real inner-product space that equality implies ⟨x,y⟩=0. This is an algebraic statement that remains meaningful in dimensions we cannot draw.
For nonzero u, positivity of ‖v−tu‖² for every real t gives a useful bound. Substitute t=⟨u,v⟩/⟨u,u⟩ and expand: 0≤‖v‖²−⟨u,v⟩²/‖u‖². Thus |⟨u,v⟩|≤‖u‖‖v‖, the Cauchy–Schwarz inequality. Equality means the residual is zero, so v is a scalar multiple of u; the case u=0 also satisfies the inequality.
Consequently ⟨u,v⟩/(‖u‖‖v‖) lies between −1 and 1 for nonzero vectors, making it a valid cosine of their angle. The triangle inequality follows by expanding ‖u+v‖² and applying Cauchy–Schwarz. Orthogonal does not mean independent in every list containing zero; a list of nonzero, pairwise orthogonal vectors is independent because taking its inner product with each listed vector isolates one coefficient.
Find the directions a subspace misses
For W⊆Rᵐ a subspace, W⊥={r: r·w=0 for every w∈W} is its orthogonal complement. It is enough to test a spanning list: if r is orthogonal to each column of A, then r is orthogonal to every linear combination of those columns. Hence Col(A)⊥=ker(Aᵀ). This turns a geometric condition into an ordinary homogeneous system.
For W=span((2,1)), the equation is 2r₁+r₂=0, so W⊥=span((−1,2)). In R³, a line has a two-dimensional orthogonal complement, not one distinguished perpendicular line. A vector perpendicular to one chosen vector in a plane need not be perpendicular to the whole plane; test a spanning list, not a single convenient direction.
The intersection W∩W⊥ is {0}, because a vector in both is orthogonal to itself. Rank–nullity applied to Aᵀ, together with equality of row and column rank, gives dim W⊥=m−dim W. Their dimensions add to m and their intersection is trivial, so Rᵐ=W⊕W⊥. Thus every b has a unique decomposition b=p+r with p∈W and r∈W⊥. These claims concern finite dimension; approximation in infinite-dimensional spaces needs additional hypotheses.
Derive the projection coefficient
For W=span(u) with u≠0, write p=cu and require r=b−cu to be orthogonal to u. The equation ⟨u,b−cu⟩=0 gives c=⟨u,b⟩/⟨u,u⟩. Therefore projW b=(⟨u,b⟩/⟨u,u⟩)u. The denominator is the squared length of u. Dropping it is valid only when u is a unit vector.
For u=(2,1), b=(1,3), the numerator and denominator are both 5, recovering p=(2,1). For b=(3,0), c=6/5, p=(12/5,6/5), and r=(3/5,−6/5). Direct checks give u·r=0 and b=p+r. Replacing u by 7u changes c but leaves the projected vector unchanged: the subspace, rather than its choice of spanning arrow, determines the projection.
In ordinary coordinates the line projector is P=uuᵀ/(uᵀu). For this u, P=[[4/5,2/5],[2/5,1/5]]. It satisfies P²=P and Pᵀ=P. A vector on W is unchanged, while a vector in W⊥ is sent to zero. The formula requires u≠0. Projection onto the subspace {0} still exists and is the zero map, but a division by the squared length of a zero spanning vector cannot compute it.
Add independent perpendicular contributions
Let u₁,…,uᵣ be a nonzero orthogonal basis of W. Seek p=Σ cj uj with b−p perpendicular to every ui. Taking an inner product with ui removes every other term and yields ci=⟨ui,b⟩/⟨ui,ui⟩. Hence projW b=Σ (⟨ui,b⟩/⟨ui,ui⟩)ui. For an orthonormal basis q₁,…,qᵣ, the denominators are 1.
Put orthonormal columns in an m-by-r matrix Q. Then QᵀQ=Iᵣ, the coordinate coefficients of the projected part are Qᵀb, and p=QQᵀb. When r<m, QQᵀ is an m-by-m projector rather than the identity. Distinguish these two products and their sizes. Qᵀ takes inner products with the basis directions; Q reconstructs the vector in the original coordinates.
The familiar dot-product formula does not give coordinates in an arbitrary oblique basis. For the retained basis u=(2,1), v=(1,−1), u·v=1, so the two columns are not orthogonal. Projecting onto each line independently and adding generally double-counts part of the vector. Either solve for the oblique coordinates as in lesson 124 or first construct an orthogonal basis for the same span.
Remove directions already represented
Gram–Schmidt constructs orthogonal directions from an independent list a₁,…,aᵣ. Set u₁=a₁ and, for j>1, set uj=aj−Σi<j (⟨ui,aj⟩/⟨ui,ui⟩)ui. The subtracted sum is the component already represented by earlier orthogonal directions. Taking an inner product with any earlier uk gives zero, and adding back that sum shows that the new and old lists have the same successive spans.
If the original columns are independent, each uj is nonzero: otherwise aj would be in the span of earlier columns. If the input is only a spanning list, a zero residual signals a redundant column; omit it rather than divide by its length. Normalize only the nonzero residuals to obtain qj=uj/‖uj‖. Exact zero and a tiny floating-point residual are different situations; numerical rank decisions need a scale-aware tolerance.
For a₁=(2,1) and a₂=(1,−1), the first subtraction coefficient is 1/5, so u₂=(3/5,−6/5). Normalization gives q₁=(2,1)/√5 and q₂=(1,−2)/√5. With B=[a₁ a₂], these columns form Q, and B=QR with R=[[√5,1/√5],[0,3/√5]]. More generally, independent columns give a thin QR factorization with QᵀQ=I and upper-triangular R. Lesson 128 develops its computational role alongside other decompositions.
Prove that perpendicular residual means closest
Take b=p+r with p∈W and r∈W⊥. For any other w∈W, b−w=r+(p−w). These two terms are orthogonal, so ‖b−w‖²=‖r‖²+‖p−w‖²≥‖r‖². Equality holds exactly when w=p. This proves that p is the unique closest vector in W; it is not merely a visually plausible foot of a perpendicular.
Conversely, suppose p is a closest vector and u∈W. Every p+tu remains in W. Expanding ‖b−p−tu‖² gives ‖b−p‖²−2t⟨u,b−p⟩+t²‖u‖². A nonzero middle coefficient would let a sufficiently small t of the matching sign reduce the error. Thus ⟨u,b−p⟩=0 for every u, so the residual is orthogonal to W. The closest-vector and perpendicular-residual characterizations are equivalent.
The projection map PW is linear because adding and scaling decompositions preserves the two subspaces, and uniqueness identifies their components. It fixes W and kills W⊥, giving P²=P. In ordinary orthonormal coordinates it also satisfies Pᵀ=P. Idempotence alone is insufficient for an orthogonal projection: [[1,1],[0,0]] squares to itself but projects along an oblique direction and is not symmetric. The chosen inner product matters.
Turn the nearest-vector question into a system
For A an m-by-n real matrix and b∈Rᵐ, least squares minimizes ‖b−Ax‖² over x∈Rⁿ. Its fitted vector Ax lies in Col(A), so the unique best fitted vector is p=projCol(A) b. The coefficients x solve the least-squares problem exactly when their residual r=b−Ax belongs to Col(A)⊥. Equivalently Aᵀr=0, giving the normal equations AᵀAx=Aᵀb.
These normal equations are always consistent: the orthogonal decomposition supplies p in Col(A), hence at least one x with Ax=p. Different solutions differ by a vector of ker A, since they reconstruct the same p. The fitted vector p and residual r are unique even when the coefficient vector is not. Uniqueness of x holds exactly when A has independent columns. For an inconsistent original equation, no choice of least-squares coefficients makes the residual disappear.
If the columns are independent, xᵀAᵀAx=‖Ax‖²>0 for x≠0, so AᵀA is positive definite and invertible. Then x=(AᵀA)⁻¹Aᵀb and P=A(AᵀA)⁻¹Aᵀ. If the columns are dependent, these inverse formulas are invalid even though the projection and least-squares solutions still exist. One may use an independent column basis, an orthogonalized spanning list, or the pseudoinverse introduced next; do not silently invert a singular Gram matrix.
Check one complete fit, including the residual
Consider three observations with t values −1,0,1 and response values b=(0,1,3). Fit y≈α+βt. The design matrix is A=[[1,−1],[1,0],[1,1]]: its first column represents the intercept and its second represents the slope. The squared error is the sum of three squared vertical response residuals. It is not the sum of squared geometric distances from the drawn points to a line in the t,y plane.
Here AᵀA=[[3,0],[0,2]] and Aᵀb=(4,3), so (α,β)=(4/3,3/2). The fitted responses are p=(−1/6,4/3,17/6), and r=b−p=(1/6,−1/3,1/6). Their sum is zero, and (−1,0,1)·r=0, verifying Aᵀr=0. The residual squared norm is 1/36+1/9+1/36=1/6. These identities check the coefficients and the meaning of the fit.
For any different coefficient vector x+h, orthogonality gives ‖b−A(x+h)‖²=‖r‖²+‖Ah‖². The design has independent columns, so a nonzero h strictly increases the error. This proves uniqueness of these coefficients without relying on a plotted curve. With a redundant design column, a nonzero h in ker A would leave both fitted values and error unchanged.
Change the metric explicitly
A real symmetric positive-definite matrix G defines ⟨u,v⟩G=uᵀGv. For positive diagonal G, squared error is Σ gi ri². Repeating the orthogonality argument gives AᵀGAx=AᵀGb and AᵀGr=0. With independent columns the weighted projector is P=A(AᵀGA)⁻¹AᵀG. It is idempotent and G-self-adjoint: PᵀG=GP. It need not be symmetric in the ordinary coordinate dot product, and a drawn residual need not meet the drawn subspace at an ordinary right angle.
Weight the middle observation of the preceding line fit twice, using G=diag(1,2,1). Then AᵀGA=diag(4,2), AᵀGb=(5,3), so (α,β)=(5/4,3/2). The residual is (1/4,−1/4,1/4), with weighted squared error 1/4 and AᵀGr=0. That value should not be compared with the previous 1/6 as though both were the same objective. The metric changed; the new coefficients minimize the new weighted sum.
Over Cᵐ, use ⟨u,v⟩=u* v, conjugate-linear in the first argument and linear in the second; * means conjugate transpose. Then ⟨u,u⟩=Σ|ui|² is nonnegative. Plain uᵀu fails: for u=(1,i) it gives 0 although u≠0. Orthogonal projections and least squares replace transposes by conjugate transposes, so Q*Q=I and A*Ax=A*b. All numerical controls in this lesson remain explicitly real; complex notation here states the correct extension.
Keep exact reasoning and measured data distinct
Normal equations explain the geometry, but explicitly forming AᵀA can amplify numerical difficulty when columns are nearly dependent. When A has full column rank, κ₂(AᵀA)=κ₂(A)²; the singular-value explanation comes in lesson 128. A QR-based solve instead obtains Rx=Qᵀb without first forming the Gram matrix. Robust implementations often use Householder transformations; classical Gram–Schmidt in floating point can lose orthogonality.
Do not label a column redundant just because a rounded residual looks small, and do not interpret an exact rational example as a measured error estimate. Numerical rank depends on scale, precision and tolerance. Exact rank, numerical conditioning and statistical uncertainty answer different questions. The explorer uses exact small rational inputs so that algebraic identities can be checked without a rounding convention.
Least squares also reflects a modelling choice. Squaring residuals gives large deviations strong influence, so an outlier can move a fit substantially. A linear least-squares model is linear in its unknown coefficients, even if its known columns contain t² or sin t. A least-squares line alone establishes neither causation nor an appropriate noise model. Claims about unbiasedness, confidence intervals or an optimal statistical estimator need assumptions beyond this geometric minimization.
Predict a residual, then test the reason
In the explorer, first choose a column space and target. Predict whether the target is already representable and whether its coefficients are unique. Compare the oblique line with its redundant-column version: the ordinary fitted vector must agree, while the coefficient descriptions can differ. The zero subspace tests a boundary case without dividing by a zero vector.
Next change between the ordinary and stated positive weighted inner products. The fitted vector can move, but the displayed normal residual AᵀGr must remain zero. For a two-coordinate example, compare the input arrow, fitted arrow and residual segment; the drawing uses the same units on both coordinate axes. A weighted residual is labelled without an ordinary right-angle claim.
The three-row examples use exact tables rather than pretending that a two-dimensional arrow picture displays a three-dimensional observation vector. The line-fit example connects those tables to the static t,y diagram above. Use the argument ‖b−w‖²=‖r‖²+‖p−w‖² to explain a successful numerical check: the computations illustrate why the projection is best, while orthogonality supplies the proof.
Predict the fit, then inspect the residual
Choose a column space, a target and a positive metric. Compare a unique fitted vector with coefficients that may have a full family of solutions. Every displayed calculation uses exact fractions.
| Row | Column 1 |
|---|---|
| Row 1 | 2 |
| Row 2 | 1 |
Target b=(1, 3). G is diagonal with positive entries (1, 1). The metric is uᵀGv.
Fitted vector p=(2, 1); residual r=(-1, 2). Always b=p+r.
Subspace dimension 1; coefficient nullity 0. The fitted vector is unique. The coefficients are also unique.
| Input column | Projection coefficients on earlier retained remainders | Orthogonal remainder | Squared metric norm | Action |
|---|---|---|---|---|
| 1 | No earlier remainder | (2, 1) | 5 | Keep |
Unnormalised orthogonal basis: (2, 1). Normalising is unnecessary for these exact projector calculations.
| Row | Column 1 | Column 2 |
|---|---|---|
| Row 1 | 4/5 | 2/5 |
| Row 2 | 2/5 | 1/5 |
| Row | Column 1 | Column 2 |
|---|---|---|
| Row 1 | 4/5 | 2/5 |
| Row 2 | 2/5 | 1/5 |
| Row | Column 1 | Column 2 |
|---|---|---|
| Row 1 | 4/5 | 2/5 |
| Row 2 | 2/5 | 1/5 |
| Row | Column 1 | Column 2 |
|---|---|---|
| Row 1 | 4/5 | 2/5 |
| Row 2 | 2/5 | 1/5 |
| Row | Column 1 |
|---|---|
| Row 1 | 5 |
Normal right side AᵀGb=(5); normal residual AᵀGr=(0).
For comparison, ordinary Aᵀr=(0). With a weighted metric this ordinary product need not be zero.
One coefficient solution x₀=(1). There are no free coefficient directions. Reconstructing gives Ax₀=(2, 1).
Squared metric lengths: ‖b‖²G=10, ‖p‖²G=5, ‖r‖²G=5. Check ‖b‖²G=‖p‖²G+‖r‖²G.
The two metrics are different objectives. A weighted fit need not minimise ordinary squared errors. These finite rational examples illustrate the article’s general proofs; they do not estimate a noise model.
Worked examples
Project onto a non-unit spanning vector
Project b=(3,0) onto span((2,1)) in the ordinary dot product.
- Compute u·u=5 and u·b=6, so the coefficient is 6/5.
- Multiply the coefficient by u to get p=(12/5,6/5).
- Subtract to get r=(3/5,−6/5), and check 2(3/5)+(−6/5)=0.
- Compute ‖r‖²=9/25+36/25=9/5.
The projection is (12/5,6/5), and the distance is 3/√5. The coefficient is not itself a distance.
Compute the complement of a plane
For W=span((1,0,1),(0,1,1)) in R³, find W⊥.
- Write r=(a,b,c). Orthogonality to the spanning columns gives a+c=0 and b+c=0.
- Thus r=c(−1,−1,1).
- This line has dimension 1, consistent with dim W=2 in R³.
W⊥=span((−1,−1,1)). Testing only one of the two plane directions would leave an entire plane of possibilities.
Orthogonalize the retained oblique basis
Apply Gram–Schmidt to (2,1),(1,−1), in that order.
- Set u₁=(2,1), with squared norm 5.
- The second column has dot product 1 with u₁, so subtract (1/5)u₁.
- The residual u₂=(3/5,−6/5) has squared norm 9/5 and is orthogonal to u₁.
- Normalize to q₁=(2,1)/√5 and q₂=(1,−2)/√5.
The original span is unchanged. Both normalized vectors have length 1 and dot product 0; an oblique basis has become an orthonormal basis.
Keep the two orthonormal-column products distinct
Let Q have columns (1,0,0) and (0,1,0). Find QᵀQ, QQᵀ and the projection of (2,−1,4).
- Q is 3-by-2. Its two orthonormal columns give QᵀQ=I₂.
- The reverse product is the 3-by-3 matrix diag(1,1,0).
- Multiplying by b gives p=(2,−1,0), with perpendicular residual (0,0,4).
QQᵀ projects onto the xy plane; it is not I₃. The distance to the plane is 4.
Fit three observations exactly in least-squares geometry
Fit α+βt to (t,y)=(-1,0),(0,1),(1,3).
- Use A=[[1,−1],[1,0],[1,1]], so AᵀA=diag(3,2) and Aᵀb=(4,3).
- Solve for α=4/3, β=3/2.
- The fitted vector is (−1/6,4/3,17/6) and the residual is (1/6,−1/3,1/6).
- Check the sum and the t-weighted sum of the residuals are both zero.
The unique coefficient vector is (4/3,3/2), the squared residual is 1/6, and the fit is not an exact solution of Ax=b.
Find a unique fit with nonunique coefficients
For A=[[1,2],[1,2],[0,0]] and b=(1,0,2), find all ordinary least-squares coefficients.
- Every fitted vector has form (s,s,0), where s=x₁+2x₂.
- Minimize (1−s)²+s²+4. Completing the square gives 2(s−1/2)²+9/2.
- Thus s=1/2 and the fitted vector is (1/2,1/2,0).
- All coefficients satisfy x₁+2x₂=1/2, so x=(1/2−2t,t) for any real t.
The fit and residual (1/2,−1/2,2) are unique, but coefficients are not. Their squared residual is 9/2; inverting AᵀA is invalid.
Track the metric as well as the minimizer
Repeat the three-observation line fit with G=diag(1,2,1).
- The weighted Gram matrix is diag(4,2), and the weighted right-hand side is (5,3).
- The coefficients become (5/4,3/2), giving fitted values (−1/4,5/4,11/4).
- The residual (1/4,−1/4,1/4) satisfies AᵀGr=0.
- Its weighted squared norm is 1/16+2/16+1/16=1/4.
The intercept changes because the middle observation receives more weight. The slope stays 3/2 in this symmetric example; that is not a general rule.
Test the missing condition in a projector claim
Does P=[[1,1],[0,0]] give an ordinary orthogonal projection?
- Multiply to check P²=P, so P is idempotent.
- Pᵀ≠P, so it fails the ordinary symmetry condition.
- For b=(0,1), Pb=(1,0) and r=(−1,1). The residual is not orthogonal to the horizontal image line.
It is an oblique projection, not the ordinary nearest-vector projection. Idempotence alone does not establish orthogonality.
Try it yourself
Is x₁y₁−x₂y₂ an inner product on R²?
Show the answer and reasoning
No.
It assigns squared value −1 to (0,1), violating positive definiteness.
Is zero orthogonal to every vector? Can it be normalized?
Show the answer and reasoning
Yes; no.
Its dot product with every vector is zero, but its norm is zero, so division by its length is undefined.
Project (1,3) onto span((2,1)).
Show the answer and reasoning
p=(2,1); r=(−1,2).
Both u·b and u·u equal 5, so the coefficient is 1; the residual dot product with u is zero.
Why is (u·b)u not the general projection formula?
Show the answer and reasoning
It omits the factor 1/(u·u).
It is correct for unit u. Rescaling a non-unit spanning vector would otherwise change the projected vector.
Find the ordinary orthogonal complement of span((1,2,0)).
Show the answer and reasoning
{(a,b,c): a+2b=0}=span((−2,1,0),(0,0,1)).
Orthogonality imposes one linear equation in three coordinates, so the complement is a plane.
Can a nonzero, pairwise orthogonal list be dependent?
Show the answer and reasoning
No.
Taking the inner product of a purported relation with each list entry isolates its coefficient times a positive squared norm.
In Gram–Schmidt, a new input has zero residual after subtracting prior projections. What does that mean in exact arithmetic?
Show the answer and reasoning
The input is already in the earlier span.
It adds no independent direction. Skip it rather than normalize zero.
If Q is 5-by-2 with orthonormal columns, what are the sizes and roles of QᵀQ and QQᵀ?
Show the answer and reasoning
QᵀQ=I₂; QQᵀ is a 5-by-5 rank-two projector.
The first product acts on the two basis coefficients; the second reconstructs the projected part of a five-coordinate vector.
If p∈W and b−p∈W⊥, why is p uniquely closest?
Show the answer and reasoning
‖b−w‖²=‖b−p‖²+‖p−w‖² for every w∈W.
The extra nonnegative term vanishes exactly at w=p.
Can a least-squares fit be unique while its coefficients are not?
Show the answer and reasoning
Yes, when A has dependent columns.
Projection onto Col(A) fixes one fitted vector; adding any kernel vector to a solution preserves that fit.
Find the best ordinary constant fit to responses 0,1,3.
Show the answer and reasoning
The constant is 4/3.
The design column is (1,1,1), so the normal equation is 3c=4. Its residual has sum zero.
Under a positive-definite G, must an optimal residual satisfy Aᵀr=0?
Show the answer and reasoning
Not generally; it satisfies AᵀGr=0.
The inner product changed. Ordinary visual perpendicularity need not express weighted orthogonality.
For v=(1,i), compare vᵀv and v*v.
Show the answer and reasoning
vᵀv=0; v*v=2.
Complex inner products use conjugation. The transpose-only expression cannot define a positive-definite norm.
Does exact invertibility of AᵀA make normal equations the most reliable floating-point method?
Show the answer and reasoning
No.
Near dependence can make the Gram matrix poorly conditioned. QR or SVD can avoid directly forming that product; the statistical model still needs its own justification.
What to carry forward
- An inner product specifies the geometry. Positivity, units, conjugation and any weights affect what distance means.
- A projection splits b into a representable part p∈W and a residual r∈W⊥. Pythagoras proves the unique closest-vector result.
- Orthogonal basis coefficients are inner products divided by squared basis lengths; orthonormal coordinates remove those denominators.
- Gram–Schmidt removes earlier represented components. A zero exact residual signals redundancy, not a new direction to normalize.
- Least squares is projection onto a column space. The normal equations are always consistent, while coefficient uniqueness requires independent columns.
- The fitted vector is unique even for a redundant design. Do not invert a singular Gram matrix or confuse one chosen coefficient solution with a unique one.
- Weighted and complex least squares retain the geometry with the appropriate inner product and adjoint. Ordinary right-angle claims require the ordinary metric.
- Exact algebra, numerical conditioning and statistical validity are separate checks. QR and SVD provide computational tools without replacing the modelling assumptions.
References
Sources for the concepts and teaching approaches in this article.
- Interactive Linear Algebra · Online editionDan Margalit and Joseph RabinoffOpen textbook · §§6.1–6.5Dot products and orthogonalityOrthogonal complementsOrthogonal projectionsOrthogonal sets and Gram–SchmidtLeast squares
- Linear Algebra Done Right · Fourth editionSheldon AxlerOpen textbook · §§6A–6C · PDF
- LAPACK Users’ Guide · QR factorizationLAPACK authorsNumerical linear algebra reference
- 18.335J · Numerical methods · Week 4Steven G. JohnsonUniversity course · QR and least squares