I'm doing some statistical analysis (random variate generation for simulation models) and I just ran the inverse transform of a CDF:
$$ F(x) = \begin{cases} (x-4)/4 & \text{for } x \in [2,3] \\ x - (x^2/12) & \text{for } x \in (3,6] \\ 0 & \text{otherwise} \end{cases} $$ That yieds a couple of equations:
$$ R=(x-4)/4 ~ \text{ for } ~ 2 \leq x \leq 3$$
$$ R=x(1-x)/12 ~ \text{ for } 3 < x \leq 6 $$
Now, the first one is easy:
$$ 4(R+1)=x ~ \text{ for } -1/2 \leq x \leq -1/4 $$
But the second one is implicit:
$$ (1-(12R/x))1/2=x \text{ for } -2 < x <=-17.5 $$
...backtracking, I rearrange the equation: \begin{eqnarray*} R & = & x - (x^2/12) \\ 12R & = & 12(x - (x^2/12)) \\ R & = & 12(x - (x^2/12))/12 \\ R & = & (12x - (12x^2/12))/12 \\ R & = &(12x - (x^2))/12 \\ 12R & = &(12x - (x^2)) \\ 12R & = &12x - (x^2) \\ 12R & = &12x - x^2 \\ \end{eqnarray*}
Changing R for y...
$$ x^2 + 12y - 12x= 0 $$
Now, that looks awfully familiar, but I confess I've hit a wall and do not remember what to do from here.
How can I get an explicit function solving for $x$?
$$x^2+12y-12x=0$$
$$x^2-12x=-12y$$
$$(x-6)^2-36=-12y$$
For $y \leq 3$ $$x-6=\pm \sqrt{-12y+36}$$
$$x=6 \pm \sqrt{-12y+36}$$