You can solve a linear system one step at time by using the LU Method.
As in the previous section, the following Matrix and Vector represent a linear system M.x=V where we want to solve for x:
First, do an LU decomposition of M. The output components are P (the permutation Matrix), L (a unit lower triangular Matrix), and U (an upper triangular Matrix).
Since this is a decomposition of M, P.L.U=M. The inverse of a permutation Matrix is always its transpose. To solve the system, M.x=V, start by multiplying both sides by the inverse (transpose) of P.
We now have L.U.x = Transpose(P).V, or L.U.x=V2 for short.
Since L is lower triangular, use ForwardSubstitute to find a Vector V3 such that L.V3 = V2:
Since L.V3=V2 and L.U.x=V2, we need to find a solution vector, x such U.x=V3. Since U is upper triangular, use BackwardSubstitute to do this:
Compute the residual to see how accurate the solution is: