Is it true that $\int x \int f(x,y) dy dx = \int\int x f(x,y)dx dy$? This holds when $f(x,y)$ is a joint probability distribution, but after some calculation it appears to be true in general: 
$$\int x \int f(x,y) dy dx = \int\int x f(x,y)dx dy $$
Somehow I can't wrap my head around it. Can anybody help me see it?
 A: Fubini's Theorem gives conditions under which you can "switch the order of integration".  By this, I mean it lets you know when
$$\int_Y\left(\int_X f(x,y)dx\right)dy = \int_X\left(\int_Y f(x,y)dy\right)dx =\int_{X\times Y}f(x,y)d(x,y)$$
So, it tells you when you can break down a double integral into two iterated single integrals.
If the conditions for fubini's theorem hold, and say that $f(x,y) = g(x,y)h(x)$, then as $h(x)$ is "constant" for fixed $x$, we get that:
$$\int_{X\times Y} f(x,y) d(x,y) = \int_X h(x)\left(\int_Y g(x,y)d y\right)d x$$
Of course, in your example you just have that $h(x) = x$.
A: Presumably, the integration is over some region in the plane. You are just changing the order of integration; when you integrate $xf(x,y)$ first with respect to $y$ (the inner integral), the variable $x$ is regarded as constant and so can be pulled outside of the integral.
Of course, you have suppressed the limits of integration, and they will likely be different in the two integrals.
As pointed out in other answers, changing the order of integration is not always valid. But it typically is for most functions you will encounter in such an application (for example, I think bounded positive functions on a bounded region will do).
