Path integral XY model I am given the Hamiltonian for the XY model of spins
$$H[\theta] = \frac{K}{2} \int |\nabla \theta|^2dxdy,$$
where $K = J/k_B T$ with $J$ the interaction energy between neighbouring spins. 
I calculated that $\beta H[\theta] = \frac{K}{2L^2} \sum_{\mathbf{q}} \theta_{\mathbf{q}}\theta_{-\mathbf{q}} \mathbf{q}^2$, where $\theta_{-\mathbf{q}} = \theta_{\mathbf{q}}^\star$ since $\theta$ is a real function.
From this I have to calculate $\langle e^{i \theta(\mathbf{0})} \rangle$.
For this I used the partition function
$$Z = \prod_{\mathbf{q}} \int d\theta_{\mathbf{q}} e^{-\frac{K}{2L^2} \mathbf{q}^2 |\theta_{\mathbf{q}}|^2} = \prod_{\mathbf{q}}\sqrt{\frac{2\pi L^2}{K\mathbf{q}^2}}.$$ 
And similarly,
$$\prod_{\mathbf{q}} \int d\theta_{\mathbf{q}} e^{-\frac{K}{2L^2}|\theta_{\mathbf{q}}|^2 \mathbf{q}^2 + iL^{-2} \theta_{\mathbf{q}}} = \prod_{\mathbf{q}} \sqrt{\frac{2\pi L^2}{K\mathbf{q}^2}} e^{-\frac{1}{2L^2}\frac{1}{K\mathbf{q}^2}} ,$$
where $\theta(\mathbf{0}) = \frac{1}{L^2} \sum_{\mathbf{q}} \theta_{\mathbf{q}}$ has been used. Therefore we find
$$\langle e^{i \theta(\mathbf{0})} \rangle = \exp \Big(-\frac{1}{2KL^2} \sum_{\mathbf{q}} \mathbf{q}^{-2}\Big).$$ 
This is exactly the result I had to prove, however I do not understand why I can evaluate the integrals in the way I did. For example in the first integral we just pretend as if $\theta_{\mathbf{q}}$ is real and $|\theta_{\mathbf{q}}|^2$ is just $\theta_{\mathbf{q}}^2$. Why can we do such things?
 A: Due to the relation $\theta_{-\mathbf{q}} = \theta_{\mathbf{q}}^{\ast}$, one needs to be careful about integrating over distinct degrees of freedom. One possible choice is to restrict to $q_i > 0$ for one of the components of $\mathbf{q}$, and then to integrate over both real and imaginary parts of $\theta_{\mathbf{q}}$.
Then you can write
$$
\theta(\mathbf{x} = 0) = \frac{1}{L} \sum_{\mathbf{q}} \theta_{\mathbf{q}} = \frac{1}{L} \sum_{q_i>0} \left( \theta_{\mathbf{q}} + \theta^{\ast}_{\mathbf{q}} \right) = \frac{2}{L} \sum_{q_i>0} \mathrm{Re}[\theta_{\mathbf{q}}],
$$
Similarly, you can write $|\theta_{\mathbf{q}}|^2 = \mathrm{Re}[\theta_{\mathbf{q}}]^2 + \mathrm{Im}[\theta_{\mathbf{q}}]^2$. So for your case, the partition function reads
$$
Z = \prod_{q_i > 0} \int d\theta_{\mathbf{q}} e^{-\frac{K}{L^2} \mathbf{q}^2 \left[ \mathrm{Re}[\theta_{\mathbf{q}}]^2 + \mathrm{Im}[\theta_{\mathbf{q}}]^2 \right]},
$$
while the numerator of the correlation function can be written
$$
\prod_{q_i > 0} \int d\theta_{\mathbf{q}} e^{-\frac{K}{L^2}\left[ \mathrm{Re}[\theta_{\mathbf{q}}]^2 + \mathrm{Im}[\theta_{\mathbf{q}}]^2 \right] \mathbf{q}^2 + 2iL^{-2} \mathrm{Re}[\theta_{\mathbf{q}}]}. 
$$
So the integration measure is really over all real and imaginary parts of $\theta_{\mathbf{q}}$, that is, $d\mathrm{Re}[\theta_{\mathbf{q}}]d\mathrm{Im}[\theta_{\mathbf{q}}]$. If you do this integral, you'll find
$$
\langle e^{i \theta(\mathbf{0})} \rangle = \exp \Big(-\frac{1}{KL^2} \sum_{q_i > 0} \mathbf{q}^{-2}\Big) = \exp \Big(-\frac{1}{2KL^2} \sum_{\mathbf{q}} \mathbf{q}^{-2}\Big).
$$
Why did your calculation work out when you just assumed $\theta_{\mathbf{q}}$ was real? Because the integration over the imaginary part of $\theta_{\mathbf{q}}$ just factored out of the above integrals, so it canceled out in the ratio. But I claim that your partition function is actually wrong (there should not be a 2 inside the square root).
