# Find all $q\in\mathbb{Q}$ such that $qx^2+(q+1)x+q=1$ has integer solutions.

Find all $q\in\mathbb{Q}$ such that equation $$qx^2+(q+1)x+q=1$$ has integers as solutions.

I tried solving it for $x$ ($q\ne0$) and stating $\sqrt{D}=\sqrt{-3q^2+6q+1}$ has to be rational, so $-3q^2+6q+1$ has to be "perfect" square, which means $-3q^2+6q+1=a^2$ where $a\in\mathbb{Q}$. This gives me $|a|\leq2$, but this still doesn't help much since $a$ could be any rational number between $-2$ and $2$. Can I argue that $a$ has to be integer (and then just do three possible cases), or I'm doing it the wrong way?

-
I think your condition on the rationality of $\sqrt D$ is not sufficient. The condition ought to be $2q|(-(q+1)+-\sqrt D)$. And this is not the same as the rationality of $\sqrt D$. – awllower Feb 7 '13 at 13:42
Ah, yes, but it is necessary and I don't know how to elaborate it, so I was stuck there. I was about to go on to the other condition as well. – Lazar Ljubenović Feb 7 '13 at 13:49
It turns out that to solve explicitly for $x$ is a rather long way... – awllower Feb 7 '13 at 13:50
When you say "has integer solutions," do you mean for what $q$ are both roots integers? Because I think you can easily show that the $q$ must be an integer if both roots have to be integers. – Thomas Andrews Feb 7 '13 at 14:06
I need to find $q\in\mathbb{Q}$ such that both roots are integers. It would be great help if you could show me how to prove that $q$ has to be integer as well... – Lazar Ljubenović Feb 7 '13 at 14:12

If $q=0$, the equation becomes $x=1$, so $q=0$ works.

Otherwise $q \not =0$, so dividing by $q$ gives $0=x^2+\frac{q+1}{q}x+\frac{q-1}{q}=x^2+(1+\frac{1}{q})x+(1-\frac{1}{q})$.

Since the solutions have to be integral, $(1+\frac{1}{q}) \in \mathbb{Z}$, so $q=\frac{1}{n}$ for some $n \in \mathbb{Z}$.

We get $0=x^2+(1+n)x+(1-n)$, so $x=\frac{-(1+n) \pm \sqrt{n^2+6n-3}}{2}$, so $n^2+6n-3=m^2$ for some $m \in \mathbb{Z}$. Thus $12=(n+3)^2-m^2=(n+3-m)(n+3+m)$.

$(n+3-m), (n+3+m)$ have the same parity, so they are both even. We have a few possiblities: $(n+3-m, n+3+m)=(2, 6), (6, 2), (-2, -6), (-6, -2)$.

Thus $(n, m)=(1, 2), (1, -2), (-7, -2), (-7, 2)$, so $n=1, -7$, so $q=1, -\frac{1}{7}$.

In conclusion, $q=0, 1, -\frac{1}{7}$.

-

Suppose $\,n,m\in\Bbb Z\,$ are the solutions, then by Viete's formulae:

$$nm=\frac{q-1}{q}\;\;,\;\;n+m=-\frac{q+1}{q}$$

There aren't, I think, many options...

-
So in fact $(q-1)/q$ should be integer, and so does $(q+1)/q$. Consequently $2/q$ is an integer $=k$.Then $q=2/k$, showing that $(2-k)/2$ is an integer, viz. $2|k$. So $q$ is of the form $1/n$ for some integer $n$. Thus we deduce that $n$ divides $n-1$, i.e. $n$ divides $1$. So $n$ is either $1$ or $-1$. Are there any errors? Thanks for the answer in any case. – awllower Feb 7 '13 at 13:48
But $q\in\mathbb{Q}$. This means $q$ could be $1/n$, $n\in\mathbb{N}$, and $(q\pm 1)/q$ becomes $1\pm n$, which is always integer. Or I'm missing some point? – Lazar Ljubenović Feb 7 '13 at 13:55