Let $X_1$ and $X_2$ be independent standard normal variables. Find the joint density function of $Y_1 = X_1^2 + X_2^2,\quad Y_2 = \frac{X_1}{X_2}$.
My solution: After solving I have $\frac{1}{|J|} = 2\left(\frac{x_1^2}{x_2^2} + 1\right) = 2(Y_2^2 + 1),$ which implies $|J| = \frac{1}{2(Y_2^2 + 1)}$.
Since $X_1$ and $X_2$ are independent standard normal variables, their joint density is given by: $f(X_1, X_2) = \frac{1}{2\pi} e^{-\frac{X_1^2 + X_2^2}{2}}.$
Therefore, the joint density of $Y_1$ and $Y_2$ is given by:
$g(Y_1, Y_2) = \frac{1}{2\pi} e^{-\frac{X_1^2 + X_2^2}{2}}|J|$
$= \frac{1}{2\pi} e^{-\frac{Y_1^2}{2}} \cdot \frac{1}{2(Y_2^2 + 1)}$
$= \frac{1}{4\pi} e^{-\frac{Y_1^2}{2}} \cdot \frac{1}{Y_2^2 + 1}.$
But the answer is $\frac{1}{2} e^{-\frac{Y_1^2}{2}} \cdot \frac{1}{\pi(Y_2^2 + 1)}.$ Also my answer can't possibly be correct because after double integrating the density function I'm getting $\frac{1}{2}$.
What am I doing wrong?
First of all, you have a minor typographical error: $Y_1 = X_1^2 + X_2^2$ implies that $$e^{-(X_1^2 + X_2^2)/2} = e^{-Y_1/2},$$ not $e^{-Y_1^2/2}$. This however is immaterial to your question.
The reason why you are not getting the correct scaling factor is because the transformation is not injective; i.e., $$(Y_1, Y_2) = (X_1^2 + X_2^2, X_1/X_2)$$ is not one-to-one on $\mathbb R^2$. In particular, $$((-X_1)^2 + (-X_2)^2, (-X_1)/(-X_2)) = (X_1^2 + X_2^2, X_1/X_2)$$ for every $X_1, X_2 \ne 0$. It is for this same reason that the univariate transformation formula $$f_Y(y) = f_X(g^{-1}(y)) \left|\frac{dg^{-1}}{dy}\right|, \quad Y = g(X),$$ requires that the transformation $g$ be one-to-one.