Solution (source code)

= Solution

An <even Dirichlet character> satisfies $\chi(-1)=1$, while an <odd Dirichlet character> satisfies $\chi(-1)=-1$. Write $a=0$ or $1$ for its <character parity> and, for $x>0$, define the <Dirichlet character theta function>
$$
\theta_\chi(x)=\sum_{n\in\mathbb Z}n^a\chi(n)e^{-\pi n^2x/q}.
$$
For a <primitive Dirichlet character> whose <conductor of a Dirichlet character> is $q>1$, the term at zero is zero. Put $\tau(\chi)=\sum_{r\bmod q}\chi(r)e(r/q)$, using the positive exponential, and $\varepsilon_\chi=\tau(\chi)/(i^a\sqrt q)$. The primitive <Gauss sum of a Dirichlet character> has magnitude $\sqrt q$, so $|\varepsilon_\chi|=1$. The theta transformation is
$$
\boxed{\theta_\chi(x)=\varepsilon_\chi x^{-a-1/2}\theta_{\overline\chi}(1/x).}
$$
Thus the powers are $x^{-1/2}$ in the even case and $x^{-3/2}$ in the odd case; the odd root number contains $1/i$. The conjugate character is necessary for a nonreal character. These formulas also follow by applying <Poisson summation> to the <Gaussian function> on each <residue class>, and to its derivative for odd parity. For the primitive <principal Dirichlet character> whose <conductor of a Dirichlet character> is one, use the ordinary <Jacobi theta function> with constant term one; its transformation has root number one.