# Which quadratic equations with integer coefficients have rational roots?

$$ax^2+bx+c=0$$

How to choose $a$, $b$, $c$ so that the solutions of the quadratic equation are rational, $x_{1,2}\in\mathbb Q$ ?
$(a,b,c\in\mathbb Z\ne0)$

Surely, that's the case if and only if the $D$ is a square number.

Since $D = b^2-4ac = d^2$, I went to find the differences between $2$ squares which are divisible by $4$ and found out that by picking any integer $b$, then $a$, $c$ can be picked as any two integers that satisfy the following conditions (where $k$ is used to represent $b$, and $n$ can be any valid integer as the conditions state):

$$b=2k, k\in\mathbb N \\ a\times c = -(n-k)(n+k) \\ n\in\mathbb Z, n\ge0, n\ne k \\ \ \\ b=2k-1, k\in\mathbb N \\ a\times c = -n(n+b) \\ n\in\mathbb Z, n\ge-k, n\ne 0$$

For a chosen $b$ depending if it's even or odd, we can first chose $n$, and then choose $a$ and $c$ as any combination satisfying the given conditions. If $a$, $b$, $c$ are chosen this way, the roots of the coresponding equation will always be rational.

Each set of solutions $(a,b,c)$ given this way can be of course multiplied by any integer $\ne0$ to give a "new" sets of solutions which will all have of course the same roots as the original set.

I believe that if I haven't made a mistake, that these conditions can solve my initial question and can produce all valid sets of $(a,b,c)$.

My question is firstly if I'm wrong, to be corrected, otherwise/then how would one combine such conditions so that we can generate all sets of $(a,b,c)$ ?
Since there are $\infty$ many solutions we can't simply write them down but rather a way to generate them.
(Of course we can omit cases which produce the same two roots as a previous case)

All in all, I'm specificly asking for the answer to the first question below the title and the rest is basically my thoughts and the progress I managed to make so far.

• this is kinda half-solved... you can't say that answer is any (a,c) that satisfy something... why not say the answer is any (a,b,c) that is "satisfying the given condition" that ax^2=bx+c have rational roots. If you are asking if your solution is correct then the answer is "that is not even a solution!" – Kazz Dec 12 '16 at 14:58
• @Kazz I think you missunderstood my statement. I said that solutions are any $(a,b,c)$ given by those conditions. And these conditions describe on how to exactly generate all valid sets of $(a,b,c)$, if I haven't missed anything. But the problem is on how to generate them without the need of picking all the valid combinations of $k,b,c,n$ one by one but rather have something like a generating formula. Unless they dont provide a complete range of all solutions in which case they need to be expanded. – Vepir Dec 12 '16 at 16:16
• What do you mean by generate? To generate all even number you can do as follow: "take all Integer numbers $n$ and for each calculate $2\cdot n$ you can't do this like "do something ,check if condition, add or not add" – Kazz Dec 12 '16 at 16:26
• I'm thinking about it but can figure out from were should we start. There is a fact that if $x_0$ is a rational solution then it $x_0 = {p \over q}$ where $p|c$ and $q|a$ however there is not simple reversed implication. That is gonna lead us to factorization and stuff like that. – Kazz Dec 12 '16 at 16:30
• lol, sorry i just noticed $a,b,c \in \Bbb Z$ xD – Kazz Dec 12 '16 at 16:42

Hint:

These equations factor as

$$a(x-p)(x-q)=a(x^2-(p+q)x+pq)=0$$ where $p,q$ are rational. Take any rationals such that $apq$ is an integer.

More specifically, consider all factorizations $a=a_0a_1$ and let $p=m/a_0,q=n/a_1$.

The coefficients are

$$a,-(ma_1+na_0),mn.$$

But there are duplicates.

• May I ask how could one prove that these coefficients not just produce only quadratic equations with rational roots but also account for all quadratic equations with only rational roots? – Vepir Dec 12 '16 at 17:45
• @Matta: it suffices for you to show me an equation with two rational roots which cannot be expressed as $a(x-p)(x-q)=0$. – Yves Daoust Dec 12 '16 at 19:52
• @Matta the only possible rational roots are ${l \over k}$ such that $l|c$ and $k|a$. Yves considered all factorization of $a$ and all $c$ that can be represented as a product of 2 integer numbers (so every possible integer). – Kazz Dec 13 '16 at 16:20
• @Matta in different words. He chooses any integers $a_1a_2mn$ such that $a_1a_0 = a$,$mn=c$,(b is not relevant here) and considers roots $x_1={m \over a_0}$$x_2={n \over a_1}$ and according to the property i mention above those are the only possibilities. – Kazz Dec 13 '16 at 16:29