TITLE: Why am I getting the wrong answer when I factor an $i$ out of the integrand?
QUESTION [22 upvotes]: Consider the following definite integral:
  $$I=\int^{0}_{-1}x\sqrt{-x}dx \tag{1}$$

With the substitution $x=-u$, I got $I=-\frac{2}{5}$ (which seems correct).
But I then tried a different method by first taking out $\sqrt{-1}=i$ from the integrand:
$$I=i\int^{0}_{-1}x\sqrt{x}dx=\frac{2i}{5}[x^{\frac{5}{2}}]^{0}_{-1}=\frac{2i}{5}{(0-(\sqrt{-1})^5})=-\frac{2i^6}{5}=+\frac{2}{5} \tag{2}$$
which is clearly wrong. 
I understand that $x\sqrt{x}$ is not even defined within $(-1,0)$, but why can't we use the same 'imaginary approach' ($\sqrt{-1}=i$) to treat this undefined part of the function (i.e. the third equality in $(2)$).
I can't find a better way of phrasing my question so it may seem gibberish, but why is $(2)$ just invalid?

REPLY [11 votes]: Fundamentally, your error amounts to the following (mis)calculation:
$$1=\sqrt1=\sqrt{-(-1)}=i\sqrt{-1}=i^2\sqrt1=-\sqrt1=-1$$
It's just that the second minus sign doesn't appear in what you're doing until after the first one was converted to an $i$. I.e., you converted $\sqrt{-x}$ to $i\sqrt x$ before doing the integration, and only later substituted the lower limit $x=-1$.