# Looking for series that suits 1,1,-1,-1,1,1,-1,-1 ..

I'm looking for a series that will give me 1,1,-1,-1,1,1,-1,-1 ......

The best I came up with is:

$a_n =sin(n\pi/2)+cos(n\pi/2)$

But I am looking for something more elegant. It is important that it will suit for all $n>=0$

• I think most mathematicians would consider $\sin(n\pi/2) + \cos(n\pi/2)$ to be needless obfuscation, even if it's done for the (questionable) purpose of providing a unified closed-form expression. Probably: $$a_n = \begin{cases} 1, & n \equiv 0~\mathrm{or}~1 \pmod{4}; \\ -1, & n \equiv 2~\mathrm{or}~3 \pmod{4} \end{cases}$$ would be the clearest way to express it. Commented Jun 16, 2017 at 19:12

## 4 Answers

$$u_n=(-1)^{\lfloor \frac {n}{2}\rfloor}$$

or $$u_{2n}=u_{2n+1}=(-1)^n$$

I found the formula $$u_n = i^{n(n-1)}$$ on the OEIS. It's credited to Bruno Berselli, 2010.

• $(-1)^{n(n-1)/2}$ seems a more logical way to write it. Commented Jun 16, 2017 at 22:34
• @eyeballfrog More logical? Logic isn't a continuum; either it's logical or it's not. Commented Jun 16, 2017 at 22:55
• @eyeballfrog this would be a nice answer. Commented Jun 16, 2017 at 23:34

$a_n = \sqrt{2} \sin[(2n+1)\pi/4]$

• it is a same as the OP mentioned Commented Jun 16, 2017 at 22:33
• i understand your point, but here we have only one trig function involved. Commented Jun 16, 2017 at 22:44

$$u_0=1$$

$$u_n=(-1)^{n-1}u_{n-1}$$