No significant change. Simply corrected a broken link to one of the references.
How many distinct solutions are there to the following problem:
- $a + b + c = (2n+1) ~: ~n \in \Bbb{Z^+}.$
- $a,b,c \in \Bbb{Z}.$
- $1 \leq a,b,c \leq n.$
For Stars and Bars theory, see
Link-1 and
Link-2.
For any set $~M~$ with a finite number of elements, let $~|M|~$ denote the
number of elements in the set $~M.$
Let $~D~$ denote the set of all solutions to the problem, under the
assumption that when Solution-2 is a permutation of Solution-1, that these
two solutions are to be regarded as distinct elements of $~D.~$
Let $~E~$ denote the subset of $~D~$ where exactly two of the three
components are equal. Note that the set $~E~$ excludes the element of $~D~$ where
all three components are equal (if any).
Let $~F~$ denote the subset of $~D~$ where all three components are equal (if any).
Then the number of distinct solutions, where permuted solutions are not to be
regarded as distinct is:
$$\frac{|D| - |E| - |F|}{3!} + \frac{|E|}{3} + |F|. \tag1 $$
The expression in (1) above is explained as follows:
$D ~\setminus ~(E \cup F) ~$ represents the set of solutions that contain exactly
$~3~$ distinct components. Each distinct solution will appear $~3!~$ times in
the set $~D ~\setminus ~(E \cup F).$
For example, if $~n = 5,~$ then the set $~D~$ will contain each of the following
elements, which all represent the same answer:
$(1,2,8), ~(1,8,2), ~(2,1,8), ~(2,8,1), ~(8,1,2), ~(8,2,1).$
$E$ represents the set of solutions that contain exactly
$~2~$ distinct components [i.e. when $~n = 5,~$ a solution like $~(5,5,1)~$].
Each distinct solution will appear $~3~$ times in
the set $~E.$
So, the entire problem reduces to computing a closed form expression for
each of $~|D|, ~|E|, ~|F|.~$
$\underline{\text{Computation of} ~|D|}$
I will parallel the approach given in
The Model.
So, the task here is to compute the number of solutions to:
$x_1 + x_2 + x_3 = (2n+1) ~: ~n \in \Bbb{Z^+}.$
$x_1, ~x_2, ~x_3 \in \Bbb{Z_{\geq 1}}.$
$x_1, ~x_2, ~x_3 \leq n.$
Basic Stars and Bars theory, as documented in Link-1 at the start of this
answer, provides a formula, based on the assumption that the lower bound of the
variables is $~0,~$ rather than $~1.$ So, the first thing to do is employ a
change of variables, to adjust the lower bounds.
For $~i \in \{1,2,3\},~$ let $~y_i = x_i - 1.$
Then $~|D|~$ will equal the number of solutions to:
$y_1 + y_2 + y_3 = (2n+1) - 3 = (2n - 2).$
$y_1, ~y_2, ~y_3 \in \Bbb{Z_{\geq 0}}.$
$y_1, ~y_2, ~y_3 \leq (n - 1).$
Following The Model:
Let $~S~$ denote the set of all solutions, where the upper bound constraint
[i.e. $~y_i \leq (n-1)~$ ] is ignored.
For $~i \in \{1,2,3\}, ~$ let $~S_i~$ denote the subset of $~S~$ where
$~y_i \geq n.$
Then
$$|D| = |S| - |S_1 \cup S_2 \cup S_3|.$$
So,
Let $~T_0~$ denote $~|S|.$
Let $~T_1~$ denote $~|S_1| + |S_2| + |S_3|.$
Let $~T_2~$ denote $~|S_1 \cap S_2| + |S_1 \cap S_3| + |S_2 \cap S_3|.$
Let $~T_3~$ denote $~|S_1 \cap S_2 \cap S_3|.$
Then,
$$|D| = T_0 - T_1 + T_2 - T_3.$$
You can examine The Model for a description of the Math involved.
You have that:
Therefore,
$$|D| = \binom{2n}{2} - \left[ ~3 \times \binom{n}{2} ~\right] = \frac{n^2 + n}{2}.$$
$\underline{\text{Computation of} ~|F|}$
The set $~F~$ represents the set of all solutions $~(a,b,c)~$ where
$~a + b + c = (2n+1),~$ and $~a = b = c.~$
Define the variable $~\alpha_n~$ so that
If $~(2n+1)~$ is a multiple of $~3,~$ then $~\alpha_n = 1.$
If $~(2n+1)~$ is not a multiple of $~3,~$ then $~\alpha_n = 0.$
Then $$|F| = \alpha_n.$$
$\underline{\text{Computation of} ~|E|}$
Consider the number of solutions to:
The above bullet pointed problem will have exactly one solution for each value
of $~x_1~$ that is viable.
For $~x_1 \in \{1,2,\cdots,n\},~$ you have that $~x_2 = (2n+1) - 2x_1.$
You must have $~x_2 \in \{1,2,\cdots,n\}.~$
So, clearly an upper bound for $~x_1~$ is $~x_1 = n \implies x_2 = 1.~$
The constraint that $~(2n+1) - 2x_1 \leq n~$ will be true if and only if
$\dfrac{n+1}{2} \leq x_1.$
Therefore, letting $~\lceil r\rceil ~$ denote the smallest positive integer
$~\geq r ~$ (i.e. the ceiling of $~r~$), you have that the lower bound for
$~x_1~$ is $~\displaystyle \left\lceil ~\frac{n+1}{2} ~\right\rceil.$
Therefore, the number of solutions to the bullet pointed problem above is
$\displaystyle (n+1) - \left\lceil ~\frac{n+1}{2} ~\right\rceil.$
From this, you have to deduct $~\alpha_n~$ which represents the solution (if any)
where $~x_1 = x_2.~$
Then,
$$|E| = 3 \times \left\{ ~(n+1) - \left\lceil ~\frac{n+1}{2} ~\right\rceil - \alpha_n ~\right\}. \tag2 $$
To illustrate the idea behind (2) above, assume that $~n = 4.~$
This implies that:
The viable solutions to $~2x_1 + x_2 = 9~$ are given by
$(x_1,x_2) \in \{~(3,3), (4,1) ~\}.~$
Then, in the set $~E~$ the solution $~(x_1,x_2) = (4,1)~$ will be represented by
$(a,b,c) \in \{~(4,4,1), ~(4,1,4), ~(1,4,4) ~\}.$
Further, the solution $~(x_1,x_2) = (3,3),~$ which represents
$(a,b,c) = (3,3,3)~$ is excluded from set $~E.$
$\underline{\text{Final Computation}}$
$\displaystyle |D| = \frac{n^2 + n}{2}.$
$3 ~| ~(2n+1) \implies \alpha_n = 1.$
$3 ~\not| ~(2n+1) \implies \alpha_n = 0.$
$|F| = \alpha_n.$
$\displaystyle |E| = 3 \times \left\{ ~(n+1) - \left\lceil ~\frac{n+1}{2} ~\right\rceil - \alpha_n ~\right\}.$
So, the number of distinct solutions, where different permutations of the same solution are not
considered distinct, is
$$\frac{|D| - |E| - |F|}{3!} + \frac{|E|}{3} + |F|. $$