A Cambridge University mathematics interview question states:
Find all $a,b,c,d,e,f \in \mathbb{N}$ such that
$$a + b + c = d \cdot e \cdot f$$
and
$$d + e + f = a \cdot b \cdot c$$
(There are a number of similar questions on this site, but none that concentrate on finding all solutions, particularly when permutations expand the solution search space.)
It is easy and fast to find one solution:
FindInstance[
{a + b + c == d e f,
d + e + f == a b c,
{a, b, c, d, e, f} > 0},
{a, b, c, d, e, f}, Integers]
(* {{a -> 2, b -> 3, c -> 1, d -> 2, e -> 3, f -> 1}} *)
Of course this solution (and others, below) can be permuted to find additional (equivalent) solutions.
The full solution set, however, is:
$\{ (3,2,1), (3,2,1) \}, \{ (1,1,6), (2,2,2) \}, \{ (1,1,8), (1,2,5) \}, \{ (1,1,7), (1,3,3) \}$ (and, of course, permutations).
I have been unable to algorithmically find all these solutions. I've tried using Solve
, Reduce
, and the obvious alterations to FindInstance
:
FindInstance[
{a + b + c == d e f,
d + e + f == a b c},
{a, b, c, d, e, f}, Integers,4]
which yields one additional solution, but not all four.
I've tried to reduce the solution search space by constraining (without loss of generality) the permutations of each subset of variables:
FindInstance[
{a + b + c == d e f,
d + e + f == a b c,
a >= b >= c > 0,
d >= e >= f > 0, (a != d) \[Or] (b != e) \[Or] (c != f)},
{a, b, c, d, e, f}, Integers]
One can also impose the fact that not all terms $\{a,b,c \}$ or $\{ d,e,f \}$ can be greater than 2.
The best I've found is:
FindInstance[
{a + b + c == d e f,
d + e + f == a b c,
{a, b, c, d, e, f} > 0,
a >= b >= 2 >= c > 0,
d >= e >= f > 0,
a != f ,
a b > 4 ,
c == 1},
{a, b, c, d, e, f}, Integers, 4]
There are yet other constraints, but none have yielded all the solutions.
I am explicitly NOT interested in any method that relies on exhaustive enumeration and testing, as might be implemented in Python or other languages without symbol manipulation. Such methods scale poorly with number of equations, variables, upper limits, and so on. After all, how do you know ahead of time that your numerical search need not go to, say, $10^{10}$ for each variable?! And how can such simulation ever show that there is NO solution? Or the total number of solutions that do exist? The "human intelligence" in the attached link at the top is the kind of "smarts" I want to implement and exploit in Mathematica.
How can I compute all the solutions (up to permutation) using symbol manipulation?
FindInstance
symbol manipulation? It could be doing exhaustive search "under the hood". The documentation does not rule that out. $\endgroup$FindInstance
does not use exhaustive search (in general). Further, it also can compute that no solution exists to a certain problem where exhaustive search would take infinite time. $\endgroup$FindInstance
has certain advantages and I have used it to get good results, but it has frustrating limitations which are not documented. In some cases, exhaustive search easily finds solutions whenFindInstance
can't. $\endgroup$Reduce[{…, 10 > {a,b,c,d,e,f} > 0},…]
does not satisfy your requirements but it works on the toy problem. $\endgroup$