In this example, if we had replaced the zeros below the main diagonal with the ratio of coefficients at each step, the resulting augmented matrix would be
This gives a LU decomposition as
It should be noted that the product or the matrices produces a permutation of the original matrix, call it , where
The determinant of the original matrix of coefficients can be easily computed according to the formula
which is close to the exact solution: -234. The exponent 2 is required, because there were two row interchanges in solving this system. To summarize
- The solution to the four equations
- The determinant of the coefficient matrix
- A decomposition of the matrix, , which is just the original matrix, , after we have interchanged its rows in the process.
>> A = [0 2 0 1 0 ; 2 2 3 2 -2 ; 4 -3 0 1 -7 ; 6 1 -6 -5 6]
>> [L, U, P]=lu(A)
>> b = [ 0 -2 -7 6]
>> A\b
ans =
-0.5000
1.0000
0.3333
-2.0000