Trying to solve a recurrence relation by using generating functions: $a_n=3a_{n-1} + a_{n-2}$

discrete mathematicsgenerating-functionsrecurrence-relations

I'm trying to solve the recurrence relation below by using generating function:

\begin{equation}
a_n=\begin{cases}
0, & \text{if $n<0$}\\
2, & \text{if $n=0$}\\
1, & \text{if $n=1$}\\
3a_{n-1} + a_{n-2}, & \text{otherwise}.
\end{cases}
\end{equation}

The first thing I did was make the recurrence relation valid for all $n$ by using a kronecker delta:

$a_0 = 3.(0) + 0 + 2.(\delta_{n,0}) = 2$

$a_1 = 3.(2) + 0 – 5.(\delta_{n,1}) = 1$

The result I got was:

$$a_n = 3a_{n-1} + a_{n-2} + 2\delta_{n,0} – 5\delta_{n,1}$$

Multiplying by $x^n$:

$$a_n . x^n = 3a_{n-1} . x^n + a_{n-2} . x^n + 2\delta_{n,0} . x^n – 5\delta_{n,1} . x^n$$

Summing up both sides:

$$\sum_{n\geq0} a_n . x^n = \sum_{n\geq0}3a_{n-1} . x^n + \sum_{n\geq0}a_{n-2} . x^n + \sum_{n\geq0}2\delta_{n,0} . x^n – \sum_{n\geq0}5\delta_{n,1} . x^n$$

And making $F(x) = \sum_{n\geq0} a_n . x^n$, I got:

$$F(x) = 3xF(x) + x^2F(x) + 2 – 5x$$

which is:

$$F(x) = \frac{2 – 5x}{1-3x-x^2}$$

So far so good but from here on I can't find a way to calculate the $a_n$

I've heard it has something to do with partials fractions but I'm a newbie in this subject and I have no idea how to follow through.

Does anyone can help me to finish the calculation?

Thanks in advance.

Best Answer

I'm going to rewrite the problem as $$a_{n+2} = 3a_{n+1} + a_n; \; a_0 = 2,\; a_1=1.$$ Multiply by $x^n$, sum, and let $A(x) = \sum_{n\ge 0}a_nx^n$. So, $$\sum_{n\ge 0}a_{n+2}x^n = 3\sum_{n\ge 0}a_{n+1}x^n + \sum_{n\ge 0}a_n x^n,$$ and we can see that $\sum_{n\ge 0}a_{n+2}x^n = a_2 + a_3x + \cdots = (1/x^2)(A(x)-a_0-a_1x)$ and similarly $\sum_{n\ge 0}a_{n+1}x^n = a_1 + a_2x + \cdots = (1/x)(A(x)-a_0)$, so we obtain $$\frac{1}{x^2}(A(x) - a_0 - a_1x) = \frac{3}{x} (A(x)-a_0 ) + A(x).$$

Substituting for $a_0$ and $a_1$ and solving for $A(x)$ yields your $F(x)$, ie $$A(x) = \frac{2-5x}{1-3x-x^2}.$$

Now the for the partial fraction decomposition, which is not so ugly if we keep our heads straight. Note that $1-3x-x^2$ has roots $\alpha_1 = -\frac{3}{2} - \frac{\sqrt{13}}{2}$ and $\alpha_2 = -\frac{3}{2} + \frac{\sqrt{13}}{2}$ and we want $$\frac{1}{1-3x-x^2} = \frac{1}{(x-\alpha_1)(x-\alpha_2)} = \frac{A}{(x-\alpha_1)} + \frac{B}{(x-\alpha_2)}.$$ Using this equation and solving for $A$ and $B$ yields \begin{align} \frac{1}{1-3x-x^2} &= \frac{1}{(\alpha_1-\alpha_2)(x-\alpha_1)} + \frac{1}{(\alpha_2-\alpha_1)(x-\alpha_2)}\\ &=\frac{1}{-\sqrt{13}(x-\alpha_1)} + \frac{1}{\sqrt{13}(x-\alpha_2)} \end{align}

So we have

\begin{align} A(x) &= (2-5x)\left(\frac{1}{-\sqrt{13}(x-\alpha_1)} + \frac{1}{\sqrt{13}(x-\alpha_2)} \right)\\ &=(2-5x) \left( \frac{1}{\alpha_1\sqrt{13}} \cdot \frac{1}{1-(x/\alpha_1)} + \frac{1}{-\alpha_2\sqrt{13}} \cdot \frac{1}{1-(x/\alpha_2)} \right)\\ &= (2-5x) \left( \frac{1}{\alpha_1\sqrt{13}} \sum_{n\ge 0} \left(\frac{1}{\alpha_1} \right)^n x^n + \frac{1}{-\alpha_2\sqrt{13}} \sum_{n\ge 0} \left(\frac{1}{\alpha_2} \right)^n x^n \right)\\ &= \frac{(2-5x)}{\sqrt{13}} \left(\sum_{n\ge 0} \left[ \left(\frac{1}{\alpha_1} \right)^{n+1} - \left(\frac{1}{\alpha_2} \right)^{n+1}\right] x^n \right) \end{align}

Can you take it from here?