CITE THIS NOTEBOOK: Diophantine equation with undetermined terms by Shenghui Yang. Wolfram Community NOV 3 2022.
This is a very interesting equation from a Chinese user and I would like to share with you how work out a nice solution with WL

Problem

Let
a
1
≤
a
2
...≤
a
n
be positive integers.
Find the number of solution tuples for
(
a
1
,
a
2
,...,
a
n-1
,
a
n
)
such that
a
1
+
a
2
+...+
a
n-1
+
a
n
=26
2
a
1
+
2
a
2
+...+
2
a
n-1
+
2
a
n
=62
3
a
1
+
3
a
2
+...+
3
a
n-1
+
3
a
n
=164

Solution

If you want to solve the problem directly, you would need some way to increase the number of variable dynamically and try to solve the set of equations every time by scanning all valid . Given all variables are positive integers, the maximum number of variable is confined by the first equation. The worst case is to solve the equation 24 times (26 - 3 + 1 = 24 with all variable equal to 1 and because we need at least three variables to solve 3 equations ). Unfortunately, this is silly and Diophantine equation with cubics terms are no joke.
Thus we should try dig more information from the conditions so as to concentrate at a handful of possibilities.
Note that all numbers are at least 1 because
1<=1<=1<=...<=1
is valid. And
a
n
cannot be too large because
3
a
1
+
3
a
2
+...+
3
a
n-1
=164-
3
a
n
must be positive
In[]:=
Reduce[an^3<164,an,PositiveIntegers]
Out[]=
an1||an2||an3||an4||an5
Also
a
n
is the largest among all
a's
, I can conclude that, by monotonicity of the chain,
(
a
1
,
a
2
,...,
a
n-1
,
a
n
)
is just
(1,...,1,2,...,2,3,...,3,4...,4,5...,5)
in which each number is of its own frequency/count.
​
Assume 1 occurs
a
times, 2 does
b
times, 3 does
c
times, 4 does
d
times and finally 5 does
e
times. The original equation turns to the following linear set of Diophantine equations:
In[]:=
Reduce[​​a+2b+3c+4*d+5e==26&&​​a+4b+9c+16*d+25e==62&&​​a+8b+27c+64*d+125e==164&&​​26>=a>=0&&21>=b>=0&&6>=c>=0&&3>=d>=0&&1>=e>=0,​​{a,b,c,d,e},Integers]
Out[]=
(a1&&b9&&c1&&d1&&e0)||(a5&&b3&&c5&&d0&&e0)
The upper boundary for other variables are determined loosely just to satisfy conditions like
1xa<=26,8xb<=164
and so on. As I find two solutions for the counting number for each
{1,2,3,4,5}
, I convert them back to the solution for
(
a
1
,
a
2
,...,
a
n-1
,
a
n
)
:
In[]:=
sol1={1,Splice[ConstantArray[2,9]],3,4}
Out[]=
{1,2,2,2,2,2,2,2,2,2,3,4}
In[]:=
sol2={Splice[ConstantArray[1,5]],Splice[ConstantArray[2,3]],Splice[ConstantArray[3,5]]}
Out[]=
{1,1,1,1,1,2,2,2,3,3,3,3,3}
Put them back to verify the solution:
In[]:=
{Total[sol1],Total[sol1^2],Total[sol1^3]}
Out[]=
{26,62,164}
In[]:=
{Total[sol2],Total[sol2^2],Total[sol2^3]}
Out[]=
{26,62,164}

Summary

This is a very good example of thinking other way round and answering the following question further helps the understanding: can we change some number in the equation to find other solution? Well, careless movements hits a dead end quickly! Say we change 164 to 165:
In[]:=
Reduce[​​a+2b+3c+4*d+5e==26&&​​a+4b+9c+16*d+25e==62&&​​a+8b+27c+64*d+125e==165&&​​26>=a>=0&&21>=b>=0&&6>=c>=0&&3>=d>=0&&1>=e>=0,​​{a,b,c,d,e},Integers]
Out[]=
False
The reason is that this problems is created after you have a set of number like our solution {1,1,1,1,1,2,2,2,3,3,3,3,3}, you will have to adjust RHS accordingly after you modify the
a
i
’s in the list. A careful adjustment can give you solutions if we fix the RHS of the first two equations and only changing the RHS on the third equation. For instance (choose 215 here because
215<=216=
3
6
so I do not need to include a new variable):
In[]:=
[◼]
PrettyGrid
[​​DeleteCases[Table[{k,Reduce[​​a+2b+3c+4*d+5e==26&&​​a+4b+9c+16*d+25e==62&&​​a+8b+27c+64*d+125e==k&&​​26>=a>=0&&21>=b>=0&&8>=c>=0&&5>=d>=0&&1>=e>=0,​​{a,b,c,d,e},Integers]},{k,164,215}],{_,False}]]
Out[]=
164
(a1&&b9&&c1&&d1&&e0)||(a5&&b3&&c5&&d0&&e0)
170
(a4&&b6&&c2&&d1&&e0)||(a8&&b0&&c6&&d0&&e0)
176
a7&&b3&&c3&&d1&&e0
182
(a6&&b6&&c0&&d2&&e0)||(a10&&b0&&c4&&d1&&e0)
188
a9&&b3&&c1&&d2&&e0
194
(a5&&b8&&c0&&d0&&e1)||(a12&&b0&&c2&&d2&&e0)
200
a8&&b5&&c1&&d0&&e1
206
(a11&&b2&&c2&&d0&&e1)||(a14&&b0&&c0&&d3&&e0)