# Some formulae for a periodic sequence $-1,-1,1,1…$?

Some formulae for a periodic sequence?

when $T = 2$, we have $-1,1,-1,1,-1,1,\text{...}$, the formula is

\begin{align*}(-1)^n\end{align*}

when $T = 4$, we have $-1,-1,1,1,-1,-1,1,1\text{...}$, the formula is?

And how about the case $T=k$?

-
It could be useful in the future to keep in mind that it is rather, "a formula ..." than "the formula ...". – Mlazhinka Shung Gronzalez LeWy Sep 3 '13 at 2:17
Are you familiar with the floor function? – Blue Sep 3 '13 at 2:19
I think you can do this pretty easily with a combination of trig functions. – Dan Rust Sep 3 '13 at 2:24
@DanielRust My first thought is to seek something just some combination of $n$, Andre gave one trig answer. – Sequence Sep 3 '13 at 6:46
@Blue I've thought of that without deep thinking, not so familiar with that in doing math, just played in softwares. Dan gave one answer with floor. – Sequence Sep 3 '13 at 6:48

The clearest is $a_n=-1$ if $n$ leaves remainder $1$ or $2$ on division by $4$, and $a_n=1$ otherwise.

There are also conventionally "closed form" formulas, such as $$a_n=\sqrt{2}\cos\left(\frac{(2n+1)\pi}{4}\right).$$

-
This is good, is it have relations with the form in Dan's answer? – Sequence Sep 3 '13 at 6:44
Well, they give the same sequence, that's about it. – André Nicolas Sep 3 '13 at 6:47
Yes, that's a wonderful thing in math. – Sequence Sep 3 '13 at 6:49
Hi, how about the case $k=3$?, it's not $\sqrt{3} \cos \left(\frac{1}{6} \pi (3 n+1)\right)$ – Sequence Sep 4 '13 at 2:51
When $n=3$, the formula in my answer yields $\sqrt{2}\cos(7\pi/4)$, which is $1$, exactly as your sequence asks for. The $\sqrt{3}\cos(\frac{1}{6}\pi(3n+1))$ has no connection with the formula that I gave. – André Nicolas Sep 4 '13 at 2:56

It is a general fact that every periodic sequence $(x_n)$ of period $T$ is in the linear span of the sequences $\{e^T_k\,;\,1\leqslant k\leqslant T\}$, where, for every $n$, $$(e_k^T)_n=\mathrm e^{2\mathrm i \pi nk/T}.$$ That is, there exists $(a_k)_{1\leqslant k\leqslant T}$ such that, for every $n$, $$x_n=\sum_{k=1}^Ta_k(e_k^T)_n=\sum_{k=1}^Ta_k\mathrm e^{2\mathrm i \pi nk/T}.$$ To find $(a_k)_{1\leqslant k\leqslant T}$, one considers the equations above over one period, say for $1\leqslant n\leqslant T$, as a Cràmer system with unknowns $(a_k)_{1\leqslant k\leqslant T}$.

Example: Consider some sequence $x=(x_1,x_2,x_3,x_1,x_2,x_3,\ldots)$, then $T=3$, $$e_1^3=(j,j^2,1,j,j^2,1,\ldots),\quad e^3_2=(j^2,j,1,j^2,j,1,\ldots),\qquad e^3_3=(1,1,1,1,1,1,\ldots),$$ with $j=\mathrm e^{2\mathrm i\pi/3}$, and one looks for $(a_1,a_2,a_3)$ such that $x=a_1e^3_1+a_2e^3_2+a_3e^3_3$, that is, $$x_1=a_1j+a_2j^2+a_3,\quad x_2=a_1j^2+a_2j+a_3,\quad x_3=a_1+a_2+a_3.$$ Thus, $$3a_1=j^2x_1+jx_2+x_3,\quad 3a_2=jx_1+j^2x_2+x_3,\quad 3a_3=x_1+x_2+x_3,$$ which yields $x_n$ as a linear combination of $j^n$, $j^{2n}$ and $1$, namely, for every $n$, $$x_n=a_1j^n+a_2j^{2n}+a_3.$$

-

You can write it as $(-1)^{\large \lfloor \frac{2 \cdot n+T-2}{T} \rfloor}$.

If you defined things a bit differently (start counting from zero, parameterize the half period instead of the full period) you could just write $(-1)^{\large \lfloor \frac{n}{T} \rfloor}$.

-
But why? ${}{}{}{}$ – Pedro Tamaroff Sep 3 '13 at 2:26
hi, I would also like to know a little about why and how to obtain the formula, I've thought something about Mod, Ceiling and Floor. This is good, is it have some relations with the form in Andre's answer? – Sequence Sep 3 '13 at 6:44
One intuition is that you can associate raising $-1$ to a power with "alternating" and associate the floor function with "doubling", "tripling", etc. You can find the relationship between the answers in the Taylor series for cosine. – Dan Brumleve Sep 3 '13 at 6:49