Horizontal line(s) that intersect $f(x)=x-2+\frac{5}{x}$ in two points. Compute exactly the value(s) of $q$ for which the horizontal line $y = q$
intersects the graph of $f(x)$ in two points that are located on a distance $4$ from each other.
While I found the two lines as $y = 4$ and $y = -8$
, I do not know how to find it by any mathematical means.
 A: We want to values of $x$ (of distance $4$ apart) such that $x-2 + \frac{5}{x} = q$, but this is equivalent to $x^2 - 2x + 5 = qx$ by multiplying throughout by $x$, more simply:  $x^2 - (2+q)x + 5 = 0$. 
Now say that the smaller point is $\alpha$, then the other one is necessarily $\alpha + 4$. Hence $2\alpha + 4= 2 +q$ and $\alpha(\alpha + 4) = 5$ using the relationship between roots and coefficients. 
Isolating $\alpha$ from the first equation and plugging it into the second gives $(q-2)(q+6) = 20$ and equivalently $(q-4)(q+8) = 0.$
A: Intersection of $y$ and $f$:
$$
q = x - 2 + 5/x \iff \\
qx = x^2 -2x + 5 \wedge x \ne 0
$$
So we remember to discard a solution $x=0$ and solve the quadratic equation:
$$
0 = x^2 - (2 + q)x + 5 = (x - (1+q/2))^2 - (1+q/2)^2 + 5 \iff \\
(x-(1+q/2))^2 =(1+q/2)^2 - 5  \iff \\
x = (1+q/2) \pm \sqrt{(1+q/2)^2 -5} 
$$
As usual we have no, one or two solutions, depending on the argument of the square root. To get two intersections we need
$$
(1 + q/2)^2 - 5 > 0 \iff \\
(1 + q/2)^2 > 5 \iff \\
\lvert 1 + q/2 \rvert > \sqrt{5}
$$
For the positive case this means
$$
q > 2 (\sqrt{5}-1) = 2.47\dotsb
$$
For the negative case
$$
-(1 + q/2) > \sqrt{5} \iff \\
1 + q/2 < - \sqrt{5} \iff \\
q < -2(\sqrt{5} + 1) = -6.47\dotsb
$$
Now we apply the condition on the distance of the intersection points:
$$
\lvert x_1 - x_2 \rvert = 4 \iff \\
4 = x_1 - x_2 = 2 \sqrt{(1+q/2)^2 - 5} \iff \\
4 = (1 + q/2)^2 - 5 \iff \\
9 = (1 + q/2)^2 \iff \\
\pm 3 = 1 + q/2 \iff \\
q/2 = 2 \vee q/2 = -4 \iff \\
q = 4 \vee q = -8
$$
