# How many $ax^2+bx+c=0$ with distinct pairs of rational roots can be made from integers $N=|ac|=|\alpha\beta|$ and $b=\alpha+\beta$?

Only for illustration, let's choose an integer $$N=6$$. I want to create a collection of all possible quadratic equations in the form of $$ax^2+bx+c=0$$ where

• $$|ac|=|\alpha\beta|=N=6$$, and
• $$\alpha+\beta=b$$.

Note that all constants are integers but $$x$$ is not necessarily integer.

Here is my attempt.

# How many ways to specify $$a$$ and $$c$$

The prime factors of $$N$$ is $$P=\{2,3\}$$

The all possible pairs of $$(a,c)$$ are $$\{(1,\pm 6), (6,\pm 1), (2,\pm 3), (3,\pm 2)\}$$ Here I don't need to consider the case in which $$a<0$$ because, for example, $$6x^2+5x-1=0$$ is actually identical to $$-6x^2-5x+1=0$$. Only the sign of $$b$$ and $$c$$ do matter here. From $$2^2=4$$ subsets of $$P$$, we can create $$\frac{2^2}{2}=2$$ "partitions", each "partition" can be assigned to $$(a,c)$$ in $$2!=2$$ ways, and $$c$$ can have two choice of signs. Thus there are $$\frac{2^2}{2}\times 2! \times 2 = 8$$ ways to create $$(a,c)$$.

# How many ways to specify $$b$$

The all possible pairs of $$(\alpha,\beta)$$ are $$\{(\pm 1,\pm 6), (\pm 2,\pm 3)\}$$

Therefore the all possible values of $$b$$ are $$\{\pm |1+6|, \pm |1-6| = \pm |2+3|, \pm |2-3|\} = \{\pm 7, \pm 5, \pm 1 \}$$

I cannot find an easier way to calculate how many possible ways to determine $$b$$ because the same $$b$$ can be obtained from two (or possibly more) "partitions". For example, partition $$\{1,6\}$$ and $$\{2,3\}$$ can produce $$b=\pm 5$$ as follows. $$\pm |1-6| = \pm |2+3|$$

As we can see, there are $$3\times 2=6$$ ways to assign $$b$$.

# Final

Thus in total, we have $$8\times 6=48$$ quadratic equations. I have not checked programmatically whether all of these equations have distinct pair of roots.

# Question

Generally speaking, for any positive integer $$N$$, how many quadratic equations (with the constraints given above) are possible to make?

• I guess $a$, $b$, $\alpha$, and $\beta$ should be integers. – Alex Ravsky Sep 18 '20 at 0:09
• It seems to me that you are not saying that $a,b,c,\alpha,\beta$ are integers. If $a,b,c,\alpha,\beta$ are not necessarily integers, then there are infinitely many such quadratic equations. Take $(a,b,c,\alpha,\beta)=\left(\sqrt{\frac{4N}{2m-1}},ma,\frac Na,\frac{b-\sqrt{b^2+4N}}{2},\frac{b+\sqrt{b^2+4N}}{2}\right)$ where $m$ is a rational number larger than $1$. This satisfies $|ac|=|\alpha\beta|=N$ and $\alpha+\beta=b$, and the roots of $ax^2+bx+c=0$ are $x=-\frac 12,\frac{1-2m}{2}$. – mathlove Sep 19 '20 at 5:53
• @AlexRavsky: Yes. They are integers as shown in my attempt. – Artificial Stupidity Sep 19 '20 at 6:53
• @mathlove: They are integers, except for $x$ that is not necessarily integer. – Artificial Stupidity Sep 19 '20 at 6:55

This answer deals with $$N$$ such that $$N\not\equiv 0\pmod 3$$.

This answer proves that the number of such quadratic equations is $$\begin{cases}2\sigma_0(N)^2&\text{if N is not a square number with N\not\equiv 0\pmod 3} \\\\\sigma_0(N)(2\sigma_0(N)-1)&\text{if N is a square number with N\equiv 1\pmod 3}\end{cases}$$ where $$\sigma_0(N)$$ is the number of the positive divisors of $$N$$.

Proof :

We may suppose that $$a\gt 0$$.

Note that $$ax^2+bx+c=0$$ has two distinct rational roots if and only if $$b^2-4ac$$ is a non-zero square number.

Also, let $$\sigma_0(N)$$ be the number of the positive divisors of $$N$$.

($$\sigma_0(N)=\displaystyle\prod_{k=1}^{d}(e_k+1)$$ when $$N=\displaystyle\prod_{k=1}^{d}p_k^{e_k}$$ where $$p_1,p_2,\cdots,p_k$$ are distinct prime numbers.)

• Case 1 : $$ac=\alpha\beta$$

Since we have $$b^2-4ac=(\alpha+\beta)^2-4\alpha\beta=(\alpha-\beta)^2$$, we see that $$ax^2+bx+c=0$$ has two distinct rational roots if and only if $$\alpha\not=\beta$$.

If $$\alpha\beta=\alpha'\beta',\alpha'\not=\alpha$$ and $$\alpha'\not=\beta$$, then $$\small\alpha+\beta-(\alpha'+\beta')=\alpha+\beta-\alpha'-\frac{\alpha\beta}{\alpha'}=\frac{(\alpha-\alpha')(\alpha'-\beta)}{\alpha'}\not=0\implies \alpha+\beta\not=\alpha'+\beta'\tag1$$Case 1-1 : $$ac=\alpha\beta=N$$

The number of $$(a,c)$$ is given by $$\sigma_0(N)$$ since $$a$$ is positive.

If $$N$$ is not a square number, then the number of $$(\alpha,\beta)$$ is given by $$2\sigma_0(N)$$. Since $$b=\alpha+\beta$$ is symmetric, it follows from $$(1)$$ that the number of $$b$$ is given by $$\sigma_0(N)$$. So, the number of such quadratic equations is $$\sigma_0(N)^2$$.

If $$N$$ is a square number, then the number of $$(\alpha,\beta)$$ is given by $$2(\sigma_0(N)-1)$$ since the case where $$\alpha=\beta$$ has to be excluded. Since $$b=\alpha+\beta$$ is symmetric, it follows from $$(1)$$ that the number of $$b$$ is given by $$\sigma_0(N)-1$$. So, the number of such quadratic equations is $$\sigma_0(N)(\sigma_0(N)-1)$$.

Case 1-2 : $$ac=\alpha\beta=-N$$

The number of $$(a,c)$$ is given by $$\sigma_0(N)$$ since $$a$$ is positive.

If $$N$$ is not a square number, then the number of $$(\alpha,\beta)$$ is given by $$2\sigma_0(N)$$. Since $$b=\alpha+\beta$$ is symmetric, it follows from $$(1)$$ that the number of $$b$$ is given by $$\sigma_0(N)$$. So, the number of such quadratic equations is $$\sigma_0(N)^2$$.

If $$N$$ is a square number, then the number of $$(\alpha,\beta)$$ is given by $$2\sigma_0(N)$$ since the case where $$\alpha=\beta$$ does not happen. Since $$b=\alpha+\beta$$ is symmetric, it follows from $$(1)$$ that the number of $$b$$ is given by $$\sigma_0(N)$$. So, the number of such quadratic equations is $$\sigma_0(N)^2$$.

• Case 2 : $$ac=-\alpha\beta=\pm N$$

For $$N$$ such that $$N\not\equiv 0\pmod 3$$, we have \begin{align}-\alpha\beta=\pm N&\implies (\alpha,\beta)\equiv (1,1),(1,2),(2,1),(2,2)\pmod 3 \\\\&\implies b^2-4ac=(\alpha+\beta)^2+4\alpha\beta\equiv 2\pmod 3\end{align}So, $$b^2-4ac$$ cannot be a square number.

Hence, it follows from the above cases that the number of such quadratic equations is $$\begin{cases}2\sigma_0(N)^2&\text{if N is not a square number with N\not\equiv 0\pmod 3} \\\\\sigma_0(N)(2\sigma_0(N)-1)&\text{if N is a square number with N\equiv 1\pmod 3}\end{cases}$$ where $$\sigma_0(N)$$ is the number of the positive divisors of $$N$$.