Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given 5 different numbers ($\in \mathbb N$) in a specific brackets pattern like:

$$\left(\left(\left(x_1 + x_2 \right) - x_3\right) \times x_4 \right) / x_5 = \text{result}$$

Only the brackets are fixed, the numbers and the operators can be permutated at will.
And there must be all the four operators.

Does someone knows how could I find out if a permutation of the numbers and of the operators that gives the same result

  • is an equivalent solution under the distributive, associative and/or commutative law
  • or is a different solution that "just happens" to give the same result

For example:

$\left(\left(\left(6 - 3 \right) \times 2\right) / 1 \right) + 5 = 11 $

is equivalent to:

$\left(\left(\left(6 - 3 \right) / 1\right) \times 2\right) + 5 = 11 $

but it's different from:

$\left(\left(\left(3 - 2 \right) \times 6\right) / 1 \right) + 5 = 11 $

that gives the same result only with this particular choice of numbers: 2,3 and 6.

share|cite|improve this question
@JasperLoy: I consider the first two equations equivalent because they will always return the same result, no matter what numbers I choose since (((a−b)×c)/d)+e=(((a−b)/d)×c)+e. While the fact that (6−3)×2=(3−2)×6 relies on the particular choice of numbers. So at the end even if the same set of numbers is involved I consider the two solutions different. I'm not very good at explaining myself, but I hope to have been more clear, what do you think? – Rik Poggi Feb 13 '12 at 17:55
@RikPoggi, it seems that we just need to solve the equation(s) f(a,b,c,d,e)=g(a,b,c,d,e). Maybe there are some interesting things in your question, but that may be beyond me. – puresky Feb 14 '12 at 12:40

For the heck of it I defined the 24 functions $f_1$, $\ldots$, $f_{24}$ resulting from permuting the operation symbols in your expression. Then I listed the $120$ ways of assigning variables $x_1$, $\ldots$, $x_5$ to the placeholders $u$, $v$, $x$, $y$, $z\ $ I had in the $f_j$. With this setup I did all $${24\choose 2}\cdot 120 + 24\cdot 119 = 35 976$$ comparisons of two resulting expressions and found 46 matching pairs among them. I spare you the list.

The number $35 976$ is obtained as follows: We have to check all pairs $f_i$ vs. $f_j$, $\ i<j$, where $f_i$ is assigned the standard $5$-tuple $(x_1,x_2,x_3,x_4,x_5)$ of variables and $f_j$ one of the $120$ permutations of this $5$-tuple. In addition we have to check for each $i$ the function $f_i$ with the standard assignment $(x_1,\ldots,x_5)$ vs. the same $f_i$ with each one of the $119$ other assignements of the variables $x_1$, $\ldots$, $x_5$.

share|cite|improve this answer
It's interesting, I will try it too, how did you made the comparisons? But is not clear to me why there are $35976$ comparisons instead of $2880 \cdot 2879 / 2$ – Rik Poggi Feb 14 '12 at 14:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.