[Math] How to calculate combinations of multiple variables which can assume multiple values

combinationscombinatoricspermutations

I have 3 variables (A,B,C); each variable can assume 3 different values (1,2,3) .
I want to calculate ho many combinations there are which follow this rule:

let's fix A1, then cycle on all the others variables which can assume 3 values each; then let's move on to A2 and calculate again all the combinations by cycling over the 2 remaining variables (which can assume 3 values each); same thing for A3. Once I am done with A I repeat the same process with B and so on. The constrain is that the combinations must repeat only once over all:
in fact if I fix A1 and the combination I get is (A1 B3 C2 ), then when I fix for example B3 I must not count (A1 B3 C2) because it has been already found before.

So what I need is the mathematical formula that allows me to do this calculation with a generic number of variables which can assume a generic number of values

Best Answer

For clarification, I am assuming we are keeping it as an ordered pair (A,B,C) for whatever ABC happens to be. (I.e. we are never concerned about a permutation of the letters such as (B,A,C))

You have 3 choices for the result of A, three choices for the result of B, and 3 choices for the result of C. By multiplication principle it is then $3\cdot 3\cdot 3 = 3^3=27$.

In general, if you have $r$ variables, each of which can take $n$ values, (I.e. we have letters $(A_1, A_2,\dots, A_r)$ each of which can be any number from $\{1,2,\dots,n\}$, there will be $n\cdot n\cdots n = n^r$ total possibilities.

Even more generally, if you have $r$ variables, the $i^{th}$ of which can take on $n_i$ values, you will have $\prod\limits_{i=1}^r n_i$ number of possibilities.

For a simple example, you go to an icecream shop and would like to get a sundae. A sundae consists of one flavor of icecream and any combination of toppings you'd like (some, all, or none). If there are five flavors of icecream and four available toppings, how many different ice cream sundaes are possible? Break it up via multiplication principle to first ask the question how many flavors of icecream there are (flavor 1, flavor 2,...). Then to ask the question if you use the first topping (yes or no), yes or no to the second topping, yes or no to the third...

This is exactly the same problem as how many possibilities exist for (A,B,C,D,E) if $A\in\{1,2,3,4,5\}$, and each of B through E are either 1 or 2. If for example, B is 1, then don't use that topping.

There are then $5\cdot 2\cdot 2\cdot 2\cdot 2=80$ possible sundaes.

Related Question