Solution (source code)

= Solution

Write $Q=c^\dagger c+d^\dagger d$ and $P=cd+d^\dagger c^\dagger$. Expanding the <number operators> and restoring the displayed order with the <canonical anticommutation relations> gives
$$
\begin{aligned}
a^\dagger a+b^\dagger b
&=(u^2-v^2)Q+2v^2-2uvP,\\
ab+b^\dagger a^\dagger
&=2uv(Q-1)+(u^2-v^2)P.
\end{aligned}
$$
The minus sign in the first line follows from $c^\dagger d^\dagger+dc=-(cd+d^\dagger c^\dagger)$. Substitution into the <Hamiltonian operator> yields
$$
H=\bigl[\varepsilon(u^2-v^2)+2\Delta uv\bigr]Q
+\bigl[\Delta(u^2-v^2)-2\varepsilon uv\bigr]P
+2\varepsilon v^2-2\Delta uv.
$$
Let $E=\sqrt{\varepsilon^2+\Delta^2}>0$. A convenient real <Bogoliubov transformation> has
$$
\boxed{u=\sqrt{\frac{E+\varepsilon}{2E}},\qquad
v=\sqrt{\frac{E-\varepsilon}{2E}}
=\frac{\Delta}{\sqrt{2E(E+\varepsilon)}}.}
$$
These obey $u^2+v^2=1$, $u^2-v^2=\varepsilon/E$ and $2uv=\Delta/E$. Equivalently $u=\cos\theta$, $v=\sin\theta$ with $0<\theta<\pi/4$ and $\tan(2\theta)=\Delta/\varepsilon$. The coefficient of $P$ vanishes, while the coefficient of $Q$ is $E$. The constant is
$$
2\varepsilon v^2-2\Delta uv
=\varepsilon\left(1-\frac\varepsilon E\right)-\frac{\Delta^2}{E}
=\varepsilon-E.
$$
Thus the diagonalized <two-mode fermion pairing Hamiltonian> is
$$
\boxed{H=E(c^\dagger c+d^\dagger d)+\varepsilon-E,
\qquad \lambda=\sqrt{\varepsilon^2+\Delta^2},\quad
\mu=\varepsilon-\sqrt{\varepsilon^2+\Delta^2}.}
$$
The two transformed <fermionic occupation numbers> independently take values zero or one. The <energy eigenvalues> and their <eigenspace> dimensions are therefore
$$
\boxed{\begin{array}{c|c|c}
n_c+n_d&\text{energy}&\text{degeneracy}\\\hline
0&\varepsilon-E&1\\
1&\varepsilon&2\\
2&\varepsilon+E&1
\end{array}}
$$
The positive <quasiparticle> <energy> $E$ makes the transformed <vacuum state> the unique <ground state>. The constant $\mu$ is essential for the correct <ground-state energy>.

As a separate sign and spectrum check, use the original <fermionic Fock space> basis. Both singly occupied states are <energy eigenstates> with <energy> $\varepsilon$, since the pairing terms annihilate them. In the ordered even-<fermion parity> basis $(|0\rangle,a^\dagger b^\dagger|0\rangle)$,
$$
H_{\mathrm{even}}=
\begin{pmatrix}0&-\Delta\\-\Delta&2\varepsilon\end{pmatrix}.
$$
The off-diagonal signs follow from $b^\dagger a^\dagger=-a^\dagger b^\dagger$ and $ab\,a^\dagger b^\dagger|0\rangle=-|0\rangle$. Its <characteristic polynomial> is $z^2-2\varepsilon z-\Delta^2$, giving the remaining two <eigenvalues> $\varepsilon\pm E$, in agreement with the <Bogoliubov transformation>.