Gram-Schmidt process Created 2026-09-24 Updated 2026-11-05
The Gram-Schmidt process turns a finite ordered family of linearly independent vectors in an inner product space over the real numbers into an orthonormal basis of their linear span. It keeps every successive linear span, so the first new vectors describe exactly the same directions as the first inputs. Its idea is geometric: remove the orthogonal projection onto directions already found, then divide the remaining vector by its norm. This makes a complicated basis easier to use without changing the vector subspace it describes.[ref]
Start with and . At step , use the previously obtained orthonormal set to define
The sum is the orthogonal projection onto a finite-dimensional subspace , and is the orthogonal projection residual. Linear independence ensures : otherwise would already be a linear combination of earlier inputs. If the input family is linearly dependent, use only the retained orthonormal vectors in the sum and omit an input whenever its remainder is the zero vector; do not divide by zero. The retained outputs still form an orthonormal basis of the original linear span, but their number can be smaller than .
For a short verification, orthonormality makes every earlier inner product vanish:
Also is minus a linear combination of earlier vectors, while is plus that same linear combination. These two inclusions, followed by division by a nonzero norm, give
The argument also works in an inner product space over the complex numbers with the existing inner product convention, linear in the first argument: the coefficients remain . With the convention linear in the second argument, write instead.
For a first picture, take and in with the ordinary dot product. Then
Subtracting the diagonal component leaves an orthogonal direction; dividing by its norm makes its length one. If the second input were instead, its orthogonal projection would be the entire input and , revealing linear dependence.
For a full three-dimensional calculation, use the ordinary dot product and the input vectors
The first two steps give
At the third step, the inner products are and . Consequently
The three numerator vectors have pairwise dot products and squared Euclidean norms . Thus the displayed outputs are indeed an orthonormal basis, and the three nonzero remainders also confirm linear independence of the inputs. Keeping the removed coefficients produces the QR decomposition below.
An immediate reward is a reusable orthogonal projection: once an orthonormal basis of a vector subspace is known, any vector has
For the linear span of just the first two inputs in the three-dimensional example, gives . Its orthogonal projection residual is , visibly in the missing orthogonal direction. This is the geometry behind the linear least-squares problem.
The formulas above describe exact arithmetic. With floating-point arithmetic, subtracting an orthogonal projection nearly equal to the input can leave a small remainder; dividing by its small norm can magnify existing roundoff error. The classical Gram-Schmidt and modified Gram-Schmidt arrangements agree in exact arithmetic but can give different rounded results. Exact linear dependence and a small computed remainder therefore require different judgments in a numerical implementation.[ref]
Least squares 2026-10-31
The least squares approach chooses parameters by minimizing the sum of squared residuals. A linear least-squares problem has affine residuals, whereas nonlinear least squares permits nonlinear dependence on the parameters. The Euclidean norm makes the objective ; the factor one-half simplifies its derivatives without changing its minimizers.
Let and consider an arbitrary variation . The objective for the linear least-squares problem is
At a minimizer the derivative at must vanish for every , so . Conversely, when this holds, the same expansion at gives for every . Thus minimizes the residual norm if and only if . These least-squares normal equations do not require to have full rank; without full rank the minimizing vector need not be unique.
The original PDF has , not the 2 in the converted TeX. Using the PDF's matrix gives
The least-squares normal equations consequently have the unique solution
As a direct check, , whose inner product with either column of is zero. The positive determinant verifies full column rank for this particular problem.
A full QR decomposition of a real by matrix with writes
where is an orthogonal by matrix and is upper triangular by . In the full-column-rank case is invertible. Equivalently the reduced factorization is with . Householder transformations can construct the full factorization.
Let with . Since orthogonal transformations preserve the Euclidean norm,
Therefore the linear least-squares problem has the full-rank solution
Back substitution solves this triangular system without forming . If the matrix is rank deficient, use a rank-revealing pivoted factorization and minimize over its independent columns; the minimizer need not be unique. The original PDF minimizes over ; the converted TeX's minimization over is a transcription error.
The linear least-squares problem is to minimize over , allowing an overdetermined system to have a nonzero residual. For a full QR decomposition, is orthogonal and is with an upper-triangular top block. Orthogonal transformations preserve the Euclidean norm, so
If has full column rank, the top triangular block is nonsingular; setting its residual to zero gives the unique minimizer, while the remaining residual is independent of . Without full column rank, minimizers still exist but need not be unique.
For the specified matrix, one Householder reflection already produces an upper-triangular matrix. Take , the difference between the first column and , and set
The formula gives , . Direct multiplication yields the Householder QR decomposition
All subdiagonal entries in the remaining columns are already zero, so no further reflection is needed. For the supplied right-hand side, . Back substitution gives , , , hence
The residual is orthogonal to every column of , independently confirming the normal equations .
The linear least-squares problem is to choose minimizing the Euclidean norm of the residual:
For a QR decomposition , orthogonality of gives . If has full column rank and is in standard form with invertible upper-triangular , the minimizer solves .
Applying the Gram-Schmidt process to the columns of the given matrix yields
Indeed, is an orthogonal matrix and . Moreover,
Back substitution in the leading triangular system gives
so the unique least-squares solution is
The unused final transformed residual component is , so the minimum residual norm is .
For , define by . If , then in particular
so . Thus is injective. Since a finite-dimensional vector space and its dual space have the same dimension, is also surjective and hence an isomorphism. This is the finite-dimensional real case of the Riesz representation theorem.
The adjoint operator of is the unique linear map satisfying
for every and . In the stated orthonormal bases, if and denote coordinate columns, then
Therefore the matrix of is the matrix transpose .
For ,
Hence . Taking orthogonal complements in the finite-dimensional space proves the image-kernel orthogonality for an adjoint
Put . For any ,
This is minimized at exactly when , equivalently when . Thus the normal equation for a linear inverse problem is
For the given linear least-squares problem,
The normal equations and have the unique solution
Every point in the affine search space is uniquely , since the columns of form a basis. Its linear-system residual is , so minimizing the residual is exactly the linear least-squares problem .
Use the standard starting choice and an orthonormal extended basis . If , then and orthonormality gives
The starting-vector choice is needed for this particular representation; an arbitrary orthonormal basis need not have those initial coordinates.
The Arnoldi iteration constructs the basis. At column , orthogonalize against , recording coefficients ; normalize the remaining vector with to get . This makes an upper Hessenberg matrix of size . The resulting GMRES algorithm starts from , grows this Arnoldi basis, solves the small least-squares problem, and sets . Its small residual norm provides the stopping test. Incremental Givens rotations efficiently update the small QR decomposition instead of solving it anew. Zero initial residual means the system is already solved; Arnoldi breakdown gives an invariant subspace and, for nonsingular , permits exact solution within it.
The orthonormal columns give . Thus is the orthogonal projection onto the column space of , and
The two terms are orthogonal, so the Pythagorean identity gives
Only the first term depends on . Consequently the linear least-squares problem has the unique answer
The orthogonal projection gives
The first summand has every column in the column space of , and the second has every column in its orthogonal complement. They therefore have zero Frobenius inner product. The Pythagorean identity, together with , gives the stronger exact formula
Consequently
with equality exactly when . Thus solving the linear least-squares problem for each column chooses the best coefficients in the prescribed column space.
Write and . The Arnoldi decomposition and give
Because has orthonormal columns, it preserves the Euclidean norm. The generalized minimal residual method therefore reduces to the small linear least-squares problem
Use Givens rotations on the upper Hessenberg matrix to obtain a QR decomposition
where is an orthogonal matrix and is an upper triangular matrix. Then solve by backward substitution in a triangular system and form . The resulting minimum linear-system residual has Euclidean norm .
The small problem has a unique answer: if , the Arnoldi decomposition gives . The invertible matrix implies , and the orthonormality of then gives . Thus has full column rank and is nonsingular.
The least-squares normal equations are
The full column rank of gives for nonzero , so is a symmetric positive-definite matrix. Apply the Conjugate gradient method to this linear system. To verify that its solution is the desired one, let solve the displayed equations. Then , and for any the Pythagorean identity gives
Thus is the unique minimizer of the linear least-squares problem.
One can apply without forming the Gram matrix: compute . More explicitly, initialize , , ; until the linear-system residual vanishes, use the Conjugate gradient method recurrence
Each dense application of this way costs operations. The condition number satisfies , where ; this is the conditioning cost of the least-squares normal equations.
Under the permitted singular value bounds, gives
For the symmetric positive-definite matrix in part (iii), its eigenvalues are the squared singular values of , so
Apply the supplied conjugate gradient convergence bound to . For and nonzero , the function increases with , giving
Thus the error in this weighted norm contracts at a guaranteed exponential factor of at most per iteration, up to the prefactor . Here . The Pythagorean identity in part (iii) also identifies with the excess squared linear least-squares problem objective, which consequently decreases by a bound proportional to . For the Euclidean norm, the same eigenvalue bounds give .
For relative accuracy in the -weighted norm, it is sufficient to take
Compute once in operations. Each iteration applies with two dense matrix multiplications and uses further arithmetic operations; when this costs . Hence the total cost is
Using finite termination of the conjugate gradient method in exact arithmetic refines this to . Explicitly constructing first would add setup work and is unnecessary. These accuracy estimates concern relative error; an absolute tolerance replaces by when . If , the initial guess already solves the problem.
As in part 2(b)(v), the Gaussian assumption alone does not make the printed singular value interval a certainty. For example, the event that every entry of has absolute value below a sufficiently small positive number has positive probability and forces , contradicting the asserted lower endpoint. The displayed rate is therefore conditional on the singular-value bounds authorized by the paper. The cost and convergence derivation are exact under that condition; an unconditional probabilistic statement would need an additional failure-probability estimate.
For the linear least-squares problem objective function, direct expansion with gives
Its gradient is , so the middle term equals .
Use the supplied thin singular value decomposition . Since , the linear map preserves the Euclidean norm. The square matrix is an orthogonal matrix, so . Consequently
Substitution into the expansion proves
Thus is a strongly convex function with modulus . This modulus is sharp: choose for an index attaining the smallest singular value. The Hessian matrix is , so the same conclusion says that its smallest eigenvalue is .
For a hyperfine multiplet governed by the magnetic-dipole hyperfine interaction, adjacent frequency gaps obey . The five measured gaps for the first isotope are approximately in the ratios . Therefore the six levels have : the first measured gap corresponds to higher . In particular and , giving
This inference uses both the number of intervals and their successive ratios. Merely seeing six levels would specify only and would not by itself establish equality.
Solving a linear least-squares problem for a fit through the origin, taking the rounded frequencies as equally weighted, gives
Thus the scale of the hyperfine structure is about J, or eV. The displayed frequencies have unequal rounding precision, so additional fit digits are not physically warranted. The gap pattern supports a leading dipole interval rule, with small residuals that do not establish higher-multipole constants without uncertainties.
The total width between and is , about GHz in frequency units. The sign of , the absolute nuclear g-factor and the electronic field coefficient cannot be separated from these gap magnitudes alone. Measuring the level ordering or using another known magnetic property would supply additional information. The figure in b shows the positive- ordering as an illustration.
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.