Algorithm Search⌘K

Proofs: Determinant by Kraut's method (LU decomposition)

These are the human proofs of Determinant by Kraut's method (LU decomposition), at full length.

Crout's method returns the determinant full

This proof shows: correctness, termination.

Let A0A_0 be the input, an n×nn \times n matrix over a field KK, and let AA be the working matrix. Indices start at 00, as in the pseudocode. Line L6 swaps whole rows of AA; let A′A' be A0A_0 with the same swaps applied, so that A′A' is the input with its rows in the current order. The working matrix stores two triangular matrices. For k≤ik \le i, L[i,k]L[i, k] means A[i,k]A[i, k] after line L3 of iteration kk has written it. For k<tk < t, U[k,t]U[k, t] means A[k,t]A[k, t] after line L7 of iteration kk has written it, and U[k,k]=1U[k, k] = 1.

Claim. KRAUT-DET(A0)(A_0) stops and returns det⁡A0\det A_0. If it does not return on line L5, then A′=LUA' = LU with LL lower triangular and UU unit upper triangular.

Termination. Line L2 runs jj over nn values, and every inner loop and every sum on lines L3 and L7 has at most nn terms.

Which entries hold what. An entry A[i,j]A[i, j] with i≥ji \ge j is written only by line L3 in iteration jj, and an entry A[j,t]A[j, t] with t>jt > j only by line L7 in iteration jj. Line L6 moves whole rows. So at the start of iteration jj, the entries A[i,j]A[i, j] for i≥ji \ge j and A[j,t]A[j, t] for t>jt > j still hold the entries of A′A', and the entries read in the sums are L[i,k]L[i, k] and U[k,t]U[k, t] with k<jk < j, which are already final.

Invariant. At the start of iteration jj, let L1=L[0..j−1,0..j−1]L_1 = L[0..j-1, 0..j-1], L2=L[j..n−1,0..j−1]L_2 = L[j..n-1, 0..j-1], U1=U[0..j−1,0..j−1]U_1 = U[0..j-1, 0..j-1] and U2=U[0..j−1,j..n−1]U_2 = U[0..j-1, j..n-1], and let SS be the (n−j)×(n−j)(n-j) \times (n-j) matrix with entries

S[i,t]=A′[i,t]−∑k<jL[i,k] U[k,t](j≤i,t≤n−1).S[i, t] = A'[i, t] - \sum_{k<j} L[i, k]\, U[k, t] \qquad (j \le i, t \le n - 1).

Then:

  • (K1) A′=(L10L2I)(U1U20S)A' = \begin{pmatrix} L_1 & 0 \\ L_2 & I \end{pmatrix} \begin{pmatrix} U_1 & U_2 \\ 0 & S \end{pmatrix}, where L1L_1 is lower triangular and U1U_1 is unit upper triangular.
  • (K2) det⁡A0=s⋅det⁡A′=s⋅∏k<jL[k,k]⋅det⁡S\det A_0 = s \cdot \det A' = s \cdot \prod_{k<j} L[k, k] \cdot \det S.

Initialization. For j=0j = 0 the blocks L1,L2,U1,U2L_1, L_2, U_1, U_2 are empty, S=A′=A0S = A' = A_0 and s=1s = 1, so both parts hold.

Maintenance. Assume the invariant at the start of iteration jj. Line L3 computes A[i,j]=S[i,j]A[i, j] = S[i, j] for i≥ji \ge j, the first column of SS.

If lines L4 and L5 find no nonzero entry, the first column of SS is zero, so det⁡S=0\det S = 0, and by (K2) det⁡A0=0\det A_0 = 0. Line L5 returns 00, which is correct.

Otherwise line L6 may swap rows jj and p≥jp \ge j of AA. These rows lie below the blocks L1L_1 and U1U_1, so the swap exchanges two rows of A′A', of L2L_2 and of SS at the same time, and (K1) holds for the new A′A'. The swap negates det⁡A′\det A' and det⁡S\det S, and line L6 negates ss, so (K2) holds. Now L[j,j]=S[j,j]≠0L[j, j] = S[j, j] \ne 0 (we index SS by j,…,n−1j, \dots, n-1).

Line L7 computes, for t>jt > j, U[j,t]=S[j,t]/S[j,j]U[j, t] = S[j, t] / S[j, j]. Put U[j,j]=1U[j, j] = 1. The new LL column is L[i,j]=S[i,j]L[i, j] = S[i, j] for i≥ji \ge j. Let S′S' be the matrix on the indices j+1,…,n−1j + 1, \dots, n - 1 with S′[i,t]=S[i,t]−L[i,j] U[j,t]S'[i, t] = S[i, t] - L[i, j]\, U[j, t]; this is the SS of iteration j+1j + 1, because its defining sum gains the term k=jk = j. Then

S=(10cI)(S[j,j]r0S′),ci=L[i,j]/S[j,j],rt=S[j,t],S = \begin{pmatrix} 1 & 0 \\ c & I \end{pmatrix} \begin{pmatrix} S[j, j] & r \\ 0 & S' \end{pmatrix}, \qquad c_i = L[i, j] / S[j, j], \quad r_t = S[j, t],

which one checks entry by entry: row jj gives S[j,j]S[j, j] and S[j,t]S[j, t], column jj gives ciS[j,j]=S[i,j]c_i S[j, j] = S[i, j], and the other entries give cirt+S′[i,t]=L[i,j]U[j,t]+S′[i,t]=S[i,t]c_i r_t + S'[i, t] = L[i, j] U[j, t] + S'[i, t] = S[i, t]. Substituting this into (K1), and moving the column (S[j,j],c S[j,j])T=L[j..n−1,j](S[j, j], c\, S[j, j])^T = L[j..n-1, j] into LL and the row (1,r/S[j,j])=U[j,j..n−1](1, r / S[j, j]) = U[j, j..n-1] into UU, gives (K1) for j+1j + 1, with L1L_1 still lower triangular and U1U_1 unit upper triangular. Taking determinants, det⁡S=S[j,j]⋅det⁡S′=L[j,j]det⁡S′\det S = S[j, j] \cdot \det S' = L[j, j] \det S', so (K2) holds for j+1j + 1.

End. If the algorithm does not return on line L5, the loop ends with j=nj = n. Then SS is empty with determinant 11, (K1) says A′=LUA' = LU, and (K2) says det⁡A0=s∏k<nL[k,k]\det A_0 = s \prod_{k<n} L[k, k]. Lines L8 to L10 compute exactly this product. ■\blacksquare

Remark. The proof shows that L[j,j]L[j, j] equals the pivot of step jj of Gaussian elimination with the same row swaps, and that every partial sum on line L3 is an entry of an intermediate matrix of Gaussian elimination. So the numbers that Crout's method stores and computes over Q\mathbb{Q} are quotients of minors of the input, as in Gaussian elimination.

Back to Determinant by Kraut's method (LU decomposition)