# High School Mathematics Extensions/Counting and Generating Functions/Solutions

## Counting and Generating Functions

At the moment, the main focus is on authoring the main content of each chapter. Therefore this exercise solutions section may be out of date and appear disorganised.

If you have a question please leave a comment in the "discussion section" or contact the author or any of the major contributors.

These solutions were not written by the author of the rest of the book. They are simply the answers I thought were correct while doing the exercises. I hope these answers are useful for someone and that people will correct my work if I made some mistakes.

### Generating functions exercises

1.

(a)${\displaystyle S=1-z+z^{2}-z^{3}+z^{4}-z^{5}+...}$
${\displaystyle zS=z-z^{2}+z^{3}-z^{4}+z^{5}-...}$
${\displaystyle (1+z)S=1}$
${\displaystyle S={\frac {1}{1+z}}}$
(b)${\displaystyle S=1+2z+4z^{2}+8z^{3}+16z^{4}+32z^{5}+...}$
${\displaystyle 2zS=2z+4z^{2}+8z^{3}+16z^{4}+32z^{5}+...}$
${\displaystyle (1-2z)S=1}$
${\displaystyle S={\frac {1}{1-2z}}}$
(c)${\displaystyle S=z+z^{2}+z^{3}+z^{4}+z^{5}+...}$
${\displaystyle zS=z^{2}+z^{3}+z^{4}+z^{5}+...}$
${\displaystyle (1-z)S=z}$
${\displaystyle S={\frac {z}{1-z}}}$
(d)${\displaystyle S=3-4z+4z^{2}-4z^{3}+4z^{4}-4z^{5}+...}$
${\displaystyle z(S+1)=4z-4z^{2}+4z^{3}-4z^{4}+4z^{5}-...}$
${\displaystyle S+z(S+1)=3}$
${\displaystyle S+zS+z=3}$
${\displaystyle (1+z)S=3-z}$
${\displaystyle S={\frac {3-z}{1+z}}}$

2.

(a)${\displaystyle S={\frac {1}{1+z}}}$
${\displaystyle S={\frac {1}{1--z}}}$
${\displaystyle S=1-x+x^{2}-x^{3}+x^{4}-x^{5}+...}$
${\displaystyle f(n)=(-1)^{n}}$
(b)${\displaystyle S={\frac {z^{3}}{1-z^{2}}}}$
${\displaystyle (1-z^{2})S=z^{3}}$
${\displaystyle S=z^{3}+z^{5}+z^{7}+z^{9}+...}$
${\displaystyle f(n)=1;{\mbox{for n}}\geq 2{\mbox{ and even}}}$
${\displaystyle f(n)=0;{\mbox{for n is odd}}}$

2c only contains the exercise and not the answer for the moment

(c)${\displaystyle {\frac {z^{2}-1}{1+3z^{3}}}}$

#### Linear Recurrence Relations exercises

This section only contains the incomplete answers because I couldn't figure out where to go from here.

1.

${\displaystyle {\begin{matrix}x_{n}&=&2x_{n-1}&-&1;\ {\mbox{for n}}\geq 1\\x_{0}&=&1\end{matrix}}}$

Let G(z) be the generating function of the sequence described above.

${\displaystyle G(z)=x_{0}+x_{1}z+x_{2}z^{2}+...}$
${\displaystyle (1-2z)G(z)=x_{0}+(x_{1}-2x_{0})z+(x_{2}-2x_{1})z^{2}+...}$
${\displaystyle (1-2z)G(z)=1-z-z^{2}-z^{3}-z^{4}-...}$
${\displaystyle (1-2z)G(z)=1-z(1+z+z^{2}+...)}$
${\displaystyle (1-2z)G(z)=1-{\frac {z}{1-z}}}$
${\displaystyle (1-2z)G(z)={\frac {1-2z}{1-z}}}$
${\displaystyle G(z)={\frac {1}{1-z}}}$
${\displaystyle x_{n}=1}$

2.

${\displaystyle {\begin{matrix}3x_{n}&=&-4x_{n-1}&+&x_{n-2};\ {\mbox{for n}}\geq 2\\x_{0}&=&1\\x_{1}&=&1\\\end{matrix}}}$

Let G(z) be the generating function of the sequence described above.

${\displaystyle G(z)=x_{0}+x_{1}z+x_{2}z^{2}+...}$
${\displaystyle (3+4z-z^{2})G(z)=3x_{0}+(3x_{1}+4x_{0})z+(3x_{2}+4x_{1}-x_{0})z^{2}+(3x_{3}+4x_{2}-x_{1})z^{3}+...}$
${\displaystyle (3+4z-z^{2})G(z)=3x_{0}+(3x_{1}+4x_{0})z}$
${\displaystyle (3+4z-z^{2})G(z)=3+7z}$
${\displaystyle G(z)={\frac {3+7z}{-z^{2}+4z+3}}}$

3. Let G(z) be the generating function of the sequence described above.

${\displaystyle G(z)=x_{0}+x_{1}z+x_{2}z^{2}+...}$
${\displaystyle (1-z-z^{2})G(z)=x_{0}+(x_{1}-x_{0})z+(x_{2}-x_{1}-x_{0})z^{2}+(x_{3}-x_{2}-x_{1})z^{2}+...}$
${\displaystyle (1-z-z^{2})G(z)=1}$
${\displaystyle G(z)={\frac {1}{1-z-z^{2}}}}$
${\displaystyle G(z)={\frac {-1}{z^{2}+z-1}}}$
We want to factorize ${\displaystyle f(z)=z^{2}+z-1}$ into ${\displaystyle (z-\alpha )(z-\beta )}$ , by the converse of factor theorem, if (z - p) is a factor of f(z), f(p)=0.
Hence α and β are the roots of the quadratic equation ${\displaystyle z^{2}+z-1=0}$
Using the quadratic formula to find the roots:
${\displaystyle \alpha ={\frac {{\sqrt {5}}-1}{2}},\beta =-{\frac {{\sqrt {5}}+1}{2}}}$
In fact, these two numbers are the faomus golden ratio and to make things simple, we use the greek symbols for golden ratio from now on.
Note:${\displaystyle {\frac {{\sqrt {5}}-1}{2}}}$ is denoted ${\displaystyle \phi }$ and ${\displaystyle {\frac {{\sqrt {5}}+1}{2}}}$ is denoted ${\displaystyle \Phi }$
${\displaystyle G(z)={\frac {-1}{(z-\phi )(z+\Phi )}}}$
By the method of partial fraction:
${\displaystyle G(z)={\frac {1}{{\sqrt {5}}(z+\Phi )}}-{\frac {1}{{\sqrt {5}}(z-\phi )}}}$
${\displaystyle G(z)={\frac {1}{\Phi {\sqrt {5}}({\frac {z}{\Phi }}+1)}}-{\frac {1}{\phi {\sqrt {5}}({\frac {z}{\phi }}-1)}}}$
${\displaystyle G(z)={\frac {1}{\Phi {\sqrt {5}}(1--\phi z)}}+{\frac {1}{\phi {\sqrt {5}}(1-\Phi z)}}}$
${\displaystyle x_{n}={\frac {\phi }{\sqrt {5}}}\times (-\phi )^{n}+{\frac {\Phi }{\sqrt {5}}}\times \Phi ^{n}}$
${\displaystyle x_{n}={\frac {\Phi ^{n+1}-(-\phi )^{n+1}}{\sqrt {5}}}}$

### Further Counting exercises

1. We know that

${\displaystyle T(z)={\frac {1}{(1-z)^{2}}}=\sum _{i=0}^{\infty }{i+1 \choose i}z^{i}=\sum _{i=0}^{\infty }(i+1)z^{i}}$

therefore

${\displaystyle T(z)={\frac {1}{(1+z)^{2}}}=\sum _{i=0}^{\infty }(i+1)(-1)^{i}z^{i}}$
Thus
${\displaystyle T_{k}=(-1)^{k}(k+1)}$

2. ${\displaystyle a+b+c=m}$

${\displaystyle T(z)={\frac {1}{(1-z)^{3}}}=\sum _{i=0}^{\infty }{i+2 \choose i}z^{i}}$
Thus
${\displaystyle T_{k}={i+2 \choose i}}$

### *Differentiate from first principle* exercises

1.

${\displaystyle f'(z)=\lim _{h\to 0}{\frac {1}{(1-(z+h))^{2}}}-{\frac {1}{(1-z)^{2}}}=}$
${\displaystyle \lim _{h\to 0}{\frac {1}{h}}{\frac {(1-z)^{2}-(1-(z+h))^{2}}{(1-z-h)^{2}(1-z)^{2}}}=}$
${\displaystyle \lim _{h\to 0}{\frac {1}{h}}{\frac {z^{2}-2z+1-(z+h)^{2}+2(z+h)-1}{(1-z-h)^{2}(1-z)^{2}}}=}$
${\displaystyle \lim _{h\to 0}{\frac {1}{h}}{\frac {z^{2}-2z+1-z^{2}-h^{2}-2zh+2z+2h-1}{(1-z-h)^{2}(1-z)^{2}}}=}$
${\displaystyle \lim _{h\to 0}{\frac {1}{h}}{\frac {-h^{2}-2zh+2h}{(1-z-h)^{2}(1-z)^{2}}}=}$
${\displaystyle \lim _{h\to 0}{\frac {-h-2z+2}{(1-z-h)^{2}(1-z)^{2}}}=}$
${\displaystyle {\frac {-2z+2}{(1-z)^{4}}}=}$
${\displaystyle {\frac {-2}{(1-z)^{3}}}}$