Why integrals with respect to different variables aren't equal? I have a function $y=x^2+1$, the integral from $-1$ to $2$ is $\int_{-1}^{2}(x^2+1)dx = 6$.
The function $x=\sqrt{y-1}$ is the same as the above function. The integral would be from $0$ to $(2)^2+1=5$. So I thought that $\int_{0}^{5}(\sqrt{y-1})dy$ would be equal to the first one.
But it turns out that it does not. The integral of the second function actually is $\frac{16}{3}+\frac{2i}{3}$.
So by looking at the graph of this function I realized that I can just add the bottom rectangle to the upper part thus eliminating the dealing with complex numbers like this: $(3\times 1)+\int_{1}^{5}\sqrt{y-1}dy$, but this is equal to $25/3$ or approximately $8$ instead of $6$.
So my question is, why aren't these two integrals equal? 
 A: Actually, the function $x=\sqrt{y-1}$ is not the same as the function $y=x^2+1$.
The function $y=x^2+1$ is not one-to-one. In order to define the inverse, you are restricting yourself to the region of the function in which $x\geq 0$. So $x=\sqrt{y-1}$ is the inverse of $y=x^2+1,\ x\geq 0$, but not of the general function. 
(Viewed another way: your first integral is for values of $x$ that are between $-1$ and $2$. But no value of $y$ will give you $x\lt 0$ in the formula $x=\sqrt{y-1}$ so you cannot cover the same "values" with that formula)
Moreover, when we integrate $y=x^2+1$ from, say, $x=0$ to $x=2$ (to keep it in a region where you can talk about both functions), you are computing the net signed area between the lines $y=0$ (the $x$-axis), the line $x=0$, the line $x=2$, and the graph $y=x^2+1$. However, when you compute the integral of $x=\sqrt{y-1}$ with respect to $y$ from $y=0$ to $y=5$, although you can view it as the same graph as before, you are now computing the net signed are between the lines $x=0$ (the $y$=axis), $y=0$, $y=5$, and the graph $x=\sqrt{y-1}$. You are measuring different areas. 
The two areas together should give you the area of the rectangle bounded by $x=0$, $x=2$, $y=0$, and $y=5$ (that is, $10$).
So it is hardly a surprise that you are getting different answers: first, your change "loses" all the information about the area under $y=x^2+1$ that was to the left of the $y$-axis; and second, the integrals are actually computing different areas (though they are both bounded by the same curve). One computes the area "under" the curve, the other integral computes the area "to the left" of the curve.
