Computation of density function of $Y=\frac1X-X$ where $X\stackrel{\mathrm d}= U[0,1]$ 
Calculate the density function of $Y=\frac1X-X$, where $X\stackrel{\mathrm d}= U[0,1]$.

I am confused about the technique to deal with the problem like this when after the transformation, I can not express the density of $Y$ in terms of $X$
 A: $1/X-X$ is a decreasing function of $X$ so $Y\in(0,\infty)$ for $X\in(0,1)$.
$$P(Y\le y)=\begin{cases}0,&y\le0\\P(1-X^2\le yX),&y>0\end{cases}$$
Now $X^2+yX-1$ is an upward opening parabola with zeroes at  $\frac{-y\pm\sqrt{y^2+4}}2$, and thus $$\begin{align*}P(X^2+yX-1\ge0)&=\underbrace{P\left(X\le\frac{-y-\sqrt{y^2+4}}2\right)}_{0}+P\left(X\ge \frac{-y+\sqrt{y^2+4}}2\right)\\&=1-P\left(X\le\frac{-y+\sqrt{y^2+4}}2\right)\\&=1-\min\left\{1,\frac{-y+\sqrt{y^2+4}}2\right\}\end{align*}$$
Can you simplify this?

 Rationalizing$$\frac{-y+\sqrt{y^2+4}}2\left[\frac{\sqrt{y^2+4}+y}{\sqrt{y^2+4}+y}\right]=\frac2{\sqrt{y^2+4}+y}$$Call it $g(y)$. It is decreasing for $y>0$ so $g(y)<g(0)=1$, giving $\min\{1,g(y)\}=g(y)$.

A: Surely you know the theorem that if $Y=r(X)$ where r(x) is differentiable and one-to-one for $a<x<b$, and $(\alpha, \beta)$ is the image of (a, b) under the function r, and if s(y) is the inverse function of r(x), then the pdf of Y is given by
$$f_Y(y)=\begin{cases}f_X(s(y))\left|\frac{d}{dy}s(y)\right|&, \alpha<y<\beta\\
0&\text{otherwise}\end{cases}$$
First find s(y):
$$\begin{split}Y&=\frac 1 X - X\\
s(Y)=X&=\frac{-y\pm\sqrt{y^2+4}}{2}\end{split}$$
Take the derivative
$$s'(y)=-\frac 1 2 \pm \frac{y}{2\sqrt{y^2+4}}$$
It remains to determine if $$\begin{split}\left|\frac{d}{dy}s(y)\right|&=\frac 1 2-\frac {y}{2\sqrt{y^2+4}}\\
\text{or}\left|\frac{d}{dy}s(y)\right|&=\frac 1 2+\frac {y}{2\sqrt{y^2+4}}\end{split}$$
Because $Y=\frac 1 X - X$ is decreasing on [0,1] you take the minus sign as $\frac {y}{2\sqrt{y^2+4}}$ is increasing on $(0,\infty)$.
Then
$$f_Y(y)=\begin{cases}\frac 1 2-\frac {y}{2\sqrt{y^2+4}}&,0<y<\infty\\
0&,y\le0\end{cases}$$
