I have a linear system
\begin{align\*}
 \left[\begin{array}{cccc}
 1 & 2 & 1 & -1 \\
 3 & 2 & 4 & 4 \\
 4 & 4 & 3 & 4 \\
 2 & 0 & 1 & 5 \\
 \end{array}\right]
 \left[\begin{array}{c}
 w \\ x \\ y \\z
 \end{array}\right] =
 \left[\begin{array}{c}
 5 \\ 16 \\ 22 \\ 15
 \end{array}\right],
\end{align\*}
whose matrix $\bf{A}$ is not diagonally dominant. What are the iterative methods that can be used to find the solution? I have tried Jacobi method, Gauss-Seidel method and SOR method but nothing works (the output diverges). The answer is ${\bf x}=[16,-6,-2,-3]^T$.



Iterative methods for linear system with non-diagonally dominant matrix
You can see your equation as $f(u)=Au-b$, with $f(u)=0$. You can use some numerical method to solve it. One way is to use the minimization problem
$$\min\_u g(u),\qquad g(u)=\frac{1}{2}\|f(u)\|^2.$$ This gives you the equation $$0=\nabla g(u)=A^T(Au-b)\quad \text{ or } \quad A^TAu=A^Tb$$ which gives you the possible minimizers.


To your matrix $A$ and vector $b$, you can use the [conjugate gradient method](https://en.wikipedia.org/wiki/Conjugate_gradient_method) to solve $$A^TAu=A^Tb,$$ and it [gives you the answer in four steps](https://www.mycompiler.io/view/2OmHyUE6x5m).


If you prefer to play with more steps, you can try [gradient descent method](https://en.wikipedia.org/wiki/Gradient_descent).


You can find more searching for "[\(Au=b\) gradient](https://www.searchonmath.com/result/?q=%5C%28Au%3Db%5C%29%20%20gradient%20) " on SearchOnMath.


**Note:** If you use the gradient descent method to minimize $h(u)=u^TAu-2u^Tb$ directly, you are going in the direction $$\frac{du}{dt}=- \nabla h(u)=-2(Au-b),$$ which is [unstable](https://en.wikipedia.org/wiki/Stability_theory#Non-linear_autonomous_systems), since $A$ has one negative eigenvalue and three positive ones.


