# Guess Diophantine equation from its solutions

Take for example the equation $$n^2=x^2+y^2+1$$ where $x,y$ are integers.

This equation admits solutions only for some values of $n$, to wit, $$n=1,3,9,17,19,33,35,51,73,81,99,\dots$$

Can we reverse-engineer the Diophantine equation from the sequence above? I guess the solution is non-unique, but any solution will do.

• This seems more like a Mathematics question than a Mathematica question. – bbgodfrey Aug 3 '18 at 4:00
• @bbgodfrey How so? I really don't think there is a general mathematical way to do this; and even if there were, that's not what I'm looking for. Rather, my hope was that there is some smart way to programmatically try polynomials until one works. In short, I would like to extend FindSequenceFunction so that it is able to identify Diophantine equations. I was surprised to see your comment, and the fact that at least two more people agree with you. I'll think about it, but I really am interested in the MMA solution, not in the math one... – AccidentalFourierTransform Aug 3 '18 at 13:26

Although perhaps not very satisfying, a Diophantine equation yielding the values of n in the question is given by

lst = {1, 3, 9, 17, 19, 33, 35, 51, 73, 81, 99};
eq = n == Sum[lst[[i]] x[i], {i, 11}]
(* n == x[1] + 3 x[2] + 9 x[3] + 17 x[4] + 19 x[5] + 33 x[6] + 35 x[7] +
51 x[8] + 73 x[9] + 81 x[10] + 99 x[11] *)


The first eleven non-trivial solutions are

tab = {n, Table[x[i], {i, 11}]} // Flatten;
Table[tab /. {n -> lst[[i]], x[i] -> 1, x[_] -> 0}, {i, 11}]
(* {{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{9, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {17, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{19, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, {33, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{35, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, {51, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
{73, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, {81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0},
{99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}} *)


In fact, there is an infinite number of Diophantine equations satisfying the requirements of the question. Obtaining a particular equation would require several constraints.