The first elimination multipliers are and . Subtracting those multiples of row one gives lower rows and . The next multiplier is , and the final elimination produces . ThusFor an upper triangular system with nonzero diagonal, back substitution computesFor the supplied triangular system, the last row gives ; the second gives ; the first gives . Hence
For a nonzero real vector , a Householder reflection isWriting gives and , so . Thus a Householder matrix is an orthogonal matrix, and it reflects across the hyperplane perpendicular to .
For , choose , taking the sign to be when , and put . This is nonzero. Since , direct expansion gives and , soApply this construction successively to the trailing part of each column of , extending each reflection by an identity on earlier coordinates. Previously created zeros are preserved. If a trailing column vector is zero, use the identity there. The resulting product is orthogonal and is upper triangular, yielding the QR factorization even when is singular.
To solve , multiply by and use back substitution on when is nonsingular. If is singular, ; an upper triangular determinant is its diagonal product, so at least one diagonal entry is zero. In that case consistency and free variables require separate treatment.
The unshifted QR algorithm starts from , factors , and formsEvery iterate is related by an orthogonal similarity transformation to the previous one and hence to , with the same eigenvalues. Symmetry is preserved. For symmetric matrices with appropriate spectral separation, the iterates approach diagonal form: the off-diagonal entries decrease and the diagonal exposes the eigenvalues. Practical shifted QR accelerates convergence and uses deflation when off-diagonal couplings become negligible. With a shift , factor and set ; the same similarity identity still holds.
Universal diagonal convergence of unshifted QR would be too strong. For example admits the standard factorization , , so the iteration remains at rather than becoming diagonal, although its eigenvalues are . Such equal-modulus cases require a convergence qualification or treatment of a retained block. Similarity is unconditional; convergence to a useful limiting form is an additional algorithmic property.
Multiply by to get the equivalent triangular systemFor nonsingular , compute and use back substitution:Orthogonal transformations preserve the Euclidean norm, making this a numerically stable reduction. The factors can be applied as stored Householder transformations without explicitly forming .
Since is invertible, is singular exactly when is singular. For an upper triangular matrix,Thus a singular forces at least one zero diagonal entry in . In that case, ordinary division-based back substitution must be replaced by a consistency/rank analysis: the system may have no solution or infinitely many solutions, and a rank-revealing factorization can identify the free parameters.
Eliminate the first column with multipliers and . The new second and third rows are and . The next multiplier is , giving final row . Recording these multipliers gives the LU decompositionFor an upper-triangular matrix with nonzero diagonal, the back substitution algorithm works from bottom to top:In the separate triangular system printed in the question, , , and . Hence
Multiplying the system by turns it into . For nonsingular , compute the transformed right side and solve the upper triangular system by back substitution. Orthogonal transformations preserve Euclidean lengths and do not amplify errors in that transformation.
If is singular,Since , at least one diagonal entry of is zero. The resulting triangular system must then be checked for consistency and any free variables, rather than applying divisions by zero.
Solve two triangular linear systems, rather than forming an inverse matrix:For this LU decomposition, forward substitution gives , and . Then back substitution givesAll diagonal entries used as divisors are nonzero. The same LU decomposition can be reused for many right-hand vectors, with only these two triangular solves repeated.
Substitute the QR decomposition into the normal equations:The diagonal of is nonzero, so is invertible. Cancel it algebraically to obtainCompute the three inner products in , then use back substitution in this upper triangular matrix. There is no need to form an inverse or explicitly construct . The orthogonal projection of onto the column space is ; its orthogonal residual proves that this solution minimizes .
Introduce . Solve by forward substitution and then by back substitution. For these factors, the recurrences arefollowed byThe nonzero diagonal entries make both triangular solves well-defined. No matrix inverse is calculated.
Apply the same permutation to the right-hand side and solve two triangular systems. Forward substitution in givesso . Back substitution in gives , , and . Therefore . Substitution in the original system returns , as required.
The supplied factors give . Back substitution in yields and , soMultiplying by the original matrix gives , so this least-squares minimizer has residual zero: this particular overdetermined system is exactly consistent. Full column rank still guarantees uniqueness of the minimizer.
Use banded Gaussian elimination followed by back substitution. To distinguish the right-hand side from the upper-diagonal coefficients , write it as . If the modified pivot elements are nonzero, the tridiagonal elimination recurrences areThey eliminate just the one entry below each pivot element. Solve the resulting upper bidiagonal matrix system byThere is a bounded number of arithmetic operations per row in each sweep, giving arithmetic operations and storage. The unpivoted recurrences cost arithmetic operations under the usual scalar-operation count.
For a general tridiagonal matrix, nonsingularity alone does not guarantee these pivot elements. If a zero or unsafe pivot element occurs, use partial pivoting between the current row and the next row. These are the only possible nonzero candidates in the current column; adjacent row swaps introduce at most a second upper diagonal. Tracking that fill-in keeps both Gaussian elimination and back substitution at arithmetic operations. For example, is invertible but requires a row swap. If the input is singular, report a zero final pivot element; a unique solution cannot be promised, and compatibility or free-variable analysis is a separate issue. No nonsingularity or safe-pivot assumption is silently inferred from the word tridiagonal.
Choose a fixed time increment , let , and approximate by . The Backward Euler method evaluates the transport term at the new time:Rearrange to the linear systemAlthough is a singular matrix, is an invertible matrix for every . In each row, its diagonal entry is and the sum of the absolute values of its off-diagonal entries is ; hence it is a strictly diagonally dominant matrix. Its Gershgorin discs have centre and radius , excluding zero. In particular, the zero eigenvalue of becomes an eigenvalue of .
- Form once. Compute a Pivoted LU decomposition , storing the permutation matrix , the unit lower triangular matrix , and the upper triangular matrix .
- Set .
- At each step form . Solve by forward substitution, then solve by back substitution.
- Advance and repeat until the desired final time. Choose the fixed increment so the final time is an integer multiple of , or refactor if a shorter final step is used.
Both triangular solves use the factors of . The LU factorization of the singular transport matrix from part (a) is not a solver for this new linear system. No matrix inverse needs to be formed. Since and are fixed, the same LU factorization serves every step; only the right-hand side changes. A varying would give without changing these factors.
As a check, multiplying the update by givesexactly reproducing the inventory balance at the sampled times, apart from roundoff error. The Backward Euler method has temporal global error for smooth solutions, so its A-stability does not remove the need to select for accuracy.
Pivoted LU decomposition 2026-10-14
We fix the convention : the permutation matrix acts on the rows of , and the same row ordering must be applied to before the Triangular solves for LU decomposition. Equivalently, , since . LAPACK documents its factors as instead, so check the defining equation rather than just the letter .[ref] Partial pivoting selects the largest absolute candidate in the current column, among rows , before forming elimination multipliers.[ref]
Fundamentals of Numerical Computation by Tobin A. Driscoll and others. §2.6.1, Definition 2.6.1; §2.6.2, Definition 2.6.2 and equation (2.6.1): pivot selection and reordered-row factorization
A zero first pivot element does not imply a singular matrix. For example,Unpivoted Gaussian elimination would divide by zero. Indeed, no with a unit lower triangular matrix exists: would force , contradicting . One row interchange resolves the obstruction. For , use ; back substitution then gives . Using the original with these factors would solve a different linear system.
Partial pivoting bounds each elimination multiplier by one in absolute value in exact arithmetic. This helps control roundoff error, but intermediate entries can still grow; it is not an unconditional guarantee of numerical stability for every matrix.[ref]
Fundamentals of Numerical Computation by Tobin A. Driscoll and others. §2.6.4, Example 2.6.6 and the concluding discussion: stability of unpivoted and pivoted factorization
It also does not remove the original problem's condition number. For the diagonal matrix with , the condition number in the Euclidean norm is . Row permutations preserve this condition number, because they preserve Euclidean norms. Even an exact solve changes from to when the right-hand side changes from to . This sensitivity is a property of the linear system, not a zero-pivot element failure.[ref] 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 coefficientsThis 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 areFor example, the last column reconstructs asThe diagonal entries are approximately . Each is a norm of the new direction before it was scaled to length one.
The computed QR factorization: input matrix , orthonormal columns of , and the upper triangular matrix of orthogonal projection coefficients
. Details. 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 isThus , 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]
https://ocw.mit.edu/courses/18-065-matrix-methods-in-data-analysis-signal-processing-and-machine-learning-spring-2018/resources/lecture-9-four-ways-to-solve-least-squares-problems/. Strang, MIT 18.065, Lecture 9: Four Ways to Solve Least Squares Problems
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, takeFirst 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 decompositionThe 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.
More generally, if the chronological rotations are , thenEach 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.
Reduced QR least-squares solution 2026-10-25
Let with and square invertible upper triangular . The normal equations for linear least squares reduce from to the system in the title. It is solved by back substitution. The geometric identity proves existence and uniqueness of the minimizer. For tall , is an orthogonal projection, not the identity on the entire observation space.
When a fixed matrix is used with several forcing or measurement vectors, compute its Pivoted LU decomposition once. Collect right-hand sides into the columns of , and the corresponding solutions into . ThenEach column undergoes the same row permutation, forward substitution and back substitution. Neither , nor depends on . This is the useful separation between preparing a linear system and applying its solution procedure repeatedly. LAPACK implements it by taking previously computed factors, permuting all right-hand sides, and performing the two triangular solves.[ref]
For the unpivoted factors in Computed three-by-three LU decomposition, takeDirect matrix multiplication checks all three identities , and . The first column reproduces the previous solve; the other two use exactly the same factors. New right-hand sides can also arrive one at a time. If changes, these stored factors generally need to be recomputed.
One row permutation fixes a zero pivot element; each new right-hand side reuses the same LU decomposition and two triangular solves
. Details. Row echelon form Created 2026-10-14 Updated 2026-10-18
A matrix over a field is in row echelon form when all zero rows follow the nonzero rows, each nonzero row's first nonzero entry lies strictly to the right of the preceding row's first nonzero entry, and all entries below each such leading entry vanish. These leading entries are its pivot elements. They need not be one, and entries above them need not vanish.[ref]
Row Reduction. Interactive Linear Algebra by Dan Margalit and others; §1.2.2, Echelon Forms: three echelon conditions and definition of a pivot
The staircase turns a linear system into a sequence of simpler equations. For example,is in row echelon form, with pivot columns 1 and 2. Its second equation determines once is chosen; its first then determines by back substitution. It is not in reduced row echelon form, because the second pivot column contains a nonzero entry above its pivot element. Neither being square nor having a nonzero entry in every row is required.
Elementary row operations bring every matrix to row echelon form: choose a nonzero entry in the leftmost available nonzero column, interchange rows, clear entries below it, and repeat on the remaining rows and later columns. Skip columns with no remaining nonzero entry. Clearing above each pivot element and scaling it to one completes reduced row echelon form.[ref]
Row Reduction. Interactive Linear Algebra by Dan Margalit and others; §1.2.3, The Row Reduction Algorithm, forward steps and Last Step
The nonzero rows of an row echelon form are linearly independent: in a vanishing linear combination, inspecting the first pivot column forces the first coefficient to be zero, then the next forces the second, and so on. They give a basis of the original row space. The number of pivot elements is both the row rank and the column rank. To recover a basis of the original column space, select the corresponding original pivot columns; the reduced column vectors generally belong to a different column space.
Here the arithmetic is exact in the specified field. For floating-point arithmetic, deciding whether a computed entry counts as zero requires a numerical criterion; see Tiny-pivot roundoff in Gaussian elimination and condition number. An exact row echelon form classification alone does not settle numerical stability.
Sparse Gaussian elimination Created 2026-10-14 Updated 2026-10-18
Sparse Gaussian elimination solves a linear system by Gaussian elimination while exploiting its sparse matrix structure to avoid storing zeros and performing unnecessary arithmetic operations. The catch is that zeros in the input need not remain zero: eliminating a shared unknown can couple two equations that previously had no direct coupling. These new positions are fill-in, and their number can depend strongly on the order of elimination.
For a real symmetric positive-definite matrix, the usual direct method is a Cholesky decomposition. Choose an ordering, use symbolic factorization to allocate the predicted factor entries, compute their values, then solve two triangular systems. Compressed sparse storage makes the reduced storage useful. General LU decomposition may also need numerical partial pivoting, so an ordering chosen for sparsity can change during factorization.[ref]
Lecture 27: Sparse Gaussian Elimination. Applications of Parallel Computers, CS267, Spring 1996; CS267, Lecture 27, 23 April 1996, Cholesky versus LU Decomposition: distinction between numerical pivot selection and advance ordering, and phases 1–4; Sparse Matrix Storage Schemes
For a fixed ordering, let be the permutation matrix that puts the unknowns in that order. Permute both rows and columns:Here is the lower triangular matrix in the Cholesky decomposition of ; . Forward substitution and back substitution give the original solution. The simultaneous permutation preserves the symmetric positive-definite matrix property because for every nonzero vector . A row permutation alone generally loses the symmetric matrix structure.
The local mechanism is a Schur complement. If the active pivot element is , then for remaining indices ,Even when , two nonzero couplings through make the second term nonzero. Thus the elimination graph removes and joins its remaining neighbors into a clique. The fill-path criterion for symmetric elimination extends this local rule across several steps. The elimination tree organizes the resulting dependencies; the minimum degree algorithm and nested dissection choose orderings to control them.
This connection between graphs and linear systems was already explicit in Donald J. Rose, R. Endre Tarjan and George S. Lueker's 1976 study of fill-in and perfect elimination orderings.[ref]
Algorithmic Aspects of Vertex Elimination on Graphs by Donald J. Rose and others. Abstract: symmetric positive-definite systems, fill calculation for a prescribed ordering, and algorithms for special orderings; publication information, June 1976
Tiny-pivot roundoff in Gaussian elimination 2026-10-18
A nonzero pivot element can still be a poor numerical choice. Partial pivoting bounds the absolute values of the elimination multipliers by one in exact arithmetic, because each numerator is no larger than the selected denominator. This usually improves numerical stability, but does not prevent every possible growth of intermediate entries or guarantee accurate answers for every linear system.[ref]
2.6 Row pivoting. Fundamentals of Numerical Computation by Tobin A. Driscoll and others; §2.6.4, Example 2.6.6, equation (2.6.3) and concluding discussion: small-pivot instability and the limits of pivoting
To see the mechanism without depending on hardware, define a toy floating-point arithmetic model. The operator rounds an exact real number to the nearest value with three significant decimal digits; halfway cases choose the even final digit, and . Allow an unbounded exponent range. Round the inputs and the result of every addition, subtraction, multiplication and division separately; a product followed by a subtraction rounds twice. This is a prescribed arithmetic model, not a measurement of a physical computer. All inputs in the following original example are represented exactly:Without a row interchange, the elimination multiplier is . The last coefficient and right-hand side becomeTwo distinct exact values now have the same rounded representation. Back substitution therefore returnsThe small difference carrying information about was lost during elimination; the final subtraction only exposes that loss. Dividing by the tiny pivot element amplifies sensitivity to the lost information.
With partial pivoting, interchange the two rows, including their right-hand sides, to start from . Now , and the rounded updates areBack substitution gives and . Both paths round intermediate values, but only the first creates million-sized entries and then divides a lost difference by .
The true solution follows from the original second equation :Evaluate the linear-system residual against the original data in exact arithmetic, separately from the three-digit solve. With , the maximum norm, the results areThe respective relative linear-system residuals are and . Computing the diagnostic in higher precision matters: a check made only against the rounded reduced equations would miss the original error.
The same three-digit floating-point arithmetic model gives without a row interchange and with partial pivoting; exact linear-system residuals expose the difference
. Details. This matrix is well conditioned in the maximum norm: its induced matrix norm is , whileThe failure therefore belongs to this unpivoted algorithm, rather than a large condition number. In general, however, partial pivoting cannot remove sensitivity inherent in the data. For any approximate solution of an invertible matrix system, ; the induced matrix norm inequality and giveA small linear-system residual controls solution error only in conjunction with the condition number; numerical stability and sensitivity are different questions.[ref]



