An overdetermined linear model cannot necessarily reproduce every observation vector. Some part of that vector can lie outside the space generated by its feature columns. QR factorization gives coordinates that separate the adjustable part from an orthogonal residual that no coefficient choice can remove.

This separation is an exact geometric statement about a stipulated model. It does not infer that an unexplained residual is sensor noise, identify its cause, or certify prediction accuracy. The following three-observation example uses original dimensionless inputs, with no numerical package, calibration system or robot experiment executed.

Write the two-column model

Let the first feature column be a_1 = (1,1,0) transpose and the second a_2 = (2,0,2) transpose. These form a three-by-two matrix A. Its predictions are A x for a two-entry coefficient vector x. Set the observed vector b = (3,0,0) transpose.

Ordinary unweighted least squares chooses x to minimize the squared Euclidean length of b-Ax. With three observations but only two independent feature directions, the model's column space is a plane through the origin. An arbitrary b can have a component normal to that plane.

SciPy's official QR reference defines orthogonal Q, triangular R, and full versus economic dimensions. The original LAPACK manual describes Q as a product of elementary reflectors. Those contracts motivate the representation; the explicit basis and fitting calculations below are independently derived rather than library output.

Construct an orthonormal basis

Normalize a_1 to obtain q_1 = (1,1,0)/sqrt(2). Its dot product with a_2 is sqrt(2). Removing that projection from a_2 leaves (1,-1,2), whose length is sqrt(6). Therefore q_2 = (1,-1,2)/sqrt(6).

Choose q_3 = (1,-1,-1)/sqrt(3). Its dot products with q_1 and q_2 are zero, and its length is one. The matrix Q with these three columns is orthogonal: Q transpose Q is the three-dimensional identity.

The full R has rows (sqrt(2),sqrt(2)), (0,sqrt(6)), and (0,0). Multiplying Q by R recovers both columns of A. The last zero row expresses the absence of a third feature direction, rather than a zero observation.

Transform observations and preserve their norm

Multiplying b by Q transpose produces c = (3/sqrt(2),3/sqrt(6),sqrt(3)) transpose. Because Q is orthogonal, transforming a residual by Q transpose preserves its squared length.

Consequently, the objective is [3/sqrt(2)-sqrt(2)x_1-sqrt(2)x_2]^2 + [3/sqrt(6)-sqrt(6)x_2]^2 + [sqrt(3)]^2.

The last term does not contain either coefficient. It is the irreducible squared residual for this model and these observations. Minimizing the objective means setting the first two bracketed terms to zero; it cannot change the third one.

The second bracket gives x_2 = 1/2. The first then gives x_1 = 1. The fitted vector is A x = (2,1,1), and the residual b-Ax is (1,-1,-1). Its squared length is three.

Verify the projection directly

Both feature columns are orthogonal to that residual: (1,1,0) dot (1,-1,-1) = 0, and (2,0,2) dot the same residual is also zero. No small coefficient change can cancel a component normal to the feature plane.

The fitted vector has squared length six. The residual has squared length three, and their dot product is zero. Pythagoras therefore gives ||b|| squared = 6 + 3 = 9, matching the original observation vector's length calculation.

This is a complete minimum proof. Any different coefficients add nonnegative squares to the transformed objective. Since the two triangular diagonal entries are nonzero, only x = (1,1/2) makes both adjustable brackets vanish.

Reduced Q is not an invertible change of coordinates

An economic QR representation keeps Q_2 = [q_1,q_2] and the upper two rows R_2. It still satisfies A = Q_2 R_2 and Q_2 transpose Q_2 = I_2. But Q_2 Q_2 transpose is a projection onto the feature plane, not the three-dimensional identity.

For this example, Q_2 Q_2 transpose b = (2,1,1), the fitted vector. The length squared of Q_2 transpose b is six, while the original b has length squared nine. The missing three belongs to the omitted orthogonal direction.

Thus applying reduced Q transpose to b is not, by itself, a norm-preserving transformation of every three-vector. It preserves the relevant fitted coordinates while dropping the orthogonal component. Confusing full and reduced Q can hide the residual rather than calculate it.

Change observations in two different directions

Add twice the original residual to b, producing b_new = (5,-2,-2). Because that perturbation is perpendicular to both feature columns, the fitted coefficients remain (1,1/2). The fitted vector remains (2,1,1), but the new residual is (3,-3,-3), with squared length 27.

By contrast, adding tau q_1 to b changes its first fitted coordinate by tau. The solution's x_1 changes by tau/sqrt(2), while x_2 stays fixed. The residual component along q_3 is unchanged.

These constructions distinguish changing the observations inside the model's column space from changing them perpendicular to it. Residual size and coefficient changes therefore respond to different observation directions, even for one fixed well-defined matrix.

Keep representation separate from diagnosis

Flipping the sign of one Q column and the matching R row leaves their product unchanged. The fit is determined by the represented feature space, not by one arbitrary basis sign. Rank-deficient columns or a different weighting of observations would require a modified problem definition.

This example makes no universal floating-point accuracy claim and does not supply a physical interpretation for the residual. Its contribution is the separation itself: the triangular coordinates identify what coefficients can fit, and the remaining orthogonal coordinates identify what this linear model cannot reproduce.

Sources checked October 24, 2026:

SciPy: scipy.linalg.qr: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.qr.html

LAPACK DGEQRF original manual, University of Utah hosting: https://www2.math.utah.edu/software/lapack/lapack-d/dgeqrf.html

Concept illustration: A small desktop robot beside a laptop showing a generic workflow provides robotics context for this analytical model. The image does not depict the article's numerical example, a verified experiment, a product specification, or deployment evidence.