<s>[INST] Find a closed form for the recurrence relation: $a_{n+2}-a_n=\sin\frac{n \pi }{2} \;\;\;a_0=a_1=1$ 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.
 [/INST] Since a generating function answer has already been provided, I'll instead provide the direct proof. Note that
$$a_{n+2}=a_n+\sin(n\pi /2)=a_{n-2}+\sin((n-2)\pi/2)+\sin(n\pi/2).$$
But $\sin(n\pi/2-\pi)=-\sin (n\pi/2)$, so $a_{n+2}=a_{n-2}$. Hence the sequence is 4-periodic, and it suffices to know the first four entries. We have $a_0=a_1=1$ by assumption, and therefore also $$a_2=a_0+\sin(0\pi/2)=a_0=1,$$ $$a_{3}=a_1+\sin(\pi/2)=a_1+1=2.$$
We conclude that $a_{n}=2$ if $n\bmod 4=3$ and $a_n=1$ otherwise.
</s>