# Using Reduce over integers produces weird result

Using Reduce to solve $$x^2(1+x)=y(3y-1)$$, over integers should yield

$$(x, y) = (-1,0),(0,0),(1,1),(4,-5),(6,-9)$$

However, when I enter

  Reduce[x^2*(1 + x) == y*(-1 + 3*y), {x, y}, Integers]


The result is

$$(x|y)\in \mathbb{Z}\land x\geq -1\land \left(y=\frac{1}{6}-\frac{1}{6} \sqrt{12 x^3+12 x^2+1}\lor y=\frac{1}{6} \sqrt{12 x^3+12 x^2+1}+\frac{1}{6}\right)$$

Granted, one can work with this and figure out the results, but why does it not produce them since there are not an infinite number? Is there some way to take this result and post-process it to get actual integers?

As a comparison, see the result from Wolfram Alpha.

• It seems that WolframAlpha either uses more advanced algorithms, or resorts to cheap heuristics like imposing Abs[x]+Abs[y]<10^5 condition on the equation. – aooiiii Jan 14 '20 at 17:43
• I did a little investigation, and turns out that yes, WolframAlpha uses heuristics. Replacing x and y with x+100 and y+100 respectively makes it miss one root, and when translating by numbers greater than 1000, WolframAlpha can only find a single solution. – aooiiii Jan 14 '20 at 18:21

Regarding the title of the question, is the result of Reduce really odd? Reduce simply reduces systems of equations, inequalities, domain specifications, logical expressions etc. And so it is not too odd.

Quite frequently we get similar expressions in the output. A natural suggestion is to reformulate the input since there are two variables $$x$$ and $$y$$ while we have the only one equation and so in general there is a continuum (a submanifold) of solutions, even in integers one might expect infinitiely many solutions, although the latter is not the case here.

Given the equation there are some options in Reduce, e.g. Backsubstitution -> True which is sometimes helpful in similar problems, however not in our case. Nonetheless one can make Reduce find all integer solutions adding some restriction on y since there are infinitely many integer y, however when you put e.g. -100 <= y <= 100 this solves the problem

{x, y} /. {ToRules @ Reduce[x^2*(1 + x) == y*(-1 + 3*y) &&
-100 <= y <= 100, {x, y}, Integers]}

{{-1, 0}, {0, 0}, {1, 1}, {4, -5}, {6, -9}}


Such a suplement is quite natural for those who are familiar with equation solving functionality.

I found later a question (Solutions given by WolframAlpha, asked a few hours ago) regarding the same equation. To answer a question on how many solutions one might expect, we observe that the original equation is an example of an elliptic cure equation ($$q^2 = 4 p^3-g_2 p -g_3)$$), we know that if there are two integer pairs of solutions there is also a third integer pair. With the original Reduce result one can find that is equivalent to $$(6y-1)^2=12 x^3+12 x^2$$ and it is straightforward to get the canonical elliptic cure equation by a simple linear transformation of $$x$$. There are five solutions since there is $$(k y -1)^2$$ , which doubles three integer solutions of elliptic curve and one is degenerate.

• +1. Thank you for the useful info. You are a master of Mathematica! – user64494 Jan 14 '20 at 19:02
• @user64494 Thanks, however you can find on this site more and greater Mathematica experts. – Artes Jan 14 '20 at 21:21
• @Artes, I actually found this problem from that WA post by another OP. I was curious how to do it and gave Reduce a go. Thanks for the insights. – Moo Jan 14 '20 at 23:54
• @Artes by "elliptic cure" you mean curve? – AccidentalFourierTransform Jan 15 '20 at 2:22
• @AccidentalFourierTransform Yes, of course. Thanks for pointing this typo, I will correct it soon. – Artes Jan 15 '20 at 12:33

Use Solve instead of Reduce, with an extra constraint as given by @Artes:

Solve[x^2*(1 + x) == y*(-1 + 3*y) && -10^3 <= x <= 10^3, {x, y}, Integers]

(*    {{x -> -1, y -> 0}, {x -> 0, y -> 0}, {x -> 1, y -> 1},
{x -> 4, y -> -5}, {x -> 6, y -> -9}}                     *)