# Turning a covariance sum into an integral

I am reading Lorenzo's Bergomi's book Stochastic Volatility Modeling, and I have come to this passage. I just would like to understand the derivation between the first and the second equality. I guess I just have to "correctly" re-express the integral and then use Fubini's theorem so as to obtain an integral with just a $$dt$$/$$du$$/whatever term that turns into the $$T - \tau$$ term, but I can't figure how to do the right change of variables as $$t - u$$ is a function of $$t$$ and $$u$$. Any idea over there?

Note that the function $$f$$ only depends on $$|t-u|$$, meaning it is actually symmetric: $$f(x)=f(-x)$$. Doing the change of variable $$\tau:=t-u$$: \begin{align} \int_0^Tdu\int_0^Tf(t-u)dt &=\int_0^Tdu\int_{-u}^{T-u}f(\tau)d\tau \\ &=\int_0^Tdu\left(\int_0^{T-u}f(\tau)d\tau+\int_0^uf(\tau)d\tau\right) \\ &=\int_0^T{du \left(\int_0^T{f(\tau) \textbf{1}_{\tau \leq T - u} d\tau} + \int_0^T{f(\tau) \textbf{1}_{\tau \leq u}d\tau}\right)} \\ &=\int_0^T{f(\tau)d\tau \left(\int_0^T{ \textbf{1}_{u \leq T - \tau} du} + \int_0^T{\textbf{1}_{u \geq \tau}du}\right)} \\ &=\int_0^Tf(\tau)d\tau\left(\int_0^{T-\tau}du+\int_\tau^Tdu\right) \\ &=2\int_0^T(T-\tau)f(\tau)d\tau \end{align} For the second equality, note that $$0\leq u\leq T$$ hence $$-u\leq0$$ and $$0\leq T-u$$.