# Is there the number a, b, c, d, m so that the equation has four integer solutions?

I am trying to find the integer numbers a, b, c, d, m so that the equation $$(x-a) (x-b) (x-c) (x-d) =m$$ where $$a + d = b + c$$ and $$m \neq 0$$ has four integer solutions.

I see here and here and tried

poly = (x - p) (x - q) (x - r) (x - s) + m;
eqn = p + s == q + r;
sol = FindInstance[
eqn && -10 < p < q < r < s < 10 && p + q + r + s != 0, {p, q, r, s, m}, Integers, 3]


I got

{{p -> -2, q -> 2, r -> 5, s -> 9, m -> -676}, {p -> -8, q -> -3, r -> 2, s -> 7, m -> 362}, {p -> -9, q -> -7, r -> -5, s -> -3, m -> -31}}

An example

Solve[(x + 9) (x + 7) (x + 5) (x + 3) - 31 == 0, x]


I got

{{x -> -6 - I Sqrt[-5 + Sqrt[47]]}, {x -> -6 + I Sqrt[-5 + Sqrt[47]]}, {x -> -6 - Sqrt[5 + Sqrt[47]]}, {x -> -6 + Sqrt[5 + Sqrt[47]]}}

This is not integral roots.

UPDATE it is difficult for me to find equations that have four integer solutions like these: $$x (2 + x) (11 + x) (13 + x) = 504,$$ and $$(x-5) (x-3) (x+6) (x+8)=504\,.$$

• You are right. I tried like that. It does not solve my question. – minhthien_2016 Feb 17 at 3:23
• I mean the equation x (2 + x) (11 + x) (13 + x) == 504, x] prove that, my question exist. – minhthien_2016 Feb 17 at 3:43
• Thank you very much. – minhthien_2016 Feb 17 at 4:07
• Can't you just translate the solution from Mapleprimes? – Michael E2 Feb 17 at 17:46
• Via translation, you may assume wlog that $a=0$ (as witnessed by your two $m=504$ examples) – Hagen von Eitzen Feb 17 at 17:46

Editon

result1 =
FindInstance[{Apply[Times, t - {b - e, b, c, c + e}] == m, e > 0,
b < c, m != 0}, {t, b, c, e, m}, Integers, 1000];
result2 = Apply[Times, x - {b - e, b, c, c + e}] == m /. result1;
result3 = Select[result2, Length[Solve[#, x, Integers]] == 4 &];
result4 = {#, Solve[#, x, Integers]} & /@ result3;
TextGrid[result4, Frame -> All]


Original

We set $$b-a=d-c=e>0$$,and set $$b, then we solve $$(t-a)(t-b)(t-c)(t-d)=m$$ ,here we assume that all of $$b,c,e,t$$ are integers, so such equations have at least one integers solution.

After that we select the equations which exactly have 4 integers solutions from above equations.

m = 180;
result1 =
FindInstance[{Apply[Times, t - {b - e, b, c, c + e}] == m, e > 0,
b < c, Alternatives[{t, b, c, e}] ∈ Integers}, {t, b, c,
e}, Integers, 100];
result2 = Apply[Times, x - {b - e, b, c, c + e}] == m /. result1;
result3 = Select[result2, Length[Solve[#, x, Integers]] == 4 &];
result4 = {#, Solve[#, x, Integers]} & /@ result3;
TextGrid[result4, Frame -> All]


• Where can I put Thread[-10 <= {d1, d2, m, x0} <= 10]? – minhthien_2016 Feb 17 at 2:11
• @minhthien_2016 Have updated the answer. – cvgmt Feb 17 at 2:17
• One question, how can I find the number 180? – minhthien_2016 Feb 18 at 7:23
• @minhthien_2016 see the updated. – cvgmt Feb 18 at 8:03

Try this:

FindInstance[
{(x - a) (x - b) (x - c) (x - d) == m,
a + d == b + c,
a < b < c < d,
{a, b, c, d, m, x} ∈ Integers},
{a, b, c, d, m, x}, 10
]

(* Out:
{{a -> 44, b -> 96, c -> 97, d -> 149, m -> 305331900, x -> -41},
{a -> 281, b -> 390, c -> 418, d -> 527, m -> 25162167780, x -> -4},
{a -> 597, b -> 662, c -> 663, d -> 728, m -> 139132605096, x -> 50},
{a -> 859, b -> 908, c -> 959, d -> 1008, m -> 709598061900, x -> 14},
{a -> -30, b -> 24, c -> 26,d -> 80, m -> -1834560, x -> -4},
{a -> 628, b -> 732, c -> 748, d -> 852, m -> 247761920016, x -> 30},
{a -> 667, b -> 791, c -> 792, d -> 916, m -> 336075509484, x -> 25},
{a -> 26, b -> 58, c -> 60, d -> 92, m -> 49040640, x -> -28},
{a -> 33, b -> 126, c -> 127, d -> 220, m -> 122147584, x -> -1},
{a -> 53, b -> 54, c -> 55, d -> 56, m -> 1413720, x -> 20}}
*)


My first, deleted answer is garbage since I misunderstood the question. Hopefully, this answer is not a waste of bandwidth.

Consider the quartic equation $$(x-a)(x-b)(x-c)(x-d)=m$$, where $$\{a,b,c,d,m\}$$ are integers. We are looking for values of $$\{a,b,c,d,m\}$$ such that there are four distinct integer solutions $$x_i=\{x_1,x_2,x_3,x_4\}$$. Imposing the constraint $$a+d=b+c$$ reduces the search to the four integers $$\{a,b,c,m\}$$.

The solution for $$x_i$$ with the constraint $$a+d=b+c$$ is as follows. Note that without the constraint, the solution is far, far more complicated.

FullSimplify[Solve[(x - a)(x - b)(x - c)(x - (b + c - a)) == m, x]]


The argument inside the outer square root admits a simplification.

Simplify[2 a^2 + b^2 + c^2 - 2 a (b + c) - ((a - b)^2 + (a - c)^2)]


0

In addition, make the substitution $$r=a-b$$ and $$s=a-c$$. The general form for the four solutions $$x_i$$ of the constrained quartic is a remarkably simple result!

$$x\rightarrow \frac{1}{2} (b + c \pm \sqrt{r^2 + s^2 \pm 2 \sqrt{r^2 s^2 + 4 m}})$$

where the $$\pm$$ signs are independent.

For the solutions $$x_i$$ to be real, the arguments of the square roots must be non-negative. Define integers $$\{y,w,z\}$$ such that $$y^2=r^2 s^2+4m$$, $$w^2=r^2+s^2-2y$$, and $$z^2=r^2+s^2+2y$$.

These definitions determine the four solutions as $$x_i=(b+c+\{-w,w,-z,z\})/2$$.

Adding gives $$w^2+z^2=2(r^2+s^2)$$, where the right-hand side is known in terms of the given $$\{a,b,c\}$$. Therefore, represent $$2(r^2+s^2)$$ as the sum of the squares of two distinct positive integers $$w$$ and $$z$$, then form the four solutions $$x_i$$. The corresponding value of $$m=((w^2-z^2)^2-16r^2 s^2)/64$$.

PrimitiveSumTwoSquares and SquareDivisors are helper routines for SumTwoSquares.

PrimitiveSumTwoSquares[n_] :=
Block[{r, a, s},
If[(r = PowerModList[-1, 1/2, n]) == {}, {},
Table[
a = n;
s = r[[i]];
While[a^2 >= n, {s, a} = {a, Mod[s, a]}];
{Mod[s, a], a},
{i, Length[r]/2}]
]]

SquareDivisors[n_] :=
Sort[Flatten[
Outer[Times, Sequence @@ Map[#[[1]]^Range[0, #[[2]], 2] &, FactorInteger[n]]]]]


SumTwoSquares[n] finds primitive and non-primitive representations $$\{w,z\}$$ of $$n=w^2+z^2$$ for positive $$w$$ and $$z$$ with $$w.

SumTwoSquares[n_] :=
Flatten[Table[
Sqrt[d]*PrimitiveSumTwoSquares[n/d], {d, SquareDivisors[n]}], 1]


Given $$\{a,b,c\}$$, quarticSolution[{a,b,c}] returns valid $$\{a,b,c,d,m,\{x_1,x_2,x_3,x_4\}\}$$ with non-zero $$m$$.

quarticSolution[{a_, b_, c_}] :=
Block[{d, r, s, wz, mxi},
d = b + c - a;
r = a - b;
s = a - c;
wz = SumTwoSquares[2 (r^2 + s^2)];
mxi =
Map[{
((#[[1]]^2 - #[[2]]^2)^2 - 16 r^2 s^2)/64,
((b + c) + {-#[[1]], #[[1]], -#[[2]], #[[2]]})/2} &, wz];
Map[Join[{a, b, c, d}, #] &, DeleteCases[mxi, {0, _}]]
]


m2016[k] returns $$\{a,b,c,d,m,\{x_1,x_2,x_3,x_4\}\}$$ such that $$-k, where $$d=b+c-a$$.

A solution $$x_i$$ corresponding to $$\{a,b,c,d\}$$ is essentially the same as the solution $$-x_i$$ corresponding to $$-\{d,c,b,a\}$$. Use DeleteDuplicates to eliminate these redundant cases.

m2016[k_] :=
Block[{v},
v = Flatten[Table[
{a, b, c},
{a, -k + 1, k - 4},
{b, a + 1, k - 3},
{c, b + 1, Min[k - 2, a - b + k - 1]}], 2];
SortBy[
DeleteDuplicates[
Flatten[Map[quarticSolution, v], 1],
Sort[Last@#1] == Sort[-Last@#2] &],
#[[5]] &]
]


For example,

m2016[8]


{{-7, -1, 0, 6, -360, {-4, 3, -6, 5}}, {-7, -3, 0, 4, -180, {-5, 2, -6, 3}}, {-6, -2, 1, 5, -180, {-4, 3, -5, 4}}, {-7, -6, 1, 2, 180, {-4, -1, -8, 3}}, {-6, -5, 2, 3, 180, {-3, 0, -7, 4}}, {-5, -4, 3, 4, 180, {-2, 1, -6, 5}}, {-7, -5, 2, 4, 360, {-2, -1, -8, 5}}, {-6, -4, 3, 5, 360, {-1, 0, -7, 6}}, {-7, -5, 4, 6, 504, {-3, 2, -8, 7}}, {-7, -4, 4, 7, 720, {-1, 1, -8, 8}}, {-7, -6, 5, 6, 1260, {-1, 0, -9, 8}}, {-7, -6, 6, 7, 1440, {-2, 2, -9, 9}}}

Pick solutions with a given $$m$$.

Pick[#, #[[All, 5]], 504] &[m2016[15]]


{{-14, -12, -3, -1, 504, {-10, -5, -15, 0}}, {-13, -11, -2, 0, 504, {-9, -4, -14, 1}}, {-12, -10, -1, 1, 504, {-8, -3, -13, 2}}, {-11, -9, 0, 2, 504, {-7, -2, -12, 3}}, {-10, -8, 1, 3, 504, {-6, -1, -11, 4}}, {-9, -7, 2, 4, 504, {-5, 0, -10, 5}}, {-8, -6, 3, 5, 504, {-4, 1, -9, 6}}, {-7, -5, 4, 6, 504, {-3, 2, -8, 7}}}

It works reasonably fast.

AbsoluteTiming[Length[m2016[20]]]


{2.41968, 798}

• @KennyColnago Thank you very much. Now Close(2) – minhthien_2016 Feb 19 at 0:09
• Thanks @MichaelE2, for the comments correcting this post and for your many other answers. I made an edit to explicitly state that PrimitiveSumTwoSquares and SquareDivisors are subfunctions called by SumTwoSquares. I hope that clears up the (my) confusion on this question. Of course, SumTwoSquares may be replaced by an equivalent Reduce command, but I am avoiding such built-in functions, which tend to slow things down. – KennyColnago Feb 19 at 2:17
• You are most welcome @minhthien_2016. This question was quite an interesting challenge. – KennyColnago Feb 19 at 2:18
• Sorry about the confusion. I think that when I copied the code, I accidentally skipped over the code for SumTwoSquares[] and thought that you had made an editing mistake. My bad. – Michael E2 Feb 19 at 4:08
• @KennyColnago Can this equation a^2 *x^2/(x-a)^2 + x^2 = m/n=0, wheere a, m, nare integers number has four integer solutions? – minhthien_2016 Feb 21 at 11:27