Change in order of integration. I have this equation, $$\int_{0}^{a}\int_{x}^{a}(x^2+y^2)dydx$$ and, I want to change the order of integration from $dydx$ to $dxdy$.$\text{ }y$ varies from $y=x \text{   to  }y=a$, and $x\text{  varies from }x=0 \text{ to } x=a$. When we change the order of integrals, I thought it should be 
$$\int_{0}^{a}\int_{y}^{a}(x^2+y^2)dxdy$$ but the actual result in the book says, it's.$$\int_{0}^{a}\int_{a}^{y}(x^2+y^2)dxdy$$
am not getting why the limits of x should start from a and end at y instead of y to a, while $\int$ w.r.t dx?
-Kamal.
 A: If you examine carefully the values that $x$ and $y$ can take at any time during the integration, you should see that you always have $x\geq0$, $y\leq a$, and $y\geq x$.
That is, $(x,y)$ is always in the region bounded by the lines $x=0$, $y=a$,
and $y=x$ colored gray in the figure below:

There are some other conditions that are enforced by the bounds of integration,
in particular $x \leq a$, but we can see that this condition is redundant.
(All points in the triangular region already satisfy that condition.)
In other words, we're integrating values of $f$, but only the ones that are found
in that triangular region.
When you reverse the order of integration, you need to set the bounds of each integral
so that you still integrate only over the values of $(x,y)$ in the same triangle.
For one thing, you must ensure that $x \leq y$. That's where the upper bound of
the integral over $x$ comes from. The condition $x\geq 0$ gives the lower bound $0$.
A: Your idea is correct, and the book is wrong. Since $x^2+y^2=y^2+x^2$ you can just interchange $x$ and $y$. Therefore,
\begin{align*}
\int_0^a\int_x^a(x^2+y^2)dydx=\int_0^a\int_y^a(y^2+x^2)dxdy=\int_0^a\int_y^a(x^2+y^2)dxdy.
\end{align*}
You can actually evaluate these integrals directly. While your idea gives $a^4/3$, the book's result would be $-a^4/3$.
A: If function $[y>x]:\mathbb R^2\rightarrow\mathbb R$ is prescribed by $\langle x,y\rangle\mapsto 1$ if $y>x$ and $\langle x,y\rangle\mapsto0$ otherwise then: $$\int_{0}^{a}\int_{x}^{a}(x^2+y^2)dydx=$$$$\int_{0}^{a}\int_{0}^{a}[y>x](x^2+y^2)dydx=\int_{0}^{a}\int_{0}^{a}[y>x](x^2+y^2)dxdy=$$$$\int_{0}^{a}\int_{0}^{y}(x^2+y^2)dxdy$$
