Triangular solves for LU decomposition 2026-10-14
Given Pivoted LU decomposition , the linear system is equivalent to . Introduce the intermediate vector : first use forward substitution to solve , then back substitution to solve . With unpivoted LU decomposition, is the identity matrix, so the first right-hand side is simply .[ref]
For the factors in Computed three-by-three LU decomposition and , forward substitution givesThen back substitution givesDirect matrix multiplication verifies . More generally, the back substitution recurrence isThe direction matters: the last row contains only , whereas the first row generally involves every unknown. No dense matrix inverse is needed for either triangular solve.
Tridiagonal elimination recurrences 2026-10-14
Let . Store the tridiagonal matrix by its diagonal , lower diagonal , and upper diagonal . The linear system iswith the nonexistent endpoint terms omitted. Initialize and . For , compute the elimination multiplier, modified pivot element, and modified right-hand side:These recurrence relations apply the elementary row operation after the preceding row has already been reduced. The transformed linear system is an upper bidiagonal matrix:Thus back substitution is especially short:For , only remains. Check each pivot element before its first division, including before back substitution.
Tridiagonal elimination preserves the narrow band: only one row and one diagonal coefficient change per step
. Details. Equivalently, this constructs an LU decomposition with unit lower bidiagonal matrix , whose lower diagonal is , and upper bidiagonal matrix , whose diagonal is and upper diagonal is . The sweep is forward substitution in . There is no fill-in outside these bands when no rows are interchanged. LAPACK's
DGTSV source uses these same coefficient and right-hand-side updates in its branch without row interchange.[ref] Tridiagonal matrix algorithm 2026-10-14
The Thomas algorithm is Gaussian elimination specialized to a tridiagonal matrix: each row couples an unknown only to its immediate neighbours. Eliminating one unknown changes just the next diagonal entry and right-hand side. Provided all pivot elements are nonzero, a forward sweep followed by back substitution solves an -unknown linear system in time and storage, using Big O notation. Treating the same entries as a full matrix wastes the zeros: classical dense LU factorization and solve costs grow cubically for factorization and quadratically for storage.
A concrete reason to care is the Dirichlet Poisson solution by tridiagonal elimination: a three-point finite difference for the second derivative couples adjacent points on a mesh, producing precisely this tridiagonal matrix. The same structure occurs in one-dimensional Crank-Nicolson method calculations. NPTEL's archived Lecture 13 introduces the Thomas algorithm from that time-stepping problem and labels the procedure “Thomas algorithm (1949)”.[ref]
Thomas algorithm (NPTEL Lecture 13). Lecture 13, Thomas algorithm: opening historical attribution and Crank Nicolson motivation
Tridiagonal solve costs 2026-10-14
For the displayed unpivoted Thomas algorithm with one right-hand side, count each scalar addition, subtraction, multiplication or division as one arithmetic operation. Forming takes five arithmetic operations per forward step. The last unknown takes one division; each remaining back substitution step takes three arithmetic operations. ThusThis is an operation-count model, excluding assignments, indexing, pivot checks and any special simplifications of the coefficients. It is not a timing benchmark. The original tridiagonal matrix needs scalar entries, and its right-hand side another . Overwriting with and with , then with , keeps storage ; the arrays, rather than the few loop temporaries, determine the total space complexity.
For repeated right-hand sides, retain the LU decomposition: computing once costs arithmetic operations, and each subsequent pair of forward substitution and back substitution sweeps costs . Hence right-hand sides cost arithmetic operations. This is the banded counterpart of Reusing LU factors for multiple right-hand sides.
An invertible matrix need not admit the unpivoted Thomas algorithm. For example,Here and , but makes undefined. Interchanging the two equations instead gives the upper triangular matrix system , , solved immediately by back substitution. Even a nonzero first diagonal does not guarantee all later pivot elements: has determinant , yet .
For a general tridiagonal matrix, use a solver with partial pivoting when these structural guarantees are unavailable or a dangerously small pivot element occurs. Adjacent row interchanges can introduce a second upper diagonal, so a pivoted solver must track that additional fill-in; it cannot blindly continue the unpivoted recurrence relations. LAPACK's
DGTSV explicitly performs partial pivoting, stores this extra upper diagonal, and includes it in back substitution. Its fixed-width storage and bounded work per row retain time for one right-hand side and storage.[ref]DGTSV (LAPACK 3.12.1) by LAPACK project. DGTSV, Purpose lines 34–39; DL argument lines 63–69; adjacent interchange lines 188–199; back solve lines 295–305
