Solution (source code)

= Solution

Choose a <matrix splitting> $A=M-N$ with $M$ invertible. Then $Ax=b$ is equivalent to
$$
x=M^{-1}Nx+M^{-1}b,
$$
and the associated <stationary iterative method for a linear system> is
$$
x^{(k+1)}=Hx^{(k)}+M^{-1}b,
\qquad H=M^{-1}N.
$$
For the <Jacobi method>, write $A=D+L+U$ with $D$ diagonal and $L,U$ strictly lower and upper triangular, and take
$$
M=D,\qquad N=-(L+U).
$$
Thus
$$
\boxed{x^{(k+1)}=-D^{-1}(L+U)x^{(k)}+D^{-1}b.}
$$
The iteration converges for every initial vector exactly when the <spectral radius> of its iteration matrix satisfies
$$
\boxed{\rho\bigl(-D^{-1}(L+U)\bigr)<1.}
$$