Find a closed form for the recurrence relation: $a_{n+2}-a_n=\sin\frac{n \pi }{2} \;\;\;a_0=a_1=1$

closed-formgenerating-functionsrecurrence-relations

Find a closed form for the following recurrence relation:

$$a_{n+2}-a_n=\sin\frac{n \pi }{2} \;\;\;a_0=a_1=1\tag{$n \ge 0$}$$


This is what I've done so far:

Define a function $f(x):=\sum_{n\ge0}^{ }a_{n}x^{n}$,then:

$$\sum_{n\ge0}^{ }a_{n+2}x^{n+2}-x^{2}\sum_{n\ge0}^{ }a_{n}x^{n}=x^{2}\sum_{n\ge0}^{ }\sin\left(\frac{n\pi}{2}\right)x^{n}$$

The RHS is $\sum_{n\ge0}^{ }\sin\left(\frac{n\pi}{2}\right)x^{n}=\sum_{n\ge0}^{ }\left(-1\right)^{n}x^{2n+1}$
$$f\left(x\right)-a_{0}-a_{1}x-x^{2}f\left(x\right)=x^{3}\sum_{n\ge0}^{ }\left(-x^{2}\right)^{n}$$

Considering the initial values the equality transforms to:

$$f\left(x\right)-1-x-x^{2}f\left(x\right)=x^{3}\sum_{n\ge0}^{ }\left(-x^{2}\right)^{n}$$

\begin{align}
a_n=[x^n]f\left(x\right)
&=[x^n]\frac{2x^{3}+x^{2}+x+1}{\left(1+x^{2}\right)\left(1-x^{2}\right)}\\
&=\left[x^{n}\right]\left(\frac{5}{4}\frac{1}{1-x}-\frac{1}{4}\frac{1}{1+x}-\frac{1}{2}\frac{x}{1+x^{2}}\right)\\
&=\left[x^{n}\right]\left(\frac{5}{4}\sum_{n\ge0}^{ }x^{n}-\frac{1}{4}\sum_{n\ge0}^{ }\left(-1\right)^{n}x^{n}-\frac{1}{2}x\sum_{n\ge0}^{ }\underbrace{\binom{-1}{n}}_\text{=$(-1)^n$}x^{2n}\right)\\
&=\frac{5}{4}-\frac{1}{4}\left(-1\right)^{n}\end{align}

But the problem is that the answer is $$a_n=\frac{5}{4}-\frac{1}{4}\left(-1\right)^{n}-\frac{1}{2}\sin\frac{n\pi}{2}$$

And I don't understand why.

Best Answer

The main question is why the $\sin\left(\frac{n\pi}{2}\right)$ term is missing. There are two reasons:

  1. You are using $n$ as both a real index and a dummy index when you write things like $$ a_n = [x^n] \left( \frac{5}{4} \sum_{n \ge 0} x^n + \dots \right) $$ In $a_n$ and $[x^n]$, this refers to a specific index $n$, but in the summation, it is a dummy variable. Instead you should write $$ a_n = [x^n] \left( \frac{5}{4} \sum_{k \ge 0} x^k + \dots \right) $$ This is an extremely common mistake that even experienced mathematicians occasionally make.

  2. Because of the confusion introduced by (1), you effectively wrote $$ [x^n] \sum_{n \ge 0} (-1)^n x^{2n} = 0 $$ by dropping the last term on the right-hand side in your second-to-last equation. But actually the correct way to do this is $$ [x^n] \sum_{k \ge 0} (-1)^k x^{2k} = \begin{cases} (-1)^{n/2} & n\ \text{even} \\ 0 & n \ \text{odd} \end{cases} $$ If you try again with this change then you should get the correct answer. (I didn't check for algebra errors, but you can figure that part out.)

Related Question