Double Integral with a Delta Function Consider the integral $$\int_0^b\int_0^a\delta(x-y)f(x,y)dxdy$$ where $b>a$. I know that we need to integrate over the larger range first (i.e do the $y$ integral) and then do the remaining integral (i.e the $x$ integral). However I'm having trouble properly understanding why? An image is attached below - it seems to me that whether you integrate over x or y first you still capture all of the relevant part of the line y=x... Would anybody be able to provide a nice worded explanation or ideally something involving a diagram showing the region of integration? Thank you :)
 A: $$\int_0^a \delta(x-y)f(x,y)dx = 1_{[0;a]}(y) f(y,y)$$ ie $f(y,y)$ if $y\in [0;a]$ and $0$ elsewhere
So $$\int_0^b \left(\int_0^a \delta(x-y)f(x,y)dx \right)dy  =\int_0^b  1_{[0;a]}(y)f(y,y) dy  =\int_0^a f(y,y)dy $$
A: As a slightly more general case, let us evaluate the integral for the region $g_1(x)<y<g_2(x)$ and $x_1<x<x_2$. Thus our integral takes the form
\begin{equation}
\int_{x_1}^{x_2}\mathrm{d}x\int_{g_1(x)}^{g_2(x)}\mathrm{d}y\delta(x-y)f(x,y)
\end{equation}
Note that in this case, the limit of integration can't be changed. This can be simplified in the following manner using the Heavyside function $\Theta(x)$ as follows
$$\int_\alpha^\beta f(x)\delta(x-a)\mathrm{d}x=f(a)\Theta(a-\alpha)\Theta(\beta-a)$$
Mathematically, the $\Theta$ functions take care of the fact that the integral is non-zero only when $\alpha<a<\beta$. This can be used for the integral given above to get
$$\int_{x_1}^{x_2}\mathrm{d}xf(x,x)\Theta(x-g_1(x))\Theta(g_2(x)-x)$$
Now let us consider a special case $g_1(x)=y_1\in\mathbb{R}$, $g_2(x)=y_2\in\mathbb{R}$, i.e., constant $y$ limits. Thus we get
$$\int_{x_1}^{x_2}\mathrm{d}xf(x,x)\Theta(x-y_1)\Theta(y_2-x)=\int_{\max\{x_1,y_1\}}^{\min\{x_2,y_2\}}\mathrm{d}xf(x,x)$$
Finally, if we consider the case given above, then this gives
$$\int_{0}^{a}\mathrm{d}xf(x,x)$$
which is the same as obtained above.
