Algorithm Search⌘K

Proofs: LUP decomposition

These are the human proofs of LUP decomposition, at full length.

LUP-DECOMPOSITION computes PA = LU with bounded multipliers, and reports SINGULAR exactly for singular A full

This proof shows: correctness, termination.

We work in exact arithmetic first. AA is a real n×nn \times n matrix, eke_k is the kk-th unit vector, and for a permutation π\pi we write PπP_\pi for the matrix with (PπA)k,:=Aπk,:(P_\pi A)_{k,:} = A_{\pi_k,:}. The algorithm stops: line L2 runs at most nn times, and each inner loop has a fixed length.

State after pass kk. Let MM be the array after pass kk (for k=0k = 0, the input AA) and π\pi the current permutation. Define

  • L(k)L^{(k)}: the unit lower triangular matrix with Lij(k)=MijL^{(k)}_{ij} = M_{ij} for j<ij < i and j≤kj \le k, and Lij(k)=0L^{(k)}_{ij} = 0 for j<ij < i and j>kj > k;
  • S(k)S^{(k)}: the matrix with Sij(k)=MijS^{(k)}_{ij} = M_{ij} when i≤ki \le k and j≥ij \ge i, or when i>ki > k and j>kj > k, and Sij(k)=0S^{(k)}_{ij} = 0 otherwise.

So S(k)=(U11U120C)S^{(k)} = \begin{pmatrix} U_{11} & U_{12} \\ 0 & C \end{pmatrix}, where U11U_{11} is k×kk \times k upper triangular and CC is the (n−k)×(n−k)(n - k) \times (n - k) trailing block of MM.

Invariant (I). After pass kk (when line L4 has not returned): PπA=L(k)S(k)P_\pi A = L^{(k)} S^{(k)}, each multiplier satisfies ∣Lij(k)∣≤1|L^{(k)}_{ij}| \le 1, and the diagonal entries u11,…,ukku_{11}, \ldots, u_{kk} of U11U_{11} are nonzero.

Initialization. For k=0k = 0, π\pi is the identity, L(0)=IL^{(0)} = I, S(0)=AS^{(0)} = A, and there are no multipliers or pivots. So (I) holds.

Maintenance. Assume (I) after pass k−1k - 1, with L=L(k−1)L = L^{(k-1)}, S=S(k−1)S = S^{(k-1)} and trailing block CC (rows and columns kk to nn). Pass kk does three things.

  1. The swap (line L5). Let Π\Pi be the permutation matrix that exchanges rows kk and pp, where k≤pk \le p. The new permutation π′\pi' has Pπ′=ΠPπP_{\pi'} = \Pi P_\pi. Then
ΠPπA=(ΠLΠ)(ΠS),\Pi P_\pi A = (\Pi L \Pi)(\Pi S),

because ΠΠ=I\Pi \Pi = I. The matrix ΠLΠ\Pi L \Pi is LL with rows kk and pp exchanged and then columns kk and pp exchanged. Columns kk to nn of LL are those of the identity, so the column exchange undoes the row exchange on them, and ΠLΠ\Pi L \Pi is again unit lower triangular: it is LL with the multipliers in columns 11 to k−1k - 1 of rows kk and pp exchanged. This is exactly what line L5 does to the stored multipliers, because it exchanges whole rows. The matrix ΠS\Pi S is SS with rows kk and pp exchanged; both rows have zeros in columns 11 to k−1k - 1, so ΠS\Pi S has the same shape, with trailing block C′C' equal to CC with two rows exchanged, and this is what line L5 does to the trailing block. So after line L5, Pπ′A=LSP_{\pi'} A = L S holds with the array updated in the same way.

  1. The pivot. We show that if line L4 does not return, the pivot c=Mkkc = M_{kk} after the swap is nonzero, and that ∣Mik∣≤∣c∣|M_{ik}| \le |c| for i>ki > k. Line L3 picks pp with ∣Mpk∣|M_{pk}| maximal over i≥ki \ge k, so after the swap ∣Mkk∣≥∣Mik∣|M_{kk}| \ge |M_{ik}| for each i>ki > k. Line L4 returns when this maximum is 00; if it does not return, c≠0c \ne 0.

  2. The elimination (lines L6 to L9). Write the trailing block after the swap as C′=(cwTvB)C' = \begin{pmatrix} c & w^T \\ v & B \end{pmatrix} with c≠0c \ne 0. Lines L7 set l=v/cl = v / c in column kk below the pivot, and lines L8 and L9 replace BB by B−lwTB - l w^T. Now

C′=(10lI)(cwT0B−lwT),C' = \begin{pmatrix} 1 & 0 \\ l & I \end{pmatrix} \begin{pmatrix} c & w^T \\ 0 & B - l w^T \end{pmatrix},

as one checks block by block: the (2,1)(2,1) block is lc=vl c = v, and the (2,2)(2,2) block is lwT+B−lwT=Bl w^T + B - l w^T = B. Embedding this identity in rows and columns kk to nn gives LS=L(k)S(k)L S = L^{(k)} S^{(k)} for the new array, because the first factor puts ll into column kk of the unit lower triangular factor (columns kk to nn of LL were the identity) and the second factor is the new S(k)S^{(k)}. By step 2, ∣li∣=∣vi∣/∣c∣≤1|l_i| = |v_i|/|c| \le 1, and the new pivot ukk=cu_{kk} = c is nonzero. So (I) holds after pass kk.

Termination with success. If line L4 never returns, then after pass nn the trailing block is empty, S(n)=US^{(n)} = U is upper triangular with nonzero diagonal, L(n)=LL^{(n)} = L, and (I) gives PπA=LUP_\pi A = L U with ∣lij∣≤1|l_{ij}| \le 1. Line L10 returns this result.

SINGULAR is reported exactly for singular AA. By (I) after pass k−1k - 1, det⁡(PπA)=det⁡L⋅det⁡S=±det⁡A\det(P_\pi A) = \det L \cdot \det S = \pm \det A, and det⁡L=1\det L = 1, det⁡S=u11⋯uk−1,k−1⋅det⁡C\det S = u_{11} \cdots u_{k-1,k-1} \cdot \det C, where the uiiu_{ii} are nonzero. So det⁡C≠0\det C \ne 0 if and only if det⁡A≠0\det A \ne 0. If AA is nonsingular, CC is nonsingular, so its first column is not zero, and line L4 does not return at pass kk; by induction on kk, it never returns. If line L4 returns at pass kk, the first column of CC is zero, so det⁡C=0\det C = 0 and AA is singular. If AA is singular, the algorithm cannot reach line L10, because then det⁡A=±∏uii≠0\det A = \pm \prod u_{ii} \ne 0; so line L4 returns at some pass. ■\blacksquare

Floating point

Assume the standard model fl(a∘b)=(a∘b)(1+δ)\mathrm{fl}(a \circ b) = (a \circ b)(1 + \delta), ∣δ∣≤u|\delta| \le u, and nu<1n u < 1. Swaps and comparisons are exact. So the computed result is the result of elimination without pivoting applied to the matrix PAP A, where PP is the permutation that the computation chose. Entry (i,j)(i, j) of PAP A is processed by the recurrence aij(k+1)=aij(k)−likukja^{(k+1)}_{ij} = a^{(k)}_{ij} - l_{ik} u_{kj} for k<min⁡(i,j)k < \min(i, j), and then by uij=aij(i)u_{ij} = a^{(i)}_{ij} for i≤ji \le j or lij=aij(j)/ujjl_{ij} = a^{(j)}_{ij} / u_{jj} for i>ji > j. This is the evaluation of s=(a−∑k=1mlkuk)s = (a - \sum_{k=1}^{m} l_k u_k), followed by a division in the second case, with m=min⁡(i,j)−1m = \min(i, j) - 1. By the standard bound for such an expression (Higham, Lemma 8.4), for i≤ji \le j

∣(PA)ij−∑k=1il^iku^kj∣≤γi∑k=1i∣l^ik∣ ∣u^kj∣,l^ii=1,\Bigl| (P A)_{ij} - \sum_{k=1}^{i} \hat l_{ik} \hat u_{kj} \Bigr| \le \gamma_{i} \sum_{k=1}^{i} |\hat l_{ik}|\,|\hat u_{kj}|, \qquad \hat l_{ii} = 1,

and for i>ji > j the same bound holds with γj\gamma_j and the sum to jj. Since γm≤γn\gamma_m \le \gamma_n for m≤nm \le n, this is L^U^=PA+ΔA\hat L \hat U = P A + \Delta A with ∣ΔA∣≤γn∣L^∣ ∣U^∣|\Delta A| \le \gamma_n |\hat L|\,|\hat U| (Higham, Theorem 9.3). The pivot rule makes ∣l^ij∣≤1|\hat l_{ij}| \le 1 exactly, because fl(v/c)\mathrm{fl}(v/c) with ∣v∣≤∣c∣|v| \le |c| is at most 11 in modulus under rounding to nearest. The ∞\infty-norm bound ∥ΔA∥∞≤n2γnρn∥A∥∞\|\Delta A\|_\infty \le n^2 \gamma_n \rho_n \|A\|_\infty on the page follows from ∥ ∣L^∣ ∥∞≤n\|\,|\hat L|\,\|_\infty \le n and ∣u^ij∣≤ρnmax⁡∣aij∣|\hat u_{ij}| \le \rho_n \max |a_{ij}|.

Back to LUP decomposition