# Solving a system of two equations of cube integers using ParallelTable

Well, I have the following problem: I need to solve the following system of equations:

$$\begin{cases} n=a^3+b^3+c^3\\ \\ n=d^3+k^3+f^3 \end{cases}\tag1$$

Where:

• $$n\ne a\ne b\ne c\ne d\ne k\ne f$$;
• $$1\le a;
• $$n\in\mathbb{N}^+,a\in\mathbb{N}^+,b\in\mathbb{N}^+,c\in\mathbb{N}^+,d\in\mathbb{N}^+,k\in\mathbb{N}^+,f\in\mathbb{N}^+$$

And I want to search for solutions using the following range: $$2\le n\le1000^3$$.

I thought of the following code:

ParallelTable[{n,Solve[{n==a^3+b^3+c^3,n==d^3+k^3+f^3,
1<=a<n&&1<=b<n&&1<=c<n&&1<=d<n&&1<=k<n&&1<=f<n&&a!=b!=c!=d!=k!=f},
{a,b,c,d,k,f},Integers]},{n,2,1000^3}]


Question: is there a faster way to let Mathematica evaluate this?

EDIT:

After seeing the answer that was posted by @kglr, I wondered can I use that technique to solve the same problem by using more variables:

$$\begin{cases} n=a^3+b^3+c^3\\ \\ n=d^3+k^3+f^3\\ \\ n=g^3+h^3+m^3\\ \\ n=a^3+k^3+m^3\\ \\ n=g^3+k^3+c^3\\ \\ n=a^3+d^3+g^3\\ \\ n=b^3+k^3+h^3\\ \\ n=c^3+f^3+m^3 \end{cases}\tag2$$

All the conditions are the same, so they all can not be equal to each other and needs to be an integer bigger than zero.

## 1 Answer

SeedRandom[1]
While[Length[pr] < 2,
pr = Select[FreeQ @ 0] @ PowersRepresentations[RandomInteger[{2, 10^6}], 3, 3]]; //
AbsoluteTiming // First

5.8*10^-6

 {{a, b, c}, {d, k, f}, n} = Join[pr[[;;2]], {Total[pr[[1]]^3]}]

{{2, 3, 16}, {3, 9, 15}, 4131}

Total[pr^3, {2}]

{4131, 4131}


If you want the 6 numbers all distinct:

SeedRandom[1]
While[Length[Union @@ pr] < 6,
pr = Select[FreeQ@0]@
PowersRepresentations[RandomInteger[{2, 10^6}], 3, 3]]; //
AbsoluteTiming // First

 0.0000275

pr

 {{5, 53, 88}, {12, 29, 93}, {15, 74, 75}}

Total[pr[[1]]^3]

830474

• @Jan, hope the new version makes it easier to see the steps: We pick a random integer in the interval 2 to 20^6 (RandomInteger[{2, 10^6}]), find its representations as the sum of 3 cubes (PowersRepresentations[..., 3,3]), select the triples free of 0 (Select[FreeQ @0]) , we repeat as long as the length of triples we get is less than 2 (Lenth[pr]<2) .
– kglr
Apr 16 '20 at 13:56
• First of all, I am very thankful for your time and answer, so +1. I understand your code. Can you help me with the problem I edited into my question, using your technique? Because that is the full problem I would like to solve. Apr 16 '20 at 14:07
• @Jan, it is unlikely that we can find 5 sets of distinct triples in Range[2, 10^6] , that is, we probably end up with an infinite while loop if we use random search without eliminating previously seen points.
– kglr
Apr 16 '20 at 14:52
• some variables are used twice, so it is not really 5 sets of distinct triples. For example the variable $a$ turns up in the first and 4th equation. So maybe extend the range or something. Can you help me with that? Apr 16 '20 at 14:56
• I also made a mistake, it should be 8 equations which are interlinked with each other. Apr 16 '20 at 14:58