Now that you have used the LU solver, it is inevitable that
the "answer" will not be exact, only approximate.
There is a method to refine your answer, based on the backwards
error analysis of the notes.
refine your solution. Assume x is the exact solution of
Ax=b, and you have computed an approximation
. Then
We know the right-hand-side; it is the residual based on the approximate solution. Notice, however, that we need the both the original matrix A and the factored form. That is, to refine, we must keep both A and LU. This done, the procedure is straightforward.
You may need only one or two calls to the refinement code to be comfortably assured that your answer is good.
For homework, use this routine to solve the same NXN tridiagonal system given above. Use the iterative refinement to brush up your solution.