Solution (source code)

= Solution

The <Poisson summation formula> for the Gaussian gives the transformations of the <Jacobi theta function>
$$
\theta(\tau+2)=\theta(\tau),
\qquad
\theta(-1/\tau)=(-i\tau)^{1/2}\theta(\tau),
$$
where the square root is the holomorphic branch on $\mathfrak h$. Raising to the $k$th power gives invariance under $T^2$. If $k=8m$, then
$$
(-i\tau)^{k/2}=(-i)^{4m}\tau^{k/2}=\tau^{k/2},
$$
so $\theta^k(-1/\tau)=\tau^{k/2}\theta^k(\tau)$. Since $T^2$ and $S$ generate the <theta group>, this is the weight-$k/2$ transformation law on $\Gamma$.

The defining series converges locally uniformly, so $\theta^k$ is holomorphic on $\mathfrak h$, and its expansion at infinity has no negative powers of $e^{\pi i\tau}$. Applying Poisson summation to the shifted Gaussian $e^{-\pi t(n+1/2)^2}$ gives the corresponding nonnegative-power expansion at the remaining cusp. Hence $\theta^k$ is holomorphic at every cusp and is a modular form of weight $k/2$ and level $\Gamma$.