Combinations of 4 variables, using different operations

Azure

New member
Joined
Mar 14, 2007
Messages
4
I'm trying to find out how many possible combinations you have if you have 4 variables, using all of them, how many unique combinations you will have using addition, subtraction, multiplication, division, exponentiation, and using roots. You can use parenthesis, but you can't have negatives, such as \(\displaystyle a \cdot -b\).

so for 2 vars:
1. \(\displaystyle a+b\), \(\displaystyle b+a\)
2. \(\displaystyle a-b\)
3. \(\displaystyle b-a\)
4. \(\displaystyle a \cdot b\), \(\displaystyle b \cdot a\)
5. \(\displaystyle \frac ab\)
6. \(\displaystyle \frac ba\)
7. \(\displaystyle a^b\)
8. \(\displaystyle b^a\)
9. \(\displaystyle \sqrt[a]{b}\)
10. \(\displaystyle \sqrt{a}\)

This isn't for school or anything, I'm trying to make a script, but I need to know how the math works.

Thanks :D
 
There is no answer to your question!
That is because there are infinitely many ways to apply grouping symbols.
 
pka said:
There is no answer to your question!
That is because there are infinitely many ways to apply grouping symbols.
I don't think it is infinite, I think it is just very high. I asked my dad and he said to look for trends in the same situation but with a lower amount of variables. But, even 3 variables might take a while to find manually. o:
 
Azure said:
I'm trying to find out how many possible combinations you have if you have 4 variables, using all of them, how many unique combinations you will have using addition, subtraction, multiplication, division, exponentiation, and using roots. You can use parenthesis, but you can't have negatives, such as \(\displaystyle a \cdot -b\).

so for 2 vars:
1. \(\displaystyle a+b\), \(\displaystyle b+a\)
2. \(\displaystyle a-b\)
3. \(\displaystyle b-a\)
4. \(\displaystyle a \cdot b\), \(\displaystyle b \cdot a\)
5. \(\displaystyle \frac ab\)
6. \(\displaystyle \frac ba\)
7. \(\displaystyle a^b\)
8. \(\displaystyle b^a\)
9. \(\displaystyle \sqrt[a]{b}\)
10. \(\displaystyle \sqrt{a}\)

This isn't for school or anything, I'm trying to make a script, but I need to know how the math works.

Thanks :D

This exercise is to count the number of expressions possible using a grammar for a simple language. There are only 4 variable names, each used exactly once, 6 binary operators and grouping to deal with. I'll give it a shot.

Start by considering when the 4 variables have a fixed order, say abcd, and there is only one operator *. Then a*b*c*d is the only valid expression except for the grouping or precedence. But the grouping can be handled by assigning a precedence to each of the three * operations: use *** for the operation that comes first, ** for the second and * for the last. Then for example, a*((b*c)*d) is written a*b***c**d. For this restricted grammar, the number of possible expressions is 3! = 6, which is the number of ways to arrange ***, ** and *.

Now consider the order of the variables. The number of ways to arrange them is 4! = 24. So with 1 operator with grouping and 4 variables, the number of possible expressions is 6 x 24.

And then the actual number of operators is 6. There are 6 choices each for ***, ** and *, which makes 6^3 = 216 choices. So the total number of possible expressions is 6 x 24 x 216 = 31,104.

For n variables and m operators, the total is \(\displaystyle \L e(n,m) = (n-1)!n!m^{n-1}.\)

This doesn't take into account that addition and multiplication are commutative and associative: for example b+(a+(d+c)) and ((a+b)+c)+d are considered two different expressions even though they are equal. So \(\displaystyle e(2,6) = 12\) and not 10 as Azure counts.
 
Top