TITLE: Find all rational points on $x^2 + y^2 = 17$
QUESTION [6 upvotes]: So yes, this was asked before but I'm stuck on a specific step.
So to solve this, I tried to find the the intersection between the line $y=m(x-1)+4$ (we have $(1, 4)$ as a rational point on the circle) and $x^2 + y^2 = 17$. So simply substitution, $x^2  + (m(x-1)+ 4)^2 = 17 \implies m^2(x-1)^2 + 8m(x-1) + x^2 - 1 = 0$. 
Now I want to find the roots to get all the rational points but I'm not sure how one would get the roots of this equation. Stuck on the algebra. Would appreciate help.

REPLY [2 votes]: Note that if we can get all the solutions inside the first quadrant, we are done. 
Starting with the OP's two equations,
$\qquad y=m(x-1)+4$
and
$\qquad m^2(x-1)^2 + 8m(x-1) + x^2 - 1 = 0$
after factoring out $x - 1$ and employing some algebra, we can get all rationals on the 1st quadrant arc $(0,\sqrt 17) \text{ to } (\sqrt 17,0)$ in a bijective manner by taking $m \in \mathbb Q$ and belonging to the open interval
$\tag 1 m \in (-\frac{4}{\sqrt {17} -1},\; 4 - \sqrt {17})$
and mapping it
$\tag 2 x\text{-coordinate}(m) = 1 -\frac{(8m+2)}{(m^2+1)}$
Checking the validity of (2): For $m = -1/2$, we get $x$, and then solving for $y$, we find the solution $(\frac{13}{5}, \frac{16}{5})$.

Afterthought: The mapping (2) actually is all that is required to
  answer the question. When I started working on this I restricted
  attention to the first quadrant, but that only made things more
  complicated. It is interesting to see a bijective corresponce to the
  quadrant, but ...
Now, when using (2) for all real numbers $m$, you have to keep in mind
  that only one value of $y$ found by taking the square root strictly
  works, i.e. represents the intersection of the line on  the circle not
  equal to $(1,4)$. So you can describe a bijection again, but  the
  algorithm is a bit wordy:
"throw out the $y$ of the two found that does not work"
As a final geometric check of our algebra, note that as $m$ goes to
  $\pm\infty$, the $x\text{-coordinate}$ found with (2) goes to $1$, as
  expected (picture the lines drawn through $(1,4)$). In the same vein,
  just plug $m = 0$ into (2).


Here is the 'factoring' algebra that the OP was looking for:
$\quad m^2(x-1)^2 + 8m(x-1) + x^2 - 1 = 0 \text{ iff }$
$\quad m^2(x-1)^2 + 8m(x-1) + (x - 1)^2 + 2(x-1) = 0 \text{ iff }$
$\quad m^2(x-1) + 8m + (x - 1) + 2 = 0 \; \text{ or } x = 1 \text{ iff }$
$\quad (m^2 + 1)(x-1) + 8m +  2 = 0 \; \text{ or } x = 1$
So ignoring the $x = 1$ solution, we have
$\quad x = 1 - \frac{8m +  2}{m^2 + 1}$
which can also be expressed as $\frac{m^2 -8m -  2}{m^2 + 1}$, as demonstrated in Eric Towers' answer.