I have a random variable of density $\frac{1}{\sqrt{2 \pi}} exp(-x^2 /2)$ and I want to prove that the distribution of $X^2$ is $\Gamma(1/2,1/2)= \frac{1}{\Gamma(1/2)\sqrt{2}} x^{-1/2} exp(-x/2)$.
Now, given a variable $X$ there is a theorem for calculating the pdf of $h(X)$ when $h$ is a diffeomorphism. The problem is that here I do not have a diffeomorphism. Intuitively, though, it is clear that restricting to the positive numbers, you can use the theorem and then double the pdf you obtain (because for every $Y=X^2$ there are two equiprobable $X$ that give $Y$). Doing it this way solves the exercise. However, I was wondering, how do you do this in general?
I mean, in this case the probability of $X$ and $-X$ is the same, and intuition gives us the answer. But in general this is not the case. How should I proceed then? I would say that (given $Y=X^2$) I should divide the two cases $X>0$ and $X<0$, treat them separately (using the fact that now I have a diffeomorphism on both of them) and then the pdf I was searching would be the sum of the two. Is this correct or there is some mistake I don't see?
Your basic strategy is right. The general method to derive the CDF of $X^2$ if you know the CDF of $X$ is: $$ \mathbb P(X^2 \leq a) = \mathbb P(-\sqrt a \leq X \leq a) = \mathbb P(X \leq \sqrt a) - \mathbb P(X < -\sqrt a)$$ Thus, if you're dealing with a continuous r.v. $X$ that has CDF $F_X(a)$, the CDF of $X^2$ is therefore $F_{X^2}(a) = F_X(\sqrt a) - F_X(-\sqrt a)$ for all nonnegative $a$.
If your original $X$ is symmetric about $0$, then as you noted, things are a bit simpler because $F_X(\sqrt a) = -F_X(-\sqrt a)$, so the formula would reduce to $2 F_X(\sqrt a)$ -- but you can still work with the above method even if $X$ is not symmetric.