Substitution in definite integral $f$ is an arbitrary real valued function. Consider the integral
$I= \int_{-a}^{a}f(x^2)dx$.
If I make the substitution $t=x^2$, then
$I=\int_{a^2}^{a^2}f(t)\frac{dt}{2\sqrt{t}}=0$, which is evidently not true as a general case. Where am I wrong?
Edit (an observation): Every time I try to make this substitution for a specific $f$, I can't find a primitive of the function $\frac{f(t)}{2\sqrt{t}}$. The only cases in which I succeeded, the integral $I$ was actually $0$. Why is this happening?
 A: As you note, this is not true in the general case, obviously. The reason is because substitutions must be injective; otherwise, you run into issues back substituting. In this case, note $x \to x^2$ is not injective in $[-a, a]$ for $a\neq0$.  We can, however, split the integral up so that it is injective in the interval we're considering. In particular, our back substitution in $[-a, 0]$, rather than the principal root, will be the negative root. Computing, we see
$$\int_{-a}^a f(x^2) \ dx = \int_{-a}^0 f(x^2) \ dx  + \int_{0}^a f(x^2) \ dx$$
and 
$$\int_{-a}^0 f(x^2) \ dx = \int_{0}^a f(x^2) \ dx =  \int_{0}^{a^2} f(t)\frac{dt}{2\sqrt{t}}$$
Thus $$\int_{-a}^a f(x^2) \ dx = 2\int_{0}^a f(x^2) \ dx = 2 \int_{-a}^0 f(x^2) \ dx$$ which is what we'd expect since $f(x^2)$ is even. 
A: I think we should go back to the method of substitution in indefinite integral. So the argument is like this: If you can't integrate $\int f(x)dx$ directly, try to find an $\textit{invertible function}$ $x=g(u)$ so that you can find easily a function $F(u)$ such that
$$\frac{dF}{du}=f(g(u))g'(u)$$
Then, by chain rule
$$\frac{d}{dx}F(g^{-1}(x))=\frac{d}{du}F(u)\frac{d}{dx}g^{-1}(x)=f(g(u))g'(u)\frac{1}{g'(u)}=f(x)$$
and hence
$$\int f(x)dx=F(g^{-1}(x))$$.
So from the above, $g(u)$ need to be a $\textit{function}$ which is $\textit{invertible}$.
So your case, you are using $x=\sqrt{t}$ which is $\textit{not}$ a function. You can make it an invertible function by restricting the codomain to $x\ge0$. But then $-a\le x<0$ are not inside the range.
A: When $t=0$, $x=0$, but at that point $\frac{dt}{dx}=2x=0$ so the mapping can and does turn around and go back. For that reason you have to break up the integral into two pieces to perform the transformation successfully.
$$\int_{-a}^af(x^2)dx=\int_{-a}^0f(x^2)dx+\int_0^af(x^2)dx$$
For the first integral $x<0$ so $x=-\sqrt t$, $dx=-\frac{dt}{2\sqrt t}$ and
$$\int_{-a}^af(x^2)dx=\int_{a^2}^0f(t)\left(-\frac{dt}{2\sqrt t}\right)=\frac12\int_0^{a^2}\frac{f(t)}{\sqrt t}dt$$
In the second, $x>0$ so $x=\sqrt t$, $dx=\frac{dt}{2\sqrt t}$ and
$$\int_0^af(x^2)dx=\int_0^{a^2}f(t)\left(\frac{dt}{2\sqrt t}\right)=\frac12\int_0^{a^2}\frac{f(t)}{\sqrt t}dt$$
Putting these together,
$$\int_{-a}^af(x^2)dx=\int_0^{a^2}\frac{f(t)}{\sqrt t}dt$$
