Transformed Random Variables.

When given a piecewise distribution function for a continuous random variable $X$, how do you find the distribution function for $X^2$? Is it that you just square each of the pieces or do you have to use $F_X(x^{1/2})$? I've been given two contrasting pieces of advice. Thank you.

\begin{align} F_{X^2}(x) & = \Pr(X^2\le x) = \Pr(-\sqrt x \le X \le \sqrt x\,) = F_X(\sqrt x\,) - F_X(-\sqrt x\,). \tag 1 \\[10pt] f_{X^2}(x) & = \frac d {dx} F_{X^2}(x) = \frac d {dx} F_X(\sqrt x\,) - \frac d {dx} F_X( - \sqrt x\,) \tag 2 \\[10pt] & = f_X(\sqrt x\,) \cdot \frac d {dx} \sqrt x - f_X(-\sqrt x\,) \cdot \frac d {dx} (-\sqrt x\,). \tag 2 \end{align} In line $(3)$, you have two minus signs cancelling each other.
In line $(1),$ in cases where the distribution of $X$ is symmetric about $0,$ you have $F_X(-\sqrt x \,) = 1 - F_X(\sqrt x\,),$ so you can simplify a bit further.
In cases where the distribution of $X$ is symmetric about $0,$ in line $(3)$ you have $f_X(\sqrt x\,) = f_X(-\sqrt x\,),$ so you can do some simplifying.
If you just want $\operatorname E(X^2)$ rather than a complete characterization of the distribution of $X^2,$ then instead of computing $$\int_0^\infty x f_{X^2}(x)\,dx$$ you can instead compute $$\int_{-\infty}^\infty x^2 f_X(x)\,dx$$ and it will come to the same thing, and the integral may be less work to compute.