Let $f,g \in L^1(\mathbb{R})$, how can I justify that
$$ \int_{a}^{b} f(x) \left( \int_{x}^{b} g(y)dy\right)dx = \int_{a}^{b} g(y) \left( \int_{a}^{y} f(x)dx\right)dy $$
using Fubini theorem (with lebesgue measure). I can't consider the intervals $[a,b]$ and $[x,b]$ because $x$ varies in $[a,b]$. I tried to put the domain:
$$ \{ (x,y) \in \mathbb{R}^2 \vert a \leq x \leq y \leq b \}$$
as union of rectangles but could not
I have learned on this note of Donald Knuth that it is best to write the integration bounds as functions. We have the double integral $$ \int_{a}^{b} f(x) \left( \int_{x}^{b} g(y)dy\right)dx.$$ In this form, manipulating it can be troublesome. But we can rewrite it as $$ \int_{[a, b]^2} f(x)g(y)\mathbf 1_{\{x\le y\}}\,dxdy,$$ where $\mathbf 1_{\{x\le y\}}$ is the function of $x$ and $y$ that equals $1$ if $x\le y$ and $0$ otherwise. We can mechanically rewrite this integral as $$ \int_a^b g(y)\left(\int_a^b f(x)\mathbf 1_{\{x\le y\}}\, dx\right)\, dy, $$ and now it is obvious that it equals $$\int_a^b g(y)\left(\int_a^y f(x)\, dx\right)\, dy,$$ as expected.
(In the linked note, Knuth goes as far as suppressing the $\mathbf 1$ altogether, writing $[x\le y]$ instead. This he calls a Iverson bracket. I think it is a great notation, but it is not that widespread).