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 be the input, an matrix over a field , and let be the working matrix. Indices start at , as in the pseudocode. Line L6 swaps whole rows of ; let be with the same swaps applied, so that is the input with its rows in the current order. The working matrix stores two triangular matrices. For , means after line L3 of iteration has written it. For , means after line L7 of iteration has written it, and .
Claim. KRAUT-DET stops and returns . If it does not return on line L5, then with lower triangular and unit upper triangular.
Termination. Line L2 runs over values, and every inner loop and every sum on lines L3 and L7 has at most terms.
Which entries hold what. An entry with is written only by line L3 in iteration , and an entry with only by line L7 in iteration . Line L6 moves whole rows. So at the start of iteration , the entries for and for still hold the entries of , and the entries read in the sums are and with , which are already final.
Invariant. At the start of iteration , let , , and , and let be the matrix with entries
Then:
- (K1) , where is lower triangular and is unit upper triangular.
- (K2) .
Initialization. For the blocks are empty, and , so both parts hold.
Maintenance. Assume the invariant at the start of iteration . Line L3 computes for , the first column of .
If lines L4 and L5 find no nonzero entry, the first column of is zero, so , and by (K2) . Line L5 returns , which is correct.
Otherwise line L6 may swap rows and of . These rows lie below the blocks and , so the swap exchanges two rows of , of and of at the same time, and (K1) holds for the new . The swap negates and , and line L6 negates , so (K2) holds. Now (we index by ).
Line L7 computes, for , . Put . The new column is for . Let be the matrix on the indices with ; this is the of iteration , because its defining sum gains the term . Then
which one checks entry by entry: row gives and , column gives , and the other entries give . Substituting this into (K1), and moving the column into and the row into , gives (K1) for , with still lower triangular and unit upper triangular. Taking determinants, , so (K2) holds for .
End. If the algorithm does not return on line L5, the loop ends with . Then is empty with determinant , (K1) says , and (K2) says . Lines L8 to L10 compute exactly this product.
Remark. The proof shows that equals the pivot of step 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 are quotients of minors of the input, as in Gaussian elimination.