I'm interested in a closed-form formula for the number of compositions of an integer n with k parts where each part is not greater than w: C(n,k,w). [Abramson 1976] contains formula E at page 441, but I always get only $0$ as results. Already formula 3.2 seems to have only 0 as results. Where is the mistake?
-
Can't catch your mistake if you don't post your work. Formatting tips here. – Em. Dec 30 '15 at 13:40
1 Answers
Formula (E) says that the number of $k$-compositions $a_1+\ldots+a_k$ of $n$ such that $1\le a_i\le w$ for $i=1,\ldots,k$ is given by the sum
$$\sum_{j=0}^k(-1)^j\binom{k}j\binom{n-jw-1}{k-1}\;.\tag{1}$$
Let’s try it with $k=w=3$ and $n=7$. The $3$-compositions of $7$ bounded by $3$ are $1+3+3$, $3+1+3$, $3+3+1$, $2+2+3$, $2+3+2$, and $3+2+2$, so there are $6$ of them, and
$$\sum_{j=0}^3(-1)^j\binom3j\binom{7-3j-1}2=\binom62-3\binom32+3\binom02-\binom{-3}2=15-9+0=0=6\;,$$
as it should.
In fact $(1)$ is definitely correct. In an earlier answer I noted that an inclusion-exclusion calculation shows that the number of weak $k$-compositions of $m$ with an upper bound of $b$ on each term is
$$\sum_j(-1)^j\binom{k}j\binom{m+k-j(b+1)-1}{k-1}\;.\tag{2}$$
Let $m=n-k$ and $b=w-1$. There is an obvious bijection between $k$-compositions of $n$ whose terms are bounded by $w$ and weak $k$-compositions of $m=n-k$ whose terms are bounded by $b=w-1$: just subtract $1$ from each term of the $k$-composition to get the corresponding weak $k$-composition. Thus, by $(2)$ there are
$$\sum_j(-1)^j\binom{k}j\binom{m+k-j(b+1)-1}{k-1}=\sum_j(-1)^j\binom{k}j\binom{n-jw-1}{k-1}$$
$k$-compositions of $n$ bounded by $w$, and $(1)$ follows from $(2)$.

- 616,228
-
Very useful answer. Many many thanks. I overlooked that the binomials in the article are defined to be 0 if one of their arguments is negative. – IV_ Dec 31 '15 at 16:04
-