# Evaluate functional integral in partition function of thermal $\phi^4$ theory (Kapusta/Gale p.34-35)

my question is about some steps in the book "Finite Temperature Field Theory" by Kapusta and Gale. To explain the setting, I how to evaluate the functional integrals in the expression $$\ln Z_1=\frac{-\lambda\int d\tau\int d^3 x \int [d\phi]e^{S_0}\phi^4(\bf{x},\tau)}{\int [d\phi]e^{S_0}}$$ where $S_0$ is the non-interacting Lagrangian. $\tau$ is imaginary time. We assume a finite volume V, such that both energies and momenta are quantized, so we can Fourier transform $$\phi(x,\tau)=\sqrt\frac{\beta}{V}\sum_n\sum_{\bf{p}}e^{i(\bf{p} x+\omega_n \tau)}\tilde\phi_n(\bf{p}),$$ where the energies are $\omega_n=2\pi nT$. Using this Fourier series we can reexpress $$\ln Z=-\lambda \int d\tau \int d^3x \sum_{n_1,\ldots,n_4}\sum_{\bf{p}_1,\ldots,\bf{p}_4}\frac{\beta^2}{V^2}e^{i(\bf{p}_1+\ldots+\bf{p}_4)\cdot\bf{x}}e^{i(\omega_{n_1}+\ldots+\omega_{n_4})\tau}\frac{A}{B},$$ where $$A=\prod_l\prod_\bf{q}\int d\tilde{\phi}_l(\bf{q})\;e^{-\frac{1}{2}\beta^2(\omega_l^2+\bf{q}^2+m^2)\tilde\phi_l(\bf{q})\tilde\phi_{-l}(-\bf{q})}\;\tilde\phi_{n_1}(\bf{p}_1)\ldots\tilde\phi_{n_4}(\bf{p}_4),$$ and B is just the same without the four $\tilde\phi$ in the end coming from the $\phi^4$ term. The integrals over $\bf{x}$ and $\tau$ amount to energy-momentum conservation.

Now, using $$\frac{\int_{-\infty}^\infty dx\;x^2 e^{-ax^2/2}}{\int_{-\infty}^\infty dx\; e^{-ax^2/2}}=\frac{1}{a}$$ I am supposed to get $$\ln Z_1=-3\beta V \left(T\sum_n \int\frac{d^3p}{(2\pi)^3}\frac{1}{\omega_n^2+\bf{p}^2+m^2}\right)^2.$$

I understand that the factors in A where $l\not\in\{n_1,\ldots,n_4\}$ and $\bf{q}\not\in\{\bf{p}_1,\ldots,\bf{p}_1\}$ simply cancel with the corresponding ones in B.

Because of $$\int_{-\infty}^{\infty} dx\; xe^{-ax^2}=0,$$ we are supposed zero if not $n_3=-n1$, $\bf{p}_3=-\bf{p}_1$, $n_4=-n2$, $\bf{p}_4=-\bf{p}_2$ or permutations thereof. I don't understand that argument, lets say none of these cases is true, then we get a factor in the integral of the form $$\int d\tilde\phi_{n_1}(\bf{p_1})\;e^{-\frac{1}{2}\beta^2(\omega_l^2+\bf{p}_1^2+m^2)\tilde\phi_{n_1}(\bf{p}_1)\tilde\phi_{-n_1}(-\bf{p}_1)}\;\tilde\phi_{n_1}(\bf{p}_1)$$ I don't see where the quadratic term in the exponential comes from as this is linear in $\phi_{n_1}(\bf{p}_1)$.

I guess this is my general problem, also for the case that actually $n_3=-n1$, $\bf{p}_3=-\bf{p}_1$, $n_4=-n_2$, $\bf{p}_4=-\bf{p}_2$ or a permutation thereof: How come there is a Gaussian integral appearing when $\phi_{l}(\bf{q})$ and $\phi_{-l}(-\bf{q})$ are independent variables to be integrated over?

Thanks!