TITLE: Counting binary sequences with no more than $2$ equal consecutive numbers
QUESTION [20 upvotes]: I invented the following problem, but I can't solve it.
There are $n$ $1$'s and $n$ $0$'s and my question is what is the number of ways to arrange them avoiding $3$ equal consecutive numbers.
So for instance, $n=3$ gives 001011, 001101, 010011, 010101, 010110, 011001, 011010, and the same sequences that start with $1$, that's $14$ in total. The first values are: $2,6,14,34,84,208$. (starting with $n=1$) It seems to be almost an exponential function.
I started defining the function $N(a,b)$ which gives all possible sequences with $a$ zeroes and $b$ ones such that no $3$ consecutive numbers are equal, and that begin with a $0$.
The same for $E(a,b)$ which gives all possible sequences with $a$ zeroes and $b$ ones such that no $3$ consecutive numbers are equal, and that begin with a $1$.
It's not hard to see that $N(a,b)=E(b,a)$.
I found a kind of recursive formula for $N(a,b)$.
Such a sequence can start with $00$. The rest of it is a sequence that starts with a $1$, that gives $E(a-2,b)=N(b,a-2)$ possibilities.
If it starts with $01$, every tail is possible unless those that start with $11$. The question is what this number of sequences is that start with $11$. But because after these two $1$'s comes a $0$, it's simply $N(a-1,b-3)$.
Adding everything up gives $$N(a,b)=N(a-1,b-1)+N(b-1,a-1)+N(b,a-2)-N(a-1,b-3).$$
This is another approach of mine:
Every sequence consists a certain number of series of $1$'s and of $0$'s. Let $n$ be divisible by $2$ (The other case is almost the same.)
The number of series is at least $n/2$ and at most $n$. The number of $0$-series can be equal to or one more then the number of $1$-series. Because every series has at least one element, the total is $$N(a,a)=1+\sum_{k=n/2}^{n-1}\binom{k}{n-k}\left(\binom{k}{n-k}+\binom{k+1}{n-k-1}\right)$$ but this summation is not worth being called a solution. And I can't simplify it.
That's all I have found.
Maybe these OEIS references may help you answering my question:
http://oeis.org/A177790
http://oeis.org/A003440
And here's a list of $N(a,b)$ for $a,b\leq 10$. ($a$ increases to the right and $b$ increases downwards)
$$\begin{array}{|c|c|} \hline
b\backslash a&0&1&2&3&4&5&6&7&8&9&10\\ \hline
0&&1&1&0&0&0&0&0&0&0&0\\ \hline
1&0&1&2&2&1&0&0&0&0&0&0\\ \hline
2&0&1&3&5&5&3&1&0&0&0&0\\ \hline
3&0&0&2&7&12&13&9&4&1&0&0\\ \hline
4&0&0&1&6&17&29&33&26&14&5&1\\ \hline
5&0&0&0&3&16&42&71&84&72&45&20\\ \hline
6&0&0&0&1&10&42&104&175&214&196&136\\ \hline
7&0&0&0&0&4&30&110&259&434&545&527\\ \hline
8&0&0&0&0&1&15&86&286&648&1082&1389\\ \hline
9&0&0&0&0&0&5&50&241&741&1627&2709\\ \hline
10&0&0&0&0&0&1&21&156&663&1916&4098\\ \hline
\end{array}$$
(I can always make it longer if someone asks me to.)

REPLY [5 votes]: I'll complete the work begun by Christian Blatter:
Let 
$$
s(x,y) \;=\; 
\frac
{\left(1+x+x^2\right) \left(1+y+y^2\right)}
{1-\left(x+x^2\right) \left(y+y^2\right)}
$$ 
as above.
Note, that this follows immediately from the fact that allowed words consist of a sequence of elements from {01, 011, 001, 0011} optionally preceded by 1 or 11 and followed by 0 or 00. Hence the class of allowed words is
$$
\mathcal{S}\;=\;
(\mathcal{E}+\mathcal{Z_1}+\mathcal{Z_1}^2)
\times
\text{SEQ}((\mathcal{Z_0}+\mathcal{Z_0}^2)\times(\mathcal{Z_1}+\mathcal{Z_1}^2))
\times
(\mathcal{E}+\mathcal{Z_0}+\mathcal{Z_0}^2)
$$
which translates directly to give $s(x,y)$.
If we let
$$
g(x) \;=\; g(z,x) \;=\; s(x\sqrt{z},\sqrt{z}/x) \;=\;
\frac
{\left(x^2+x \sqrt{z}+z\right) \left(1+x \sqrt{z}+x^2 z\right)}
{x^2 (1 - z - z^2) - x (1 + x^2) z \sqrt{z}},$$
then the constant term of $g(x)$ (i.e. coefficient of $x^0$ in the expansion of $g(x)$) gives the generating function $h(z)$ for sequences with the same number of $0$s and $1$s where the exponent of $z$ records the half-length. This is what we require.
Now, the constant term in a function $g(x)=g(z,x)$ is given by the sum of the residues of $g(x)/x$ at those poles $\alpha$ of $g(x)$ for which $\lim\limits_{z\rightarrow0}\alpha(z)=0$ (see e.g. Stanley, Enumerative Combinatorics II Sect. 6.3).
It simply remains to work through the details. There are two suitable poles (at $x=0$ and $x=\frac{1-z-z^2-\sqrt{1-2 z-z^2-2 z^3+z^4}}{2 z \sqrt{z}}$). Summing the residues of $g(x)/x$ at these values gives
$$
h(z)\;=\;
\frac{(1-z)^2 \sqrt{1+z+z^2}}{z^2 \sqrt{1-3 z+z^2 }}
-\frac{1}{z^2}.
$$
Since the radius of convergence of $h(z)$ is $\frac{1}{2} \left(3-\sqrt{5}\right)$, the growth rate is its reciprocal $\frac{1}{2} \left(3+\sqrt{5}\right) \approx 2.56126$.