I'm trying to write a matlab code that gets a diagonal dominant matrix $A$, vector $b$, and finds an approximate solution $x$ to $Ax=b$ using Gauss-Seidel Method.
I understand the theory.
Suppose $L$ is the lower part of $A$ (diagonal included) and $U$ is strictly the upper part of $A$ (diagonal not included.). It is clear that $A=L+U$
Now, since $Ax=(L+U)x=b$, we can see that $Lx=b-Ux$, and if we multiply by $L^{-1}$:
$x^{(k+1)}=L^{-1}(b-Ux^{(k)})$ for some initial guess $x^{(0)}$.
Now here is the problem...
If at all possible, I rather avoid calculating an inverse matrix like the plague. It completely defeats the point. If I could calculate inverse matrices, I would just calculate $A^{-1}$. Is there a way to use the fact that $L$ is lower triangular to calculate the inverse quickly? Is there some short cut?
Yes: Don't calculate $L^{-1}$. At each step, use forward-substitution to solve $Lx^{k+1} = b -Ux^{k}$ for $x^{k+1}$.