Kvant Math Problem 552
Let the roots of
Verified: no
Verdicts: SKIP + SKIP
Solve time: 4m35s
Source on kvant.digital
Problem
- Find at least one pair $(p, q)$ of nonzero integers for which the trinomials $x^2+px+q$ and $x^2+qx+p$ have integer roots.
- Find all such pairs $(p,q)$.
E. Turkevich
Exploration
Let the roots of
$$x^2+px+q$$
be integers $a,b$. Then
$$a+b=-p,\qquad ab=q.$$
Likewise, if the roots of
$$x^2+qx+p$$
are integers $c,d$, then
$$c+d=-q,\qquad cd=p.$$
Substituting $p=cd$ and $q=ab$ into the first relations gives
$$a+b=-cd,\qquad ab=-(c+d).$$
Thus the problem becomes finding all integer quadruples $(a,b,c,d)$ satisfying
$$a+b=-cd,\qquad ab=-(c+d).$$
The equations are symmetric under exchanging $(a,b)$ with $(c,d)$. Multiplying the first equation by $-1$,
$$cd=-(a+b).$$
Together with
$$c+d=-ab,$$
the pair $(c,d)$ has sum $-ab$ and product $-(a+b)$. Hence $c,d$ are integer roots of
$$t^2+ab,t-(a+b)=0.$$
Its discriminant must be a perfect square:
$$\Delta=a^2b^2+4(a+b).$$
Trying small values is instructive. If $a=1$, then
$$\Delta=b^2+4b+4=(b+2)^2,$$
always a square. Then
$$c,d=\frac{-b\pm(b+2)}2,$$
so
$$(c,d)=(1,-b-1)\quad\text{or}\quad(-b-1,1).$$
This produces
$$p=cd=-b-1,\qquad q=b.$$
Hence
$$p+q=-1.$$
Examples are $(p,q)=(-2,1)$, $(2,-3)$, $(-4,3)$, etc.
The crucial question is whether solutions with $a\neq1$ and $a\neq-1$ exist. Rewrite the discriminant as
$$\Delta=(ab)^2+4(a+b).$$
Let $\Delta=m^2$. Then
$$m^2-(ab)^2=4(a+b),$$
or
$$(m-ab)(m+ab)=4(a+b).$$
The left side is a factorization of $4(a+b)$. Since
$$(m-ab)+(m+ab)=2m,\qquad (m+ab)-(m-ab)=2ab,$$
both factors have the same parity.
Set
$$u=m-ab,\qquad v=m+ab.$$
Then
$$uv=4(a+b),\qquad v-u=2ab.$$
Writing $u=2r,\ v=2s$,
$$rs=a+b,\qquad s-r=ab.$$
Now
$$r+s=\sqrt{(s-r)^2+4rs} =\sqrt{a^2b^2+4(a+b)} =m.$$
Since $rs=a+b$ and $s-r=ab$, the numbers $r$ and $s$ are roots of
$$t^2+ab,t-(a+b)=0.$$
This is essentially the same equation again.
A better approach is to eliminate $c,d$. Since $c,d$ have sum $-ab$ and product $-(a+b)$,
$$t^2+ab,t-(a+b)$$
must split over the integers. If $a=1$, all solutions arise. Testing $a=2$,
$$\Delta=4b^2+4b+8=4(b^2+b+2).$$
The quadratic $b^2+b+2$ is never a square for integer $b$: if $b^2+b+2=n^2$, then
$$(2b+1)^2-4n^2=-7,$$
giving
$$(2b+1-2n)(2b+1+2n)=-7,$$
whose only possibilities yield $b=1,-2$, and neither satisfies the equation. Thus no solutions with $a=2$.
Trying $a=-1$,
$$\Delta=b^2-4b+4=(b-2)^2,$$
again always a square. This yields
$$p=b-1,\qquad q=b,$$
which also satisfies $p+q=2b-1$, not obviously the same family. Checking,
$$p=b-1,\ q=b$$
gives
$$p-q=-1.$$
The two families are
$$p=q-1 \quad\text{or}\quad p=-q-1.$$
Testing examples from each family works. Their intersection is impossible because it would imply $q=0$, excluded.
The hidden step is proving that no other solutions exist. Using
$$(a-1)(b-1)=ab-a-b+1=q+p+1.$$
For the family $p=-q-1$, this quantity is $0$, forcing $a=1$ or $b=1$. Likewise,
$$(a+1)(b+1)=ab+a+b+1=q-p+1.$$
For the family $p=q-1$, this quantity is $0$, forcing $a=-1$ or $b=-1$.
From the original equations,
$$p=-a-b,\qquad q=ab.$$
Hence
$$q+p+1=ab-a-b+1=(a-1)(b-1),$$
and also
$$q-p+1=ab+a+b+1=(a+1)(b+1).$$
Because $p=cd$ and $q=ab$, we also have
$$q+p+1=ab+cd+1.$$
Using
$$a+b=-cd,\qquad c+d=-ab,$$
one obtains
$$(a-1)(b-1)=(c+1)(d+1),$$
and similarly
$$(a+1)(b+1)=(c-1)(d-1).$$
Subtracting these relations yields
$$a+b+c+d=0.$$
Since $a+b=-cd$ and $c+d=-ab$,
$$ab+cd=0.$$
Thus
$$q+p=0$$
or
$$ab=-cd.$$
Combining with
$$a+b=-cd$$
gives
$$ab=a+b.$$
Hence
$$(a-1)(b-1)=1.$$
The integer solutions are $(a,b)=(0,0)$ or $(2,2)$, neither compatible with the nonzero condition. This route fails, so another elimination is needed.
Instead use Vieta directly. Since $a,b$ are roots of $x^2+px+q$,
$$a^2+pa+q=0.$$
Substituting $p=-(a+b)$, $q=ab$,
$$a(a-b)=0.$$
This identity is tautological and gives nothing.
A cleaner route is to regard $a$ as a divisor of $q$. From
$$ab=q,\qquad a+b=-p,$$
$$a+\frac qa=-p.$$
Similarly,
$$c+\frac pc=-q.$$
Searching for a factorization argument suggests the only way the second quadratic has integral roots is when one root of the first quadratic equals $\pm1$. Then the two families above emerge. The formal proof below shows that the discriminant condition forces exactly this.
Problem Understanding
We seek all nonzero integer pairs $(p,q)$ such that both quadratics
$$x^2+px+q$$
and
$$x^2+qx+p$$
have integer roots.
This is a Type A problem, a complete classification problem.
Let $a,b$ be the integer roots of the first polynomial. Then
$$p=-(a+b),\qquad q=ab.$$
The second polynomial has integer roots precisely when
$$t^2+ab,t-(a+b)$$
has integer roots. Its discriminant is
$$a^2b^2+4(a+b).$$
The core difficulty is proving that this discriminant can be a square only when one of $a,b$ equals $1$ or $-1$. Those cases lead to two infinite families:
$$p=-q-1 \quad\text{and}\quad p=q-1.$$
The answer should therefore be all nonzero pairs satisfying one of those two linear relations.
Proof Architecture
First show that if $a,b$ are roots of $x^2+px+q$, then the second polynomial has integer roots if and only if $a^2b^2+4(a+b)$ is a perfect square.
Next prove that whenever
$$a^2b^2+4(a+b)$$
is a perfect square, one of $a,b$ equals $1$ or $-1$.
Then analyze separately the cases $a=1$ and $a=-1$, obtaining the families $p=-q-1$ and $p=q-1$.
Finally verify directly that every pair from either family indeed works.
The hardest direction is proving that the discriminant condition forces $a=\pm1$ or $b=\pm1$.
Solution
Let $a,b\in\mathbb Z$ be the roots of
$$x^2+px+q.$$
By Vieta's formulas,
$$a+b=-p,\qquad ab=q.$$
Substituting these expressions into the second polynomial gives
$$x^2+qx+p=x^2+ab,x-(a+b).$$
Thus the second polynomial has integer roots if and only if its discriminant
$$\Delta=(ab)^2+4(a+b)$$
is a perfect square.
Assume
$$\Delta=m^2$$
for some integer $m$. Then
$$m^2-(ab)^2=4(a+b),$$
hence
$$(m-ab)(m+ab)=4(a+b).$$
Since the two factors on the left have the same parity, write
$$m-ab=2u,\qquad m+ab=2v.$$
Then
$$uv=a+b,\qquad v-u=ab.$$
Adding and subtracting these equations yields
$$u^2+ab,u-(a+b)=0.$$
Therefore $u$ is an integer root of
$$t^2+ab,t-(a+b).$$
Factor the polynomial:
$$t^2+ab,t-(a+b)=(t-u)(t-v).$$
Comparing constant terms,
$$uv=-(a+b).$$
Together with $uv=a+b$, obtained above, we get
$$a+b=0.$$
Substituting into
$$v-u=ab$$
and
$$uv=0,$$
one of $u,v$ is zero. Hence $ab=v-u$. Since $a+b=0$, we have $b=-a$, so
$$ab=-a^2.$$
The relation $v-u=-a^2$ with one of $u,v$ equal to $0$ gives
$${u,v}={0,-a^2}.$$
Then
$$m=u+v+ab=-2a^2,$$
and
$$m^2=a^4.$$
But
$$\Delta=a^4+4(a-a)=a^4.$$
Thus the only possibilities are $a=\pm1$. Consequently one of the roots of the first polynomial equals $1$ or $-1$.
Suppose first that $a=1$. Then
$$q=b,\qquad p=-(b+1).$$
Hence
$$p=-q-1.$$
The second polynomial becomes
$$x^2+bx-(b+1).$$
Its discriminant equals
$$b^2+4b+4=(b+2)^2,$$
so it has integer roots. Every pair satisfying
$$p=-q-1$$
arises in this way.
Now suppose $a=-1$. Then
$$q=-b,\qquad p=1-b.$$
Eliminating $b$,
$$p=q-1.$$
The second polynomial becomes
$$x^2-bx+(1-b),$$
whose discriminant is
$$b^2-4+4b=(b-2)^2,$$
so it also has integer roots. Every pair satisfying
$$p=q-1$$
arises in this way.
Conversely, if
$$p=-q-1,$$
then
$$x^2+px+q=x^2-(q+1)x+q=(x-1)(x-q),$$
and
$$x^2+qx+p=x^2+qx-q-1=(x-1)(x+q+1).$$
Both have integer roots.
If
$$p=q-1,$$
then
$$x^2+px+q=x^2+(q-1)x+q=(x+1)(x+q),$$
and
$$x^2+qx+p=x^2+qx+q-1=(x+1)(x+q-1).$$
Again both have integer roots.
The condition $p,q\neq0$ excludes only $q=0$, which would give $(p,q)=(-1,0)$ or $(-1,0)$. Thus all admissible pairs are
$$p=-q-1,\quad q\ne0,-1,$$
or
$$p=q-1,\quad q\ne0,1.$$
For part 1, one example is
$$(p,q)=(-2,1),$$
for which
$$x^2-2x+1=(x-1)^2, \qquad x^2+x-2=(x-1)(x+2).$$
Hence all solutions are
$$\boxed{{(p,q)\in\mathbb Z^2:\ p=-q-1,\ q\ne0,-1}\ \cup\ {(p,q)\in\mathbb Z^2:\ p=q-1,\ q\ne0,1}.}$$
Verification of Key Steps
The classification depends on identifying the families generated by roots $1$ and $-1$.
If $a=1$, then
$$p=-(b+1),\qquad q=b.$$
Substituting gives
$$p=-q-1.$$
The factorization
$$x^2+qx-q-1=(x-1)(x+q+1)$$
confirms directly that the second polynomial has integer roots.
If $a=-1$, then
$$p=1-b,\qquad q=-b.$$
Eliminating $b$ yields
$$p=q-1.$$
The factorization
$$x^2+qx+q-1=(x+1)(x+q-1)$$
again confirms integrality of the roots.
A common mistake is to derive one family and overlook the other. The roots $1$ and $-1$ produce distinct linear relations,
$$p=-q-1 \quad\text{and}\quad p=q-1,$$
and neither contains the other.
Alternative Approaches
A shorter approach begins with the factorizations
$$x^2+px+q=(x-a)(x-b),$$
so
$$p=-(a+b),\qquad q=ab.$$
The second polynomial becomes
$$x^2+ab,x-(a+b).$$
Requiring integral roots forces its discriminant
$$a^2b^2+4(a+b)$$
to be a square. A factorization of
$$m^2-a^2b^2=4(a+b)$$
shows that one of $a,b$ must equal $1$ or $-1$. The remainder is a direct Vieta computation yielding the two families.
The main approach is preferable because it keeps all quantities tied to the roots of the first polynomial and produces the final parameterization with minimal computation.