First of all, I should probably mention that I am a physicist, not a mathematician so I sincerely apologize for any lack of rigour in my explanation of my problem.
Recently, I have been trying to calculate (simple) 2d Fourier transforms of time-ordered Matsubara Green's functions, but I have been having some problems with it.
I can't seem to determine whether or not the order of integration matters for a double integral like the following
$$ \int_{0}^{\beta} \int_{0}^{\beta} e^{i \omega_1 \tau_1}e^{i \omega_2 \tau_2} \theta(\tau_1-\tau_2) e^{g (\tau_1-\tau_2)} d\tau_1 d\tau_2 \quad (1) $$
By my calculation (and double checking with mathematica), evaluating the above double integral iteratively as:
$$ \int_{0}^{\beta} \left(\int_{0}^{\beta} e^{i \omega_1 \tau_1}e^{i \omega_2 \tau_2} \theta(\tau_1-\tau_2) e^{g (\tau_1-\tau_2)} d\tau_1\right) d\tau_2 \quad (2) $$
gives
$$ \frac{e^{i \beta \omega _1} \left(e^{\beta g}-e^{i \beta \omega _2}\right)}{\left(g+i \omega _1\right) \left(g-i \omega _2\right)}+\frac{-1+e^{i \beta \left(\omega _1+\omega _2\right)}}{\left(\omega _1+\omega _2\right) \left(\omega _1-i g\right)} \quad (3) $$
whereas evaluating iteratively instead as
$$ \int_{0}^{\beta} \left(\int_{0}^{\beta} e^{i \omega_1 \tau_1}e^{i \omega_2 \tau_2} \theta(\tau_1-\tau_2) e^{g (\tau_1-\tau_2)} d\tau_2\right) d\tau_1 \quad (4) $$
gives
$$ \frac{-1+e^{\beta (g+i \omega_1)}}{(g+i \omega_1) (g-i \omega_2)}-\frac{-1+e^{i \beta (\omega_1+\omega_2)}}{(\omega_2+i g) (\omega_1+\omega_2)} \quad (5) $$
Such a discrepancy between results does not seem to occur when the limits of each integral is $(-\infty,\infty)$ (such a problem has been addressed in previous posts such as this one).
Furthermore, I even tried the usual variable substitution approach where I defined the following new set of variables
$$ \tau = \tau_1-\tau_2, \qquad \tilde{\tau} = \tau_2 \\ \tilde{\tau} \epsilon [0,\beta], \qquad \tau \epsilon [-\tilde{\tau}, \beta-\tilde{\tau}] $$
And this gives me the same result as (3). So I'm not sure whether I am making a mistake or that Fubini's theorem does not apply when dealing with Heaviside theta functions. But if the order of integration does matter, then which is the correct way of calculating these integrals? Surely this is crucial when calculating Matusbara Green's functions in frequency space. Any advice would be greatly appreciated!