Change of variables technique to show that for iid standard normals $X_1,X_2$, $Y_1 = X_1^2 + X_2^2$ has a $\chi^2(2)$ distribution Suppose $X_1$ and $X_2$ are iid with a common standard normal distribution. Find the joint pdf of $Y_1 = X_1^2 + X_2^2$ and $Y_2=X_2$ and the marginal pdf of $Y_1$.
It's easy to see that $Y_1$ has a $\chi^2(2)$ distribution, but this problem asks to show it using change of variables technique. 
Here, I can find the Jacobian $\partial(x_1,x_2) / \partial(y_1,y_2) = \frac{1}{2x_1}$, where $x_1^2 = y_1 - y_2^2$. Hence we must have 
$$f_{Y_1,Y_2}(y_1,y_2) = \frac{1}{2x_1} \frac{1}{2\pi} e^{-y_1^2}.$$
However, in this case we have $x_1 = \pm \sqrt{y_1 - y_2^2}$. How can we integrate $y_2$ out from this pdf to get the marginal pdf of $Y_1$?
 A: Joint density of $(X_1,X_2)$ is $$f_{X_1,X_2}(x_1,x_2)=\frac{1}{2\pi}e^{-\frac{1}{2}(x_1^2+x_2^2)}\quad,(x_1,x_2)\in\mathbb R^2$$
We change variables $(X_1,X_2)\to(Y_1,Y_2)$ such that $Y_1=X_1^2+X_2^2$ and $Y_2=X_2$.
The inverse solutions of the transform  are
$$x_1=\begin{cases}\sqrt{y_1-y_2^2}&,\text{ if }x_1\ge0\\-\sqrt{y_1-y_2^2}&,\text{ if }x_1<0\end{cases}\qquad\text{ and }\quad x_2=y_2$$
We have, $(x_1,x_2)\in\mathbb R^2\implies y_1\ge0\,,y_2\in\mathbb R$.
But for $x_1$ to be defined, $y_1-y_2^2\ge0\implies -\sqrt{y_1}\le y_2\le \sqrt{y_1}$.
So the joint support of $(Y_1,Y_2)$ is $$S=\{(y_1,y_2):y_1\ge0\,,\, -\sqrt{y_1}\le y_2\le\sqrt{y_1}\}$$
Clearly, this is not a one-to-one transformation.
Jacobian of the transformation is given by
$$J_1=\det J\left(\frac{x_1,x_2}{y_2,y_2}\right)=\frac{1}{2\sqrt{y_1-y_2^2}}\quad\text{ if }x_1\ge0$$
and $$J_2=\frac{-1}{2\sqrt{y_1-y_2^2}}\quad\text{ if }x_1<0$$
Hence joint density of $(Y_1,Y_2)$ is 
\begin{align}
f_{Y_1,Y_2}(y_1,y_2)&=\frac{1}{2\pi}e^{-y_1/2}|J_1|\mathbf1_S+\frac{1}{2\pi}e^{-y_1/2}|J_2|\mathbf1_S
\\&=2\times\frac{1}{2\pi}e^{-y_1/2}\frac{1}{2\sqrt{y_1-y_2^2}}\mathbf1_S
\\&=\frac{1}{2\pi}e^{-y_1/2}\frac{1}{\sqrt{y_1-y_2^2}}\mathbf1_S
\end{align}
For $y_1\ge 0$, marginal pdf of $Y_1$ is thus 
\begin{align}
f_{Y_1}(y_1)&=\int_{-\sqrt {y_1}}^{\sqrt {y_1}}f_{Y_1,Y_2}(y_1,v)\,dv
\\&=\frac{e^{-y_1/2}}{2\pi}\sin^{-1}\left(\frac{v}{\sqrt{y_1}}\right)\big|_{-\sqrt {y_1}}^{\sqrt {y_1}}
\\&=\frac{1}{2}e^{-y_1/2}
\end{align}
That is, $$f_{Y_1}(y_1)=\frac{1}{2}e^{-y_1/2}\mathbf1_{y_1\ge 0}$$
So we have shown that $Y_1\sim\text{Exp}$ with mean $2$ or simply, $Y_1\sim\chi^2_2$.
