How many solutions are there of the equation $x_1 + x_2 + x_3 = 12$ with $x_1, x_2, x_3$ non-negative integers? Solution. This is the same as the number of ways to choose 12 objects from 3 distinct objects with repetition and order does not matter, i.e.,
$${12+3-1}\choose{3-1}$$
So from What I thought, the number of ways to choose 12 objects from 3 distinct objects with repetition and order does not matter would be $${12+3-1}\choose{3}$$ as my formula doesn't have a -1 at the bottom, so why does this one?
That is, why sometimes $${n+r-1}\choose{r-1}$$ and some times $${n+r-1}\choose{r}$$?
A particular solution corresponds to the placement of two addition signs in a row of twelve ones. For instance, $$1 1 1 1 1 + 1 1 1 1 + 1 1 1$$ corresponds to the solution $x_1 = 5$, $x_2 = 4$, $x_3 = 3$, while $$+ 1 1 1 1 1 1 1 1 + 1 1 1 1$$ corresponds to the solution $x_1 = 0$, $x_2 = 8$, $x_3 = 4$. The number of solutions of the equation is the number of ways we can fill two of the fourteen positions required for twelve ones and two addition signs to be filled with addition signs, which is $$\binom{12 + 2}{2} = \binom{14}{2}$$ or, equivalently, the number of ways we can fill twelve of the fourteen positions with ones, which is $$\binom{12 + 2}{12} = \binom{14}{12}$$
Now, let's look at the general case. Suppose we wish to solve the equation $$x_1 + x_2 + x_3 + \cdots + x_n = k$$ in the nonnegative integers. A particular solution corresponds to the placement of $n - 1$ addition signs in a row of $k$ ones. The number of ways we can do this is the number of ways we could select which $n - 1$ of the $k + n - 1$ positions required for $k$ ones and $n - 1$ addition signs will be filled with addition signs, which is $$\binom{k + n - 1}{n - 1}$$ or, equivalently, the number of ways we could select $k$ of the $k + n - 1$ positions to be filled with ones, which is $$\binom{k + n - 1}{k}$$
The solution can represent the number of ways $k$ identical objects can be placed in $n$ distinct boxes, or the number of ways $k$ objects can be selected from $n$ types of objects, provided that there are at least $k$ objects available from each of the $n$ types of objects.