What is a mathematical expression for the sequence $\{1,1,-1,-1,1,1,-1,-1,\dots\}$? What is a mathematical expression for the sequence $\{1,1,-1,-1,1,1,-1,-1,\dots\}$, that is $1$ and $-1$, two at a time alternating?

The sequence $a_0=1$, $a_1=1$, $a_2=-1$, $a_3=-1$, $a_4=1$ and so on satisfies the recursion
$$
a_0=1,\quad a_1=1,\qquad a_{n+2}=-a_n
$$
so its characteristic equation is $t^2+1=0$. Thus the general solution is of the form
$$
xi^n+y(-i)^n
$$
The initial conditions tell that $x+y=1$ and $xi-yi=1$, thus
$$
\begin{cases}
x+y=1\\[4px]
x-y=-i
\end{cases}
$$
that gives
$$
x=\frac{1-i}{2},\quad y=\frac{1+i}{2}
$$
Since $i=\cos\frac{\pi}{2}+i\sin\frac{\pi}{2}$, we can write
\begin{align}
a_n
&=\frac{1}{2}\bigl(
  (1-i)(\cos\tfrac{n\pi}{2}+i\sin\tfrac{n\pi}{2})+
  (1+i)(\cos\tfrac{n\pi}{2}-i\sin\tfrac{n\pi}{2})
\bigr)\\[6px]
&=\cos\frac{n\pi}{2}+\sin\frac{n\pi}{2}
\end{align}
