Integration of density function I am working with two random variables: $X\sim \text{Exp}(2\lambda)$ and $Y$, which has the following density function
$$f_Y(x)=\frac{1}{\pi\sqrt{x(2-x)}},$$
where $0<x<2$. I'm trying to find the density function of the variable $Z=XY$, knowing that $X$ and $Y$ are independent. I have found out that:
$$f_Z(x)=\frac{2\lambda}{\pi}\int_0^2\frac{e^{-2\lambda x/b}}{b^{3/2}\sqrt{2-b}}\,db.$$
However, I don't know how to integrate this.
By the way, WolframAlpha gives the density function of a Gamma distribution of shape $1/2$ and rate $\lambda$, that is
$$Z\sim \Gamma(1/2,\,\lambda).$$
 A: It is possible to do this integration directly, but it can be easier to choose a different change of variables.
This can be a bit of an art, so I'll outline my thinking as I go.
So whatever transformation $(u(x, y), v(x, y))$ you choose, the density that you'll be dealing with is going to end up being
\begin{align*}
f_{U, V}(u, v)
&= f_X(x(u, v)) f_Y(y(u, v)) |J(u, v)| \\
&\propto \frac{e^{-2\lambda x}}{y(2-y)} |J| \mathbf{1}_{x\geq 0}\mathbf{1}_{0\leq y \leq 2}
\end{align*}
where $J$ is the corresponding Jacobian.
Our aim is then to choose the transformation so that this factors into terms containing only $u$ and only $v$, or failing that, something that is easier to integrate with respect to $u$.
In this case, it's the exponential term that's going to give us trouble, so it makes sense to choose a transformation in which $x(u, v)$ is a function of only one of $u$ or $v$.
So let's try
\begin{align*}
\begin{pmatrix}u \\ v\end{pmatrix}
= \begin{pmatrix} xy \\ 2v\end{pmatrix},
\quad
\begin{pmatrix}x \\ y\end{pmatrix}
= \begin{pmatrix} v/2 \\ 2u/v\end{pmatrix},
\quad
J
= \begin{pmatrix}0 & 1/2 \\ 2/v & -2u/v^2\end{pmatrix}.
\end{align*}
Now the density is
\begin{align*}
f_{U,V}(u,v)
&\propto \frac{e^{-\lambda v}}{\sqrt{\frac{2u}{v}(2 - \frac{2u}{v})}} \frac{1}{v} \mathbf{1}_{v \geq 0} \mathbf{1}_{0 \leq \frac{2u}{v} \leq 2} \\
&\propto \frac{e^{-\lambda v}}{\sqrt{u(v-u)}} \mathbf{1}_{v \geq u \geq 0}.
\end{align*}
This is already better, but notice that
\begin{align*}
f_{U,V}(u,v)
&\propto \frac{e^{-\lambda u}}{\sqrt{u}}\mathbf{1}_{u \geq 0} \cdot \frac{e^{-\lambda (v - u)}}{\sqrt{v-u}}\mathbf{1}_{v - u \geq 0}.
\end{align*}
This suggests another change of variables
\begin{align*}
\begin{pmatrix}u \\ v'\end{pmatrix}
= \begin{pmatrix} u \\ v - u\end{pmatrix},
\quad
\begin{pmatrix} u \\ v \end{pmatrix}
= \begin{pmatrix} u \\ u + v'\end{pmatrix},
\quad
J
= \begin{pmatrix}1 & 0 \\ 1 & 1\end{pmatrix},
\end{align*}
from which we get
\begin{align*}
f_{U, V'}(u, v')
&\propto \frac{e^{-\lambda u}}{\sqrt{u}}\mathbf{1}_{u \geq 0} \cdot \frac{e^{-\lambda v'}}{\sqrt{v'}}\mathbf{1}_{v' \geq 0}.
\end{align*}
That is, $(U, V')$ are independent $\Gamma(1/2, \lambda)$ RVs.
In particular, $XY = U \sim \Gamma(1/2, \lambda)$, agreeing with your WolframAlpha result.
A: Another way of solving it is through your integral and some variable changes. Let
$$
I_1 = \int_0^2 \frac{e^{-2\lambda x/b}}{b^{3/2}\sqrt{2-b}}db
$$
such that $f_Z(x) = 2\lambda /\pi I_1$. Let $a = 2/b-1$ such that $da = -2/b^2db$. Moreover, when $b=2\implies a = 0$ and $b\to 2\implies a \to \infty$. Also, $2/b = a+1$. Therefore
$$
\begin{aligned}
I_1 &= \int_0^2 \frac{e^{-2\lambda x/b}}{b^{3/2}\sqrt{b(2/b-1)}}db \\
&= \int_0^2 \frac{e^{-2\lambda x/b}}{b^{2}\sqrt{2/b-1}}db \\
&= \int_{\infty}^0 -\frac{1}{2} \frac{e^{-\lambda x(a+1)}}{\sqrt{a}}da \\
&= \frac{1}{2}e^{-\lambda x} \int_0^{\infty} e^{-\lambda x a} a^{1-1/2}da\\
&= \frac{1}{2}e^{-\lambda x} I_2
\end{aligned}
$$
Note however that $I_2$ is the kernel of a gamma function over $a$ with parameters $\beta = \lambda x$ and $\alpha = 1/2$, and such it integrates to the integration constant $\Gamma(\alpha) /(\beta^\alpha) = \Gamma(1/2) / (\lambda x)^{1/2}$. Thus
$$
\begin{aligned}
I_1 &= \frac{1}{2}e^{-\lambda x} I_2 \\
&= \frac{1}{2}e^{-\lambda x}\frac{\Gamma(1/2)}{(\lambda x)^{1/2}}.
\end{aligned}
$$
Then
$$
\begin{aligned}
f_Z(x) &= \frac{2\lambda}{\pi}I_1 \\
&= \frac{2\lambda}{\pi} \frac{1}{2}e^{-\lambda x}\frac{\Gamma(1/2)}{(\lambda x)^{1/2}}\\
&= \frac{\lambda^{1/2} e^{-\lambda x}x^{1-1/2}}{ \sqrt{\pi}} \\
&= \frac{\lambda^{\tau} e^{-\lambda x}x^{1-\tau}}{ \Gamma(\tau)}
\end{aligned}
$$
with $\tau = 1/2$, where we used the fact that $\Gamma(1/2) = \sqrt{\pi}$. Thus, $Z\sim Gamma(\tau, \lambda)$.
