Confusion related to changing the order of integrals. let's say we have this double integral: $$\int_0^1\int_0^x f(x,y)\,dy\,dx $$
$x$ is from $0$ to $1,$ and $y$ is from $0$ to the line $y=x.$
when we swap the order of the integral we get: $$\int_0^1\int_y^1 f(x,y) \, dx \, dy $$ 
$x$ is from the line $x=y$ to $1,$ and $y$ is now from $0$ to $1.$ Please explain to me two things:
a. does the variable in the limit always need to be in the inner integral?
b. why can't i view $x$ as still being from $0$ to $1$ when changing the order of the integral instead of $y$ to $1.$ it still makes sense in the Region of Integration, no?
 A: $$
\int_0^1 \left( \int_0^x f(x,y)\,dy\right) \,dx = \iint\limits_{0\,\le\,y\,\le\, x\,\le\,1} f(x,y) \, d(x,y) = \int_0^1 \left( \int_y^1 f(x,y)\, dx \right) dy 
$$
One could say that the integrals on the left and right above are equal to each other because they are both equal to the integral in the middle.
This may be easier to illustrate using sums:
\begin{align}
& \sum_{x\,=\,1}^3 \left( \sum_{y\,=\,1}^x a(x,y) \right) \\[10pt]
= {} & \phantom{{}+{}} a(1,1) & \longleftarrow\quad & x=1 \\
& {} + a(2,1) + a(2,2) & \longleftarrow\quad & x=2 \\
& {} + a(3,1) + a(3,2) + a(3,3) & \longleftarrow\quad & x=3 \\[10pt]
= {} & \phantom{{}+{}} a(1,1) \\
& {} + a(2,1)+a(2,2) \\
& {} + a(3,1)+a(3,2)+a(3,3) \\
& \qquad \uparrow \qquad\qquad\uparrow\qquad\quad\uparrow \\
& \quad y=1\qquad y=2 \qquad y=3 \\[15pt]
= {} & \sum_{y\,=\,1}^3\left( \sum_{x\,=\,y}^3 a(x,y) \right)
\end{align}
Both of the iterated sums above are equal to $\displaystyle \sum_{x,y\,:\, 1\,\le\,y\,\le\,x\,\le\,3} a(x,y).$
Postscript suggested in a comment below from Mark Viola:
Changing the order in some cases alters the sum $\displaystyle \sum_{x,y} a(x,y)$ (without absolute value signs) when $\displaystyle \sum_{x,y} |a(x,y)|= +\infty$ (with absolute value), and likewise with integrals.
