Solution (source code)

= Solution

For a bulk bond, $K_{n+1}=K_n(1-2n_n)$ and $c_n(1-2n_n)=-c_n$. Reordering the remaining different-site operators then gives
$$
S_n^+S_{n+1}^-=c_{n+1}^\dagger c_n,\qquad
S_n^-S_{n+1}^+=c_n^\dagger c_{n+1}\quad(n<N).
$$
The periodic <spin> <boundary condition> requires separate attention. Set $P=\prod_{n=1}^N(1-2n_n)=(-1)^{N_f}$. The end bond becomes $S_N^+S_1^-=-P c_1^\dagger c_N$, with the conjugate relation for its adjoint. Consequently the exact finite-ring <Hamiltonian> is
$$
\boxed{H=-\frac{hN}{2}+h\sum_{n=1}^Nn_n
-\frac J2\sum_{n=1}^{N-1}(c_n^\dagger c_{n+1}+c_{n+1}^\dagger c_n)
+\frac{JP}{2}(c_N^\dagger c_1+c_1^\dagger c_N).}
$$
<fermion parity> is conserved, so diagonalize in a sector $P=\pm1$. There the end bond can be written like every other bond provided $c_{N+1}=-Pc_1$. This <parity-dependent boundary condition of the Jordan-Wigner chain> is \b[antiperiodic for even <fermion> number and periodic for odd <fermion> number]. Simply assuming periodic <fermions> in both sectors changes the finite-size spectrum.