  We compute the exact thermal partition functions of a massive scalar field on
flat spacetime backgrounds of the form $\mathbb R^{d-q}\times \mathbb T^{q+1}$
and show that they possess an ${\rm SL}(q+1,\mathbb Z)$ symmetry. Non-trivial
relations between equivalent expressions for the result are obtained by doing
the computation using functional, canonical and worldline methods. For $q=1$,
the results exhibit modular symmetry and may be expressed in terms of massive
Maass-Jacobi forms. In the complex case with chemical potential for ${\rm
U}(1)$ charge turned on, the usual discussion of relativistic Bose-Einstein
condensation is modified by the presence of the small dimensions.
