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?
 A: A rather exotic formula uses tribonacci numbers $T_n$,
$$a_n = -(-1)^{T_n} = 1,1,-1,-1,1,1,-1,-1,\dots$$
where,
$$T_n=\sum_{k=0}^n\sum_{j=0}^{n-k}\tbinom{n-k}{j}\tbinom{j}{k-j}=1, 1, \color{blue}{2, 4}, 7, 13, \color{blue}{24, 44}, 81, 149, \color{blue}{274, 504},\dots$$
and we define $T_0=1$. 
P.S. The above has period $4$. For other periods which uses the Fibonacci numbers etc, see this post.
A: You can simply interpolate$(1,1,-1,-1)$, and then use $x=n\bmod4$:
$$a_n=\frac{2}{3}(n\bmod4)^3-5(n\bmod4)^2+\frac{31}{3}(n\bmod4)-5$$
A: Starting with $n=0$, these all work. 
$$\begin{align}
a_n&=(-1)^{n(n-1)/2}\\
a_n&=(-1)^{\left\lfloor\frac{n}{2}\right\rfloor}\\
a_n&=\cos(n\pi/2)+\sin(n\pi/2)\\
a_n&=\sqrt{2}\cdot\sin\big((2n+1)\tfrac{\pi}4\big)
\end{align}$$
If I'm being honest, being able to come up with these things for me comes from having seen them before.  But in each case you can think about the pattern of even/odd exponents for $-1$ or the periodicity mod 4 if you were trying to build these having no prior knowledge.
$\color{blue}{Update}:$ And modified from this post so it starts $a_0=1$,
$$\begin{align}
a_n&=\sqrt{2}\cdot\cos\big((2n-1)\tfrac{\pi}4\big)
\end{align}$$
A: 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}
A: I interpret your question as: "How can we define this sequence formally?"
A more general question is: how can we define $x = (a,a,b,b,a,a,b,b,a,a,\ldots)$ formally?
If you prefer the convention that sequences start at $0$, use:
$$x_i = \left\{\begin{aligned}
&a, && \mbox{if} \;{\left\lfloor\frac{i}{2}\right\rfloor} \in 2\mathbb{Z}\\
&b, && \mbox{if} \;{\left\lfloor\frac{i}{2}\right\rfloor} \in 2\mathbb{Z}+1
\end{aligned}
\right.$$
If you prefer the convention that sequences start at $1$, use:
$$x_i = \left\{\begin{aligned}
&a, && \mbox{if} \;{\left\lfloor\frac{i}{2}\right\rfloor} \in 2\mathbb{Z}+1\\
&b, && \mbox{if} \;{\left\lfloor\frac{i}{2}\right\rfloor} \in 2\mathbb{Z}
\end{aligned}
\right.$$

The above definitions are "set-theoretic." But we can also give an "algebraic" definition. This has the benefit that our numbering conventions become irrelevant. We begin by telling the reader that by $\sum$, we mean concatenation of sequences. Then we write: $$x = \sum_{n \in \mathbb{N}} (a,a,b,b)$$
A: The sequence of exponents of $-1$ (i.e. $0,0,1,1,0,0,1,1,\cdots$ but also $0,0,1,1,2,2,3,3\cdots$) can follow the recurrence
$$e_{n+2}=e_n+1,\\e_0=e_1=0.$$
The general solution is given by 
$$e_n=\frac n2+c_0+c_1(-1)^n$$ and you can determine the constants from the initial conditions, giving
$$e_n=\frac n2-\frac{1-(-1)^n}4.$$
The method generalizes to runs of length $k$, involving the $k^{th}$ roots of the unit.
A: The sequence $\{a_0,a_1,a_2, \dots \}$ with $a_n$ defined as the coefficient of the $n$th power of $x$ in the expansion of $(1+x)/(1+x^2)$ will do.
