Number of ternary sequences of length $n$ with same number of $1$'s and $0$'s My attempt is considering the number of $1$'s to be $k$ then for each $k$ we choose choose the inner order of the $1$'s and $0$'s which has ${2k \choose k }$ options then choosing the indices of the $2$'s which has ${ n \choose n -2k } = { n \choose 2k }$. So if we sum for each $k$ we get:
$\sum_{k=0}^{\left \lfloor \frac{n}{2} \right \rfloor} {2k \choose k }{ n \choose 2k } = \sum_{k=0}^{\left \lfloor \frac{n}{2} \right \rfloor} \frac{(2k)!}{k!k!} \frac{n!}{(2k)!(n-2k)!} = \sum_{k=0}^{\left \lfloor \frac{n}{2} \right \rfloor} \frac{n!}{k!k!(n-2k)!} $
The problem is that this doesn't add up to a nice closed form, any idea how to get a nice closed form from here or by any other method?
 A: For having exactly $k$ 1's and 0's there are $\binom n k$ possibilities to choose the 1's and $\binom{n-k}{k}$ possibilities to choose the 0's. All the rest needs to be 2's so the order of those needn't to be considered. I assume that having a 0 at first place is fine.
We now have to sum up these possibilities for all $k$:
$$
S=\sum_{k=0}^{\lfloor n/2\rfloor}\binom{n}{k}\binom{n-k}{k}
$$
I find this sum more understandable and better visible than yours :)
I was not able to find a general formula for that, but there are many applications which use this kind of calculation. You can have a look at this OEIS sequence https://oeis.org/A002426, there are some other forms of calculation as well as other application mentioned. Maybe one of those is helpful for you - however, most representations still use sums or asymptotic calculations
A: We find using OPs approach
\begin{align*}
\color{blue}{\sum_{k=0}^{\left\lfloor\frac{n}{2}\right\rfloor}\binom{2k}{k}\binom{n}{2k}}
&=\sum_{k=0}^{\left\lfloor\frac{n}{2}\right\rfloor}\frac{n!}{k!k!(n-2k)!}=\sum_{k=0}^{\left\lfloor\frac{n}{2}\right\rfloor}\frac{n!}{k!(n-k)!}\,\frac{(n-k)!}{k!(n-2k)!}\\
&\color{blue}{=\sum_{k=0}^{\left\lfloor\frac{n}{2}\right\rfloor}\binom{n}{k}\binom{n-k}{k}}\tag{1}
\end{align*}

In the following we use the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ of a series. We obtain from (1)
\begin{align*}
\color{blue}{\sum_{k=0}^{\left\lfloor\frac{n}{2}\right\rfloor}\binom{n}{k}\binom{n-k}{k}}
&=\sum_{k=0}^n\binom{n}{k}[z^k](1+z)^{n-k}\tag{2}\\
&=[z^0](1+z)^n\sum_{k=0}^n\binom{n}{k}\left(\frac{1}{z(1+z)}\right)^k\tag{3}\\
&=[z^0](1+z)^n\left(1+\frac{1}{z(1+z)}\right)^n\tag{4}\\
&\,\,\color{blue}{=[z^n]\left(1+z+z^2\right)^n}\tag{5}
\end{align*}
and observe (1) is a representation of the central trinomial coefficients (5).

Comment:

*

*In (2) we use the coefficient of operator $[z^k](1+z)^{n-k}=[z^k]\sum_{j=0}^{n-k}\binom{n-k}{j}z^j=\binom{n-k}{k}$.


*In (3) we factor out terms independent from $k$ and use the rule $[z^{p-q}]A(z)=[z^p]z^qA(z)$.


*In (4) we apply the binomial theorem.


*In (5) we simplify and  apply the rule stated in (3) again.
The following notes from the experts show there is  no closed form available for the  central trinomial coefficients:

D.E. Knuth gives in Concrete Mathematics, Appendix A 7.56 the following representation of a more general expression
\begin{align*}
[z^n](a+bz+cz^2)^n=[z^n]\frac{1}{\sqrt{1-2bz+(b^2-4ac)z^2}}\tag{6}
\end{align*}
He states that according to the paper Hypergeometric Solutions of Linear Recurrences with Polynomial Coeffcients by Marko Petkovšek there exists a closed form (more precisely: a closed form solution as a finite sum of hypergeometric terms) if and only if
$$\color{blue}{abc(b^2-4ac)=0}$$
In case of central trinomial coefficients we have $a=b=c=1$. Since then the expression $abc(b^2-4ac)=-3\ne 0$
there is no such closed form in particular for the central trinomial coefficients.

Note: Some might be interested how to obtain the right-hand side expression of (6). This can be done e.g. by a clever change of variables stated as rule 5 in section 1.2 of Integral Representation and the Computation of Combinatorial Sums by G. P. Egorychev. Rule 5 adapted for this special case is:
\begin{align*}
[z^n]f^{n}(z)
&=[y^n]\left.\frac{f(z)}{f(z)-zf^{\prime}(z)}\right|_{z=g(y)}\tag{7}
\end{align*}
Here we have $f(z)=1+z+z^2$ and $g=g(y)$ is the inverse function of
\begin{align*}
\frac{z}{f(z)}=\frac{z}{1+z+z^2}=y
\end{align*}
We obtain
\begin{align*}
yz^2&+(y-1)z+y=0\\
z&=\frac{1}{2y}\left(1-y\pm\sqrt{1-2y-3y^2}\right)\tag{8}
\end{align*}
We take from (8) the root $z$ with the minus sign, since this one represents a power series.

We obtain from (5), (7) and (8)
\begin{align*}
\color{blue}{[z^n]}&\color{blue}{\left(1+z+z^2\right)^n}\\
&=[y^n]\left.\frac{1+z+z^2}{1+z+z^2-z(1+2z)}\right|_{z=\frac{1}{2y}\left(1-y-\sqrt{1-2y-3y^2}\right)}\\
&=[y^n]\left.\frac{1+z+z^2}{1-z^2}\right|_{z=\frac{1}{2y}\left(1-y-\sqrt{1-2y-3y^2}\right)}\\
&\,\,\color{blue}{=[y^n]\frac{1}{\sqrt{1-2y-3y^2}}}
\end{align*}
corresponding to the right-hand side of (6).

A: As pointed out by LegNaiB, they correspond to OEIS A002425, which contains many references. Historically, they are also called trinomial coefficients, or in general $m$-nomial coefficients and they are often denoted by
$$
{n \choose 0}_2 
\quad \text{ or } \quad 
{n \choose n}_3 
\quad \text{ or } \quad 
{n, 3 \choose n}.
$$
(The notation is unfortunately not very uniform.)
See, e.g., the paper by Andrews https://doi.org/10.1090/S0894-0347-1990-1040390-4 in which he also gives two formulas on page 1 both involving a sum. Note that (1.2) is exactly your representation ;).
Moreover, he also mentions that these are the simplest ones, while neither of them is especially attractive.
For more details on the historial context see also page 27 in https://arxiv.org/pdf/1609.06473.pdf.
