%
% This is the LaTeX template file for preparing lecture notes for 
% courses taught by Neil Calkin.  When preparing 
% LaTeX notes for this class, please use this template.
%
% The body contains examples: study them, run 
%
%	pdflatex <yourfilename.tex>
%
% and see how they work.   View the output file with acrobat,
% or print it out to compare input and result.
%
%
%
%
%


\documentclass{article}
\usepackage{epsfig,amsmath,amssymb}
\usepackage{graphicx}
\usepackage{fullpage}
%
% The following commands set up the lecnum (lecture number)
% counter and make various numbering schemes work relative
% to the lecture number.
%
\newcounter{lecnum}
\renewcommand{\thepage}{\thelecnum-\arabic{page}}
\renewcommand{\thesection}{\thelecnum.\arabic{section}}
\renewcommand{\theequation}{\thelecnum.\arabic{equation}}
\renewcommand{\thefigure}{\thelecnum.\arabic{figure}}
\renewcommand{\thetable}{\thelecnum.\arabic{table}}

%
% The following macro is used to generate the header.
%
\newcommand{\lecture}[4]{
   \pagestyle{myheadings}
   \thispagestyle{plain}
   \newpage
   \setcounter{lecnum}{#1}
   \setcounter{page}{1}
   \noindent
   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 6.28in { {\bf Combinatorial Analyis
                        \hfill Fall 2010} }
       \vspace{4mm}
       \hbox to 6.28in { {\Large \hfill Lecture #1: #2  \hfill} }
       \vspace{2mm}
       \hbox to 6.28in { {\it Lecturer: #3 \hfill Scribe: #4} }
      \vspace{2mm}}
   }
   \end{center}
   \markboth{Lecture #1: #2}{Lecture #1: #2}
   {\bf Disclaimer}: {\it These notes are intended for students in the class
listed above: they are not guaranteed to be complete or even necessarily
correct.  They may only be redistributed with permission, which you may
expect will be liberally granted.  Ask first, please.} \vspace*{4mm}
}

%
% Convention for citations is authors' initials followed by the year.
% For example, to cite a paper by Leighton and Maggs you would type
% \cite{LM89}, and to cite a paper by Strassen you would type \cite{S69}.
% (To avoid bibliography problems, for now we redefine the \cite command.)
% Also commands that create a suitable format for the reference list.
\renewcommand{\cite}[1]{[#1]}
\def\beginrefs{\begin{list}%
        {[\arabic{equation}]}{\usecounter{equation}
         \setlength{\leftmargin}{2.0truecm}\setlength{\labelsep}{0.4truecm}%
         \setlength{\labelwidth}{1.6truecm}}}
\def\endrefs{\end{list}}
\def\bibentry#1{\item[\hbox{[#1]}]}

%Use this command for a figure; it puts a figure in wherever you want it.
%usage: \fig{NUMBER}{SPACE-IN-INCHES}{CAPTION}
\newcommand{\fig}[3]{
			\vspace{#2}
			\begin{center}
			Figure \thelecnum.#1:~#3
			\end{center}
	}
% Use these for theorems, lemmas, proofs, etc.
\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newenvironment{proof}{{\bf Proof:}}{\hfill\rule{2mm}{2mm}}


\def\Z{\hbox{$\mathbb Z$}}
\def\Q{\hbox{$\mathbb Q$}}
\def\R{\hbox{$\mathbb R$}}
\def\N{\hbox{$\mathbb N$}}
\def\C{\hbox{$\mathbb C$}}



% **** IF YOU WANT TO DEFINE ADDITIONAL MACROS FOR YOURSELF, PUT THEM HERE:

\begin{document}
%FILL IN THE RIGHT INFO.
%\lecture{**LECTURE-NUMBER**}{**DATE**}{**LECTURER**}{**SCRIBE**}
\lecture{4}{August 25}{Neil Calkin}{Charles Pilman and Anna Keaton}

\begin{flushleft}


\section{Counting Strings Without Consecutive Ones:}

We saw last class that the set of binary strings can be be expressed as $0^*(11^*00^*)^*1^*$.
Furthermore, we saw that strings without adjacent ones can be expressed as
$0^*(100^*)^*(\epsilon \cup 1)$.

\subsection{Generating function:}

The generating function for $0^*$, with $x$ marking length is 
\[1+x+x^2+... = \frac{1}{1-x}.\]

The generating function for $\epsilon \cup 1$, with $x$ marking length is \[1+x.\]

The generating function for $100^*$, with $x$ marking length is \[x^2+x^3+x^4+x^5+...=\frac{x^2}{1-x}.\]

The generating function for $(100^*)^*$, with $x$ marking length is 
\[1+\frac{x^2}{1-x}+\left(\frac{x^2}{1-x}\right)^2+\left(\frac{x^2}{1-x}\right)^3+...
=\frac{1}{1-\frac{x^2}{1-x}}.\]

\indent

So the generating function for $0^*(100^*)^*(\epsilon \cup 1)$ is 
\[\frac{1}{1-x}\cdot\frac{1}{1-\frac{x^2}{1-x}}\cdot(1+x)=\frac{1+x}{1-x-x^2}.\]

\indent

\subsection{Deriving Sequence from Generating Function:}

How do we get the Fibonacci numbers out of $\frac{1+x}{1-x-x^2}$?

Suppose $f(x)=f_0+f_1x+f_2x^2+...=\displaystyle\sum\limits_{n\geq0}f_nx^n$,
and $f(x)=\frac{1+x}{1-x-x^2}$, that is, $(1-x-x^2)f(x)=1+x$.

\indent

Then
$  [x^n](1-x-x^2)f(x)=[x^n](1+x)= \left\{
     \begin{array}{ll}
       1 & : n=0,1\\
       0 & : n\geq 2
     \end{array}
   \right.$

\indent

\[[x^n]f(x)-xf(x)-x^2f(x)=
([x^n]f(x))-([x^{n-1}]f(x))-([x^{n-2}]f(x))=
f_n-f_{n-1}-f_{n-2}, \text{if } n\geq 2.\]

\indent

So, if $n\geq2$, $f_n-f_{n-1}-f_{n-2}=0.$

So $f_n=f_{n-1}+f_{n-2}.$

If $n=1$, we get $f_1-f_0=1.$

If $n=0$, we get $f_0=1.$

So $f(x)=1+2x+3x^2+5x^3+8x^4+...$

And the $f_n$'s are (when suitably indexed) the Fibonacci numbers.

\subsection{Exercises:}

\textbf{Exercise TBHI:} By considering strings of length $n$ starting with 0, and strings of length $n$ starting with 1, (without adjacent 1's) show combinatorially that  $f_n=f_{n-1}+f_{n-2}$ for $n\geq 2$.

\indent

\textbf{Exercise TBHI:} Reverse the argument above, and use $f_0=1$ and $f_1=2$ to show $(1-x-x^2)f(x)=1+x$ and hence $f(x)=\frac{1+x}{1-x-x^2}$.

\indent

\textbf{Exercise TBHI:} By considering strings (without adjacent 1's) of length 2n+1 (or, more generally, $m+n+1$) and separating them according to whether the middle bit is 0 or 1, show combinatorially that $f_{2n+1}=f_n^2+f_{n-1}^2$ ($f_{m+n+1}=f_mf_n+f_{m-1}f_{n-1}$, respectively).

\indent

\subsection{Generating Function Growth:}

How fast does $f_n$ grow?

\indent

Note that since $f_n$ is an increasing sequence,

$f_n<2f_{n-1},$ if $n\geq2$.

$f_n>2f_{n-2},$ if $n\geq2$.

\indent

Hence, since $f_1=2^1$, $f_n<2^n$ for $n\geq2$.
And since $f_0=(2^{1/2})^n$ for all $n\geq1$.
So for all $n\geq0$, $(2^{1/2})^n\leq f_n\leq 2^n$.

\subsection{Further Analysis of $f_n$:}

If $f_n$ were exactly $c\alpha ^n$ (which it is not!) then we would have
$c\alpha ^n=c\alpha ^{n-1}+c\alpha ^{n-2}$.

So, $\alpha=0,$
or $c=0,$
or $\alpha ^2-\alpha-1=0$.

$\alpha=\frac{1\pm\sqrt{5}}{2}=1.6...$ or $-.6...$

\indent

Now observe that if $\alpha_1=\frac{1+\sqrt{5}}{2}$
and $\alpha_2=\frac{1-\sqrt{5}}{2}$
then $g_n=c_1\alpha_1^n+c_2\alpha_2^n$
also satisfies $g_n=g_{n-1}+g_{n-2}$.

If we solve  $c_1\alpha_1^0+c_2\alpha_2^0=1$
and $c_1\alpha_1^1+c_2\alpha_2^1=2$,
then $g_n=c_1\alpha_1^n+c_2\alpha_2^n=f_n$
for all $n$ by induction.
$\left( \begin{array}{cc}
       1 & 1\\
       \alpha_1 & \alpha_2
     \end{array} \right)
\left( \begin{array}{c}
       c_1\\
       c_2
     \end{array} \right)=
\left( \begin{array}{c}
       1\\
       2
     \end{array} \right)$.

Since $\alpha_1\neq\alpha_2$, 
$\left( \begin{array}{cc}
       1 & 1\\
       \alpha_1 & \alpha_2
     \end{array} \right)$
is invertible, and hence this system $\emph{does}$ have a solution:

$c_1+c_2=1$

$\frac{c_1}{2}+\frac{c_1\sqrt{5}}{2}+\frac{c_2}{2}-\frac{c_2\sqrt{5}}{2}=2$

$c_1+c_2+(c_1-c_2)\sqrt{5}=4$

$c_1-c_2=\frac{3}{\sqrt{5}}$

$c_1=\frac{1}{2}\left(1+\frac{3}{\sqrt{5}}\right)=\frac{1}{2}\left(1+\frac{3\sqrt{5}}{5}\right)$.

$c_2=\frac{1}{2}\left(1-\frac{3}{\sqrt{5}}\right)=\frac{1}{2}\left(1-\frac{3\sqrt{5}}{5}\right)$.

\indent

So,
$f_n=\frac{1}{2}\left(1+\frac{3\sqrt{5}}{5}\right)\left(\frac{1+\sqrt{5}}{2}\right)^n
+\frac{1}{2}\left(1-\frac{3\sqrt{5}}{5}\right)\left(\frac{1-\sqrt{5}}{2}\right)^n$.

Note that 
$\left|\frac{1}{2}\left(1-\frac{3\sqrt{5}}{5}\right)\right|<\frac{1}{2}$

and
$\left|\frac{1-\sqrt{5}}{2}\right|<1$

so
$\left|\frac{1}{2}\left(1-\frac{3\sqrt{5}}{5}\right)\left(\frac{1-\sqrt{5}}{2}\right)^n\right|<\frac{1}{2}$.

And so $f_n$ is the closest integer to $\frac{1}{2}\left(1-\frac{3\sqrt{5}}{5}\right)\left(\frac{1-\sqrt{5}}{2}\right)^n$.

\subsection{Back to $f(x)=\frac{1+x}{1-x-x^2}$:}

If we consider $\frac{1}{1-\beta x}$,
with constant $\beta$, as a formal power series,

we have $\frac{1}{1-\beta x}=1+\beta x+\beta^2 x^2+\beta^3 x^3+...$

So, if we could write $\frac{1+x}{1-x-x^2}$ as 
 $\frac{c_1}{1-\alpha_1 x}+\frac{c_2}{1-\alpha_2 x}$
then $f_n=c_1 \alpha_1^n+c_2 \alpha_2^n$.

\indent

To find $c_1,c_2,\alpha_1,\alpha_2$:

we need $(1-\alpha_1 x)(1-\alpha_2 x)=1-x-x^2$

or $\alpha_1+\alpha_2=1$, $\alpha_1\alpha_2=-1$
\[\alpha_2=\frac{-1}{\alpha_1}\]
\[\alpha_1-\frac{1}{\alpha_1}=1\]
\[\alpha_1^2-1=\alpha_1\]
\[\alpha_1^2-\alpha_1-1=0\]
\[\alpha_1=\frac{1+\sqrt{5}}{2}, \alpha_2=\frac{1-\sqrt{5}}{2}\]
\[\frac{1+x}{(1-\alpha_1 x)(1-\alpha_2 x)}=\frac{c_1}{1-\alpha_1 x}+\frac{c_2}{1-\alpha_2 x}\]
So,
\[c_1(1-\alpha_2 x)+c_2(1-\alpha_1 x)=1+x\]
\[c_1+c_2=1\]
\[c_1\alpha_2+c_2\alpha_1=-2\]
Solve, and obtain the same values as before.

\end{flushleft}

\end{document}
