I'm having a hard time reasoning through the formula for combinations $\frac{n!}{k!\left(n-k\right)!}$. I understand the reason for the permutations formula and I know that for the combinations we divide by $k!$ to adjust for the repeated cases, since order does not matter. But what exactly happens when we divide the set of permutations by $k!$ ?
I know this may seem like a silly question... I just can't take this for granted, lest I miss a chance to apply it correctly. Can you describe what's happening here step by step, sort like debugging a script?
Let $X$ be a finite set of size $n$. Suppose we want to know the number of combinations of size $k$. First a definition:
So let us instead ask: How can we construct a combination? I suggest that we do this by constructing a permutation. Let’s use this definition:
There are two ways two proceed. This one is called forwards:
How do we construct a subpermutation? Well it has to be ordered so let’s choose the first element. There are $n$ choices and we can partition the set of permutations by the choice of first element, so we haven’t missed anything yet with this choice and we haven’t double counted anything. So we carry on and eventually we stop after $k$ elements and conclude that there are $\frac{n!}{(n-k)!}=n(n-1)\cdots(n-k+1)$ subpermutations of size $k.$
Given a subpermutation we can forget the order to get a combination. However as there are multiple subpermutations with the same set and different orders, we have counted the same combination multiple times by getting to it in different ways. If we divide by the number of ways of getting to each combination, we will not be counting things multiple times. So how many ways to get to a combination? Well that’s the number of ways to have a different order on a subpermutation without changing the set. How many of those? Well there’s $k$ choices for the first, $k-1$ for the second, and so on, so $k!$ total, hence we divide by $k!.$
This is the backwards way:
Suppose we know there are $C$ combinations of size $k$ and we want to compute $P,$ the number of subpermutations of size $k$. Here is an algorithm:
And there are $C$ ways of doing part 1, and $k!$ ways to do part 2, so there are $Ck!$ ways to make a subpermutation of size $k.$ We haven’t double counted because we don’t double count in step 1 or 2 and two subpermutations need the same set and the same order to be equal. Therefore $P=Ck!$, but we happen to know $P$ and not $C$ so we can deduce $C=\frac P{k!}$