  We consider the $2+1$ dimensional Yang-Mills theory with gauge group
$\text{SU}(N)$ on a flat 2-torus under twisted boundary conditions. We study
the possibility of phase transitions (tachyonic instabilities) when $N$ and the
volume vary and certain chromomagnetic flux associated to the topology of the
bundle can be adjusted. Under natural assumptions about how to match the
perturbative regime and the expected confinement, we prove that the absence of
tachyonic instabilities is related to some problems in number theory, namely
the Diophantine approximation of irreducible fractions by other fractions of
smaller denominator.
