Solution (source code)

= Solution

For an $n\times n$ <matrix> here, $D=I$. The sine vectors $v_j(i)=\sin(ij\pi/(n+1))$ give <eigenvalues>
$$
\lambda_j=1+\frac12\cos\frac{j\pi}{n+1},\quad1\leq j\leq n.
$$
Thus every <eigenvalue> lies strictly between $1/2$ and $3/2$. For $0<\omega\leq4/3$, $0<\omega\lambda_j<2$, so $|1-\omega\lambda_j|<1$, including the upper endpoint $\omega=4/3$. Hence \b[the iteration converges for the entire stated range].

The extreme <eigenvalues> are $1-a$ and $1+a$, with $a=\tfrac12\cos(\pi/(n+1))$. The <spectral radius> is $\max(|1-\omega(1-a)|,|1-\omega(1+a)|)=|1-\omega|+a\omega$ for $\omega>0$. It decreases up to one and increases after one, since $0\leq a<1$. Therefore
$$
\boxed{\omega_{\rm opt}=1,\qquad\rho_{\rm opt}=\frac12\cos\frac{\pi}{n+1}.}
$$
For $n=1$ the same formula gives zero <spectral radius> and exact solution in one ordinary Jacobi step.