0

I let $a_n$ be the different sequences with $n$ digits such that there is at least one instance of consecutive $2$'s. This is what I did, if I place a a $1$ first, I have $n-1$ digits left and by definition, I have $a_{n-1}$ different sequences with $n-1$ digits...one instance of consecutive $2$'s. Next case: Now instead of placing one $2$ I place two $2$'s such that I have my met condition. What follows in the next $n-2$ digits may or may not have an instance of consecutive $2$'s but I don't care anymore. With that being said, there are $2$ to the $(n-2)$ different sequences left. So my recurrence relation is $a_n = a_{n-1} + 2^{n-2}$. What's wrong with my recurrence relation? Thank you in advance for your time.

  • 1
    There seems to be some confusion: first, binary digits are usually thought of as on the alphabet ${0,1}$, not ${1,2}$; more importantly, here you distinction of cases is "either start by a $1$, or by 2 $2's$." This does not cover all cases. If you go that way, then it either starts by a $1$, or by $21$, or by $22$. ($3$ cases, not $2$) – Clement C. Oct 08 '15 at 14:34
  • You can note that there are $2^n$ total sequences and subtract the ones that do not have consecutive $2$'s, seen here, here, and here – Ross Millikan Oct 08 '15 at 16:09
  • pretty sure I didn't do the third case as @clement stated. I thought about doing that but i'd be defining a new recurrence relation and wouldn't be using my original one... – ponderingdev Oct 08 '15 at 19:38

1 Answers1

0

A sequence of length $n$ with at least one instance of two consecutive $2$'s is arrived at in one of two ways: first, the initial $n-1$ elements already contain a two consecutive $2$'s, in which case the last digit can be either $1$ or $2$. Second, the initial $n-3$ elements do not contain such a sequence, and the $n-2^{\mathrm{nd}}$ element is a $1$; in this case, we add $22$ to the end (the reason for requiring the $n-2^{\mathrm{nd}}$ element to be $1$ is to avoid double counting a sequence ending in $222$. We thus get $$a_1 = 0,\ a_2 = 1,\ a_3 = 2,\ a_n = 2a_{n-1}+(2^{n-3}-a_{n-3}),\ n>3.$$ Thus $a_n = 2^{n-3} + 2a_{n-1}-a_{n-3}$, and the first ten $a_i$ are $$0, 1, 3, 8, 19, 43, 94, 201, 423, 880.$$

This sequence satisfies $a_n = 2^n - F_{n+2}$; thus for example $a_3 = 8-f_5 = 8-5 = 3$. To see this, write \begin{align} g(x) &= \sum_{n=1} a_nx^n = x^2 + 3x^3 + \sum_{n=4}a_nx^n \\ &= x^2 + 3x^3 + 2\sum_{n=4}a_{n-1}x^n + \sum_{n=4}2^{n-3}x^n - \sum_{n=4}a_{n-3}x^n \\ &= x^2 + 3x^3 + 2x\sum_{n=4}a_{n-1}x^{n-1} + x^3\sum_{n=4}2^{n-3}x^{n-3} - x^3\sum_{n=4}a_{n-3}x^{n-3} \\ &= x^2 + 3x^3 + 2x\sum_{n=3}a_nx^n + x^3\sum_{n=1}(2x)^n - x^3\sum_{n=1}a_nx^n \\ &= x^2 + 3x^3 + 2x(-x^2 + g(x)) + x^3\left(-1+\frac{1}{1-2x}\right) - x^3g(x) \\ &= x^2 + (2x-x^3)g(x) + \frac{x^3}{1-2x}. \end{align} Solving for $g(x)$ gives $$g(x) = \frac{x^2}{(1-2x)(x^2+x-1)} = \frac{1}{1-2x} + \frac{1+x}{x^2+x-1}.$$ The first of these is just the series $\sum 2^nx^n$ while the second is $$\frac{1+x}{x^2+x-1} = \frac{1}{x^2+x-1} + \frac{x}{x^2+x-1} = \sum (-F_nx^n - F_{n+1}x^n) = \sum (-F_{n+2})x^n,$$ so their sum is $g(x) = \sum_n (2^n-F_{n+2})x^n.$

This is sequence A008466 at oeis. There is undoubtedly a combinatorial way to see this formula.

rogerl
  • 22,399