A simple mathematical expression for the periodic sequence $(1, -2, -1, 2, 1, -2, -1, 2,\dots)$

Expanding on my comment:

$$\cos(\pi n/2) -2\sin(\pi n/2)$$


Per the OP's request, given the sequence, $$\alpha_n=1,-2,-1,2,1,-2,-1,1,\dots$$ and $\alpha_0=1$, we are to generate it using $(-1)^n$ and well-defined sequences of integers. The unsigned version is easy to do, $$\beta_n = \tfrac{3-(-1)^n}2=1,2,1,2,1,2,1,2,\dots$$ So the problem really is to generate the signs, $$U_n = 1,-1,-1,1,1,-1,-1,1,\dots$$ and fortunately answered by this post and this, $$U_n =(-1)^{n(n+1)/2} = \sqrt{2}\cos\tfrac{(2n+1)\pi}4$$

$\color{blue}{Update:}$ We also have the rather exotic, $$U_n = (-1)^{T_n}$$ with tribonacci numbers $T_n$, $$T_n=\sum_{k=0}^{n-1}\sum_{j=0}^{n-k-1}\tbinom{n-k-1}{j}\tbinom{j}{k-j}=\color{blue}0,1, 1, \color{blue}{2, 4}, 7, 13, \color{blue}{24, 44}, 81, 149, \color{blue}{274, 504},\dots$$ and $T_0=0$.

Alternatively, we seek, $$V_n = \tfrac{2n+1-(-1)^n}4= 0,1,1,2,2,3,3,4,\dots$$ which this post has considered. It then gives us three ways to form $\alpha_n$ as,

$$\alpha_n = \beta_n \,U_n=\tfrac{3-(-1)^n}2\,(-1)^{n(n+1)/2}\,=\,\tfrac{3-(-1)^n}2\,(-1)^{T_n}\tag1$$

and

$$\alpha_n = \beta_n \,(-1)^{V_n} = \tfrac{3-(-1)^n}2\,(-1)^{\frac14\big(2n+1-(-1)^n\big)}\tag2$$

P.S. For a signed sequence with period $5$, see here.


This can be done easily with Discrete Fourier Transform. Observe that $$ \operatorname{DFT}\begin{bmatrix}1\\-2\\-1\\2\end{bmatrix} = \begin{bmatrix} 0 \\ 1-2i \\ 0 \\ 1 + 2i \end{bmatrix} $$ Using the convention $$ \operatorname{DFT}(\mathbf{v})(\xi) = \frac{1}{\sqrt{n}} \sum_{x=0}^{n-1} \mathit{v}_x e^{2\pi i \xi x/n} $$ Hence the inverse DFT gives a periodic interpolation for your sequence: $$ f(x) = \frac{1 - 2i}{2} e^{-2\pi i x/4} + \frac{1 + 2i}{2} e^{-6\pi i x/4} $$ DFT