This is a rapid-fire trap-detector for Ordinary Least Squares. Every item below targets a spot where intuition quietly lies. Cover the answer, commit to a reason (not just "true"/"false"), then reveal. If your reason is wrong even when your verdict is right, you have not understood the trap.
Before any trap makes sense, pin down the five objects every question below leans on. Say each one in plain words before you read on.
Look at the geometry that every "orthogonality" and "projection" answer secretly refers to:
The prediction vector Xθ can only ever live inside the flat plane Col(X). The closest point in that plane to the target y is the foot of the perpendicular dropped from y — the orthogonal projection. At that closest point the residual r=Xθ∗−y (red) is perpendicular to the whole plane, which is precisely XTr=0.
False. Only when X has full column rank is XTX invertible; if columns are linearly dependent (rank <n+1) the bowl J(θ) has a flat valley floor, so infinitely many θ hit the same minimal cost.
The 2m1 factor in the cost changes the optimal parameters.
False. Multiplying J(θ) by any positive constant rescales the bowl's height but not the location of its lowest point, so argminθJ is untouched — the factor is pure convenience.
Minimizing squared error is the same as minimizing absolute error.
False. Squaring punishes large residuals quadratically, so OLS is pulled harder toward outliers than absolute-error (L1) fitting, giving a different line.
At the OLS optimum, the residual vector r=Xθ∗−y is perpendicular to every column of X.
True. The normal equation is exactly XTr=0, meaning each column of X has zero dot product with the residual — that orthogonality (see the projection figure) is why it is called the "normal" equation.
OLS assumes the noise in y is Gaussian.
The derivation by least squares needs no such assumption, but OLS equals maximum likelihood estimation (Maximum Likelihood Estimation) precisely when the noise is Gaussian — so the Gaussian story is a justification, not a requirement.
Gradient descent and OLS can converge to different parameters on the same convex problem.
False provided the minimizer is unique. When X has full column rank the bowl has one lowest point, so Gradient Descent — run with a step size small enough to guarantee descent — must land at the same θ∗; if rank is deficient both methods only agree up to the flat valley.
Adding the column of ones to X is optional if the data is already centered.
If both x and y have mean zero the fitted intercept is zero, so you can drop it — but for uncentered data omitting the ones column forces the line through the origin and biases the fit.
XTX is always symmetric.
True. For any matrix, (XTX)T=XT(XT)T=XTX, so it equals its own transpose regardless of the data.
If XTX is invertible, OLS is guaranteed to be numerically stable.
False. Invertibility is a yes/no fact; stability is a matter of degree. A near-singular XTX (tiny determinant, huge condition number) inverts in theory but amplifies rounding errors badly — prefer QR Decomposition.
Ridge regression makes the residual Xθλ−y orthogonal to Col(X) just like OLS does.
False. Ridge solves (XTX+λI)θ=XTy, giving XT(Xθλ−y)=−λθλ=0 for λ>0. So the ridge residual is deliberately not orthogonal to the column space — we tilt away from the pure projection to shrink θ and cut variance (Ridge Regression).
Wrong shape. X is m×(n+1), so XTX is (n+1)×(n+1) — inversion is O(n3), driven by feature count n, not sample count m.
"Since (Xθ)Ty=yT(Xθ), we cannot combine those two terms."
Error. Both are 1×1 scalars, and a scalar equals its own transpose, so (Xθ)Ty=yTXθ — that is exactly why the cross terms combine into −2yTXθ.
"∂θ∂(θTXTXθ)=XTXθ."
Missing factor of 2. For a symmetric matrix A, ∂θ∂(θTAθ)=2Aθ; here A=XTX is symmetric, so the correct gradient carries the 2 that later cancels the 21.
"OLS is closed-form, so it is always faster than gradient descent."
False economics. The O(mn2+n3) cost blows up for large n; for n in the tens of thousands, iterative Gradient Descent is far cheaper in time and memory.
"With 5 samples and 20 features, OLS just needs a bigger matrix inversion."
No inversion exists. With m<n+1 the system is underdetermined, XTX is singular, and infinitely many θ fit perfectly — you need regularization or the Pseudoinverse, not a bigger solver.
"Feature scaling doesn't matter for OLS because it has a closed form."
Half-true, dangerous. The exact solution is scale-equivariant, but poor scaling wrecks the condition number of XTX, so Feature Scaling still improves numerical accuracy (and matters a lot for the gradient-descent path).
Why does the residual being orthogonal to the column space mean we found the minimum?
Because the fitted vector Xθ∗ is the orthogonal projection of y onto Col(X) (see figure); for any other in-space point Xθ, the vector y−Xθ=(y−Xθ∗)+(Xθ∗−Xθ) splits into a piece perpendicular to the plane and a piece inside it, so by Pythagoras ∥y−Xθ∥2=∥y−Xθ∗∥2+∥Xθ∗−Xθ∥2≥∥y−Xθ∗∥2 — the projection is strictly closest.
Why is the OLS minimum unique when X has full column rank?
Compute the Hessian: ∇2J=m1XTX. Full column rank means for any nonzero v, vTXTXv=∥Xv∥2>0, so the Hessian is positive definite. A positive-definite Hessian everywhere makes J strictly convex — a strictly convex function has at most one minimizer, and the normal equation supplies it.
Why do we square residuals instead of taking their fourth power?
Squaring already fixes sign cancellation and stays differentiable everywhere; higher even powers would over-punish outliers and lose the clean linear normal equation, and they no longer correspond to Gaussian-noise likelihood.
Why does perfect correlation between two features break OLS?
Correlated columns are linearly dependent, so X loses full column rank, det(XTX)=0, and the inverse ceases to exist — the model cannot tell how to split credit between the two identical directions.
Why does adding λI in Ridge always make the matrix invertible (for λ>0)?
XTX is symmetric positive semi-definite (eigenvalues ≥0); adding λI with λ>0 shifts every eigenvalue up by λ, making them all strictly positive, hence positive definite and invertible.
Why does gradient descent need a bounded step size to reach θ∗?
The gradient ∇J=m1XT(Xθ−y) is Lipschitz with constant L=m1λmax(XTX) (the largest eigenvalue). A step size α<2/L guarantees each update lowers J; larger steps overshoot the bowl and diverge — that is the precise meaning of "a good step size."
Why is the pseudoinverse the right tool when XTX is singular?
The Pseudoinverse returns the minimum-norm solution among the infinitely many that minimize the cost, giving a unique, well-defined answer where the plain inverse fails to exist.
Why can OLS overfit even though it never "trains too long"?
Overfitting here is structural, not iterative: with many features relative to samples the model has enough freedom to fit the noise exactly, pushing it to the high-variance end of the Bias-Variance Tradeoff.
What does OLS return if all target values yi are identical?
It fits a flat line: the slope coefficients go to zero and the intercept equals that common value, since a constant already achieves zero residual.
What happens if a data row is duplicated many times?
Duplicates add no new column-rank, so XTX stays invertible only if the distinct points already span the feature directions; the repeats simply reweight the loss toward that point, tilting the fit.
What is the OLS fit when there is exactly one data point per parameter (m=n+1, points in general position)?
The system is square and (generically) full rank, so OLS interpolates every point with zero residual — a perfect fit that is usually pure overfitting, not good generalization.
What does OLS do with a feature column that is all zeros?
A zero column is trivially a linear combination of the others (coefficient zero), so X loses full column rank and XTX is singular; the corresponding θ is unidentifiable and must be dropped or regularized.
As two features become nearly (not exactly) collinear, what happens to the coefficients?
The condition number explodes, so the coefficients swing to huge, opposite-signed, unstable values — a warning sign that calls for Ridge or feature removal even though the inverse technically still exists.
What if you set the Ridge penalty λ≤0?
For λ=0 ridge collapses back to plain OLS (no regularization). For λ<0 you subtract from the eigenvalues of XTX, which can make the matrix singular or indefinite — the "penalty" now rewards large θ, the problem may become unbounded below, and it is no longer a valid regularizer.
What if the noise is heavy-tailed rather than Gaussian?
OLS still minimizes squared error, but it is no longer the maximum-likelihood estimator; heavy tails (e.g. Laplace or Cauchy noise) make squared loss over-react to outliers, so robust losses (L1, Huber) or the corresponding MLE (Maximum Likelihood Estimation) fit better.
Recall Self-check before you leave
Which single geometric fact underlies the entire normal equation? ::: The residual r=y−Xθ∗ is orthogonal to the column space of X, i.e. XTr=0 — every other result is algebra flowing from this projection.