Solution (source code)

= Solution

Here $\Delta x=1/M$ and periodic indexing is taken modulo $2M$. The <second-order central difference> matrix is the real symmetric circulant matrix
$$
A=M^2
\begin{pmatrix}
-2&1&0&\cdots&0&1\\
1&-2&1&\ddots&&0\\
0&1&-2&\ddots&\ddots&\vdots\\
\vdots&\ddots&\ddots&\ddots&1&0\\
0&&\ddots&1&-2&1\\
1&0&\cdots&0&1&-2
\end{pmatrix}.
$$
Since $V$ is real diagonal, $H=A-V$ is <Hermitian matrix>[Hermitian]. Therefore $iH$ is <skew-Hermitian matrix>[skew-Hermitian], and
$$
\boxed{\frac d{dt}\|\mathbf u\|_2^2
=\mathbf u^*(iH)\mathbf u+
\mathbf u^*(-iH)\mathbf u=0.}
$$