Because has full column rank, is invertible. The ordinary least squares estimator is
It satisfies the normal equations
so the residual is orthogonal to the column space of . For any ,
The two terms are orthogonal, and the Pythagorean theorem in an inner-product space gives
Thus minimizes the least-squares objective.
The Reverse-order law for the Moore--Penrose inverse is false in general. Take
Then
A sufficient condition is
so that has full column rank and has full row rank. Indeed and ; these identities make satisfy all four Penrose equations for .
QR decomposition Created 2026-09-24 Updated 2026-10-14
A reduced QR decomposition of an matrix over the real numbers with full column rank, , writes , where is with orthonormal columns and is a upper triangular matrix with positive diagonal. Applying the Gram-Schmidt process to the columns of constructs and records the coefficients
This last column identity is exactly the matrix multiplication . The upper triangular matrix records that the th input uses only the first new directions, while its positive diagonal records the norms of the nonzero orthogonal projection residuals. Since , one also has ; denotes the transpose and the identity matrix. Over the complex numbers, use the conjugate transpose in these identities.
For the three-dimensional Gram-Schmidt process example, the exact matrices are
For example, the last column reconstructs as
The diagonal entries are approximately . Each is a norm of the new direction before it was scaled to length one.
For a linear least-squares problem, the orthogonal projection of onto the column space of is . Hence the minimizing coefficients solve the linear system by back substitution. Let consist of the first two columns of the example; its reduced factors are and the leading block of . For , the linear system is
Thus , agreeing with the orthogonal projection computed above, and the minimum Euclidean norm of is . The QR decomposition separates building an orthonormal basis from recovering coefficients in the original basis.[ref]
QR decomposition by Givens rotations Created 2026-09-24 Updated 2026-10-14
Successive Givens rotations eliminate entries below the diagonal of a matrix. For an matrix with , process columns ; within column , rotate rows for each whose entry needs elimination. Apply each Givens row-pair update to columns . Both rows are zero in earlier columns, so these operations preserve earlier eliminations. No assumption of full column rank is needed to perform the eliminations.
For a concrete example, take
First use , then :
The entry in position was already zero, so its elimination was skipped. The second Givens rotation combines the remaining pair in column two. This yields the full QR decomposition
The first two columns of and first two rows of give the reduced QR decomposition. Direct multiplication verifies both and . For these displayed factors evaluated in binary64 floating-point arithmetic, the Frobenius norms and are both below ; these measure reconstruction and loss of orthogonality separately.
Figure 1.
Two local Givens row-pair updates turn a matrix into the rectangular of a QR decomposition
. Details.
More generally, if the chronological rotations are , then
Each factor is an orthogonal matrix, so is too. For a rectangular matrix, has zeros below its diagonal; its leading block is an upper triangular matrix. With full column rank, retaining the first columns of gives orthonormal columns. To impose a positive diagonal when necessary, flip matching columns of and rows of , preserving their product.
For a linear least-squares problem, apply the same chronological Givens rotations to the right-hand side , obtaining , without explicitly constructing . Since the Euclidean norm is preserved, solve the leading upper triangular matrix system by back substitution when has full column rank; the remaining entries of give the minimum residual norm. In the example, gives , , and minimum residual Euclidean norm .
The locality is useful for a sparse matrix or an existing QR decomposition needing an extra row: only two rows change at each step, and the new row can be eliminated against the stored upper triangular matrix. For an factor, this extra-row procedure takes rotations and arithmetic operations. Locality does not guarantee preservation of sparsity: mixing rows can create nonzeros wherever either row had one. For a fully populated input, the straightforward elimination uses rotations, each touching columns, giving work. Storage layout, zero patterns and implementation affect speed; this count alone establishes no universal advantage over other QR decomposition algorithms.
The Euclidean norm preservation explains the appeal for numerical stability: exact rotations do not amplify a perturbation's length. Rounded coefficients and Givens row-pair updates still introduce roundoff error. Small reconstruction and orthogonality residuals check the computed factors, while the condition number of the original problem still controls how accurately a linear least-squares problem determines its solution.
If and , then . In particular full column rank of raw does not ensure a nonsingular centered sample covariance matrix. When is singular, its Gaussian precision profile likelihood has no finite maximizer: increase precision along a nonzero null vector.
The identity does not hold for arbitrary matrices. A sufficient condition is that have full column rank and have full row rank.
Ridge regression Created 2026-09-24 Updated 2026-10-14
Ridge regression fits a linear regression model while penalizing the size of its slope regression coefficients. For a fixed design matrix containing the slope predictors, observed responses , and an unpenalized regression intercept , the objective is
Here is the all-ones vector, and is the squared Euclidean norm of the slopes alone. The first term is the residual sum of squares; the second implements regularization. No random-error assumption is needed to define this fit. The convention is a summed squared-error loss: writing the objective as gives the same fit when .[ref]
For an exact example, reuse the constructed pairs from linear regression. Their sample means are and , and the centered cross-products are and . Thus
The ordinary least squares line has slope and residual sum of squares . At , ridge regression has slope , regression intercept , and residual sum of squares ; at these become , , and . Every line passes through : the penalty reduces the slope while retaining the response sample mean.
Figure 1.
Exact synthetic ridge fits flatten around the sample mean as training RSS increases
. Details.
The computational benefit is visible after predictor centering. Write for the design matrix with each column's sample mean subtracted, and . The unpenalized intercept in ridge regression gives , and the closed-form ridge regression estimator solves
For any nonzero vector and , . This positive-definite matrix is therefore invertible even when lacks full column rank, including repeated columns or . The unique penalized slopes resolve the ambiguity of rank-deficient ordinary least squares; they do not supply evidence about slope directions absent from the data. This makes ridge regression useful for multicollinearity.[ref]
Predictor centering and scaling serve different purposes. Centering handles the free regression intercept. Scaling determines what counts as a large slope: replacing by changes its coefficient to for the same predictions, changing its contribution to an unweighted penalty. A common convention forms standard scores using each nonconstant predictor's sample standard deviation , then penalizes slopes in those coordinates. Since , this is the weighted penalty in the original units. Constant columns have and must be removed before this scaling. Scaling is a modelling choice; equal penalties in original units and in standardized units define different fits.[ref]
The singular value decomposition explains the shrinkage. If is the compact decomposition using the positive singular values , with columns of , then
The principal-component shrinkage by ridge regression factors are between and : directions with small singular values are damped most. As , the fitted values approach ; the vanishing-penalty ridge limit recovers the ordinary least squares fitted vector as , even if the slope estimates at zero penalty are nonunique. The covariance and bias of a ridge regression estimator describes the resulting bias-variance tradeoff. A penalty can reduce variance of an estimator while introducing bias of an estimator; the unbounded directional risk of fixed ridge shrinkage rules out a uniform improvement for a fixed positive penalty over all possible signals.[ref]
For a second exact construction, choose a centered orthonormal set of three vectors,
and set and . The squared singular values are and . At , the fitted coordinates along are , retaining and of their ordinary least squares values . At they become , retaining and . The unfittable component contributes to every residual sum of squares, giving total values , , and at penalties . These are constructed fits, not measured prediction results.
Figure 2.
Exact synthetic ridge shrinkage retains the strong singular direction longer than the weak one
. Details.
The penalty is a hyperparameter, so fitting slopes at a fixed value and selecting that value are separate tasks. Use a validation set or K-fold cross-validation to compare candidate penalties by held-out squared-error loss. In each split, compute predictor sample means and scales from that split's training data, apply the same transformation to its validation set, and refit the slopes; using held-out information in preprocessing introduces data leakage. Minimum training residual sum of squares cannot select useful shrinkage: ordinary least squares already attains the smallest possible value.[ref] After model selection, refit on all training data with the selected penalty. A separate test set or nested cross-validation assesses the entire selection procedure; a low selected validation score alone is no performance guarantee.[ref]
Singular matrix Created 2026-09-29 Updated 2026-10-18
An square matrix over a field, with , is singular when it has no matrix inverse. Geometrically, its linear map loses at least one input direction: some nonzero vector satisfies , so . Over the real numbers, the following family makes that loss visible:
Figure 1.
Compression by becomes collapse only at
. The square retains two-dimensional extent for and , but maps to a segment at . The orange points come from three inputs with the same first coordinate and different second coordinates. They coincide only at . This is exact illustrative geometry, not measured data. Details.
For this diagonal matrix, . Whenever , the input can be recovered as and the kernel is . At , the kernel becomes : the entire second coordinate is forgotten. Consequently has no solution if , and has the solution straight line , , if . A singular matrix therefore need not make a particular linear system inconsistent; it prevents unique recovery when that linear system is consistent.
For an square matrix, all these tests describe the same failure:
Here is the field of scalars. Equivalently, the columns are linearly dependent, the linear map is neither injective nor surjective, and some outputs cannot be reached. See the invertible matrix equivalences and Strang's MIT 18.06SC lecture summary, Multiplication and inverse matrices, p. 2. Over an infinite field, every consistent linear system for a singular matrix has infinitely many solutions; over a finite field with elements and nullity , it has exactly solutions. This follows by adding each kernel vector to one solution.
The square hypothesis is essential. For an matrix, injectivity means matrix rank (full column rank), whereas surjectivity means matrix rank (full row rank). A rectangular matrix can satisfy one condition without the other; its kernel and image of a linear map give the useful tests without calling it a singular matrix.
Exact singularity also differs from sensitivity. For , is an invertible matrix, but its smallest singular value is and its condition number in Euclidean norm is . A change changes the recovered input by : with and , an output change of causes an input change of . These are exact toy values, not measurements. The condition number quantifies this sensitivity before a direction is lost; see Steve Marschner, Condition numbers, §2. A small determinant alone is not a reliable sensitivity test: has determinant yet condition number one for every nonzero real , since both singular values shrink equally.
Trivial kernel Created 2026-09-28 Updated 2026-10-14
A linear map has a trivial kernel when : the zero vector is the only input producing the zero output. The kernel is a singleton set, not the empty set, because every linear map sends zero to zero. Equivalently, its nullity is zero and is injective. This holds even without a finite-dimensional hypothesis; see Linear Algebra Done Right by Sheldon Axler (4th edition).
The reason this zero-output test controls all outputs is linearity:
With a trivial kernel, equal outputs force equal inputs. Therefore every equation has at most one solution. Existence is a separate question: must belong to the image of a linear map. In the fiber description under nullity, is just the single point .
For example, the linear map , , has trivial kernel and full column rank:
The output comes from exactly , while is unreachable. Conversely, , , is surjective and has full row rank, but its kernel is : every output comes from the solution straight line .
For an matrix, a trivial kernel is equivalent to matrix rank and linear independence of its columns. It can therefore occur only if . If , the rank-nullity theorem also forces surjectivity, giving an invertible matrix; if , the example shows why unique recovery of reachable inputs does not imply that every output is reachable. Finally, a trivial kernel guarantees exact uniqueness without guaranteeing numerical stability: the singular matrix example has trivial kernel for every , even as its condition number grows without bound when approaches zero.