6

Consider a sequence of the form:

$x[n]=-1,-1...,1,1,...,-1,-1...,1,1... \quad n>0$

One can think of this as a square wave ($\pm1$) with a 50 % duty cycle (coming from EE).

For the simplest case of such a series i.e. $-1,+1,-1,+1,-1...$, a general equation is quite trivial ($x[n]=-1^n$).

Can we have e general equation for the other cases i.e. when there are multiple $-1$'s followed by $+1$'s ?

Bernard
  • 175,478
  • 3
    The definition of $x[n]$ is not at all clear. Where does $n$ come into play? – lulu Jan 01 '18 at 02:15
  • 4
    I think, but am not at all sure, that you want something like $x_n=(-1)^{\lfloor \frac nk \rfloor}$. That alternates $\underbrace {1,\cdots , 1}{k,terms},\underbrace {-1,\cdots , -1}{k,terms}, \cdots $ – lulu Jan 01 '18 at 02:21
  • Thank You, this answers my question. – Saqib Shah Jan 01 '18 at 02:26

4 Answers4

8

If you want $m$ negatives ones, followed by $m$ positive ones, et cetera, then use $$-(-1)^{\lfloor{n/m}\rfloor}$$ where $\lfloor{x}\rfloor$ is the floor function, and the sequence starts with $n=0$. Happy New Year!

max_zorn
  • 4,875
3

How about $x(k)=(-1)^{\left\lceil\frac{k}{n}\right\rceil}, k=1,2,3\ldots$? This will produce the sequence with $n$ of $-1$'s, followed by $n$ of $1$'s, followed by $n$ of $-1$'s etc.

Note: $\lceil x\rceil$ is $\operatorname{ceil}(x)$ - the smallest integer $\ge x$.

3

Try this:

$$x(k)=-\frac{2}{\pi}\left[\arctan\left(\sin\frac{(2k-1)\pi}{2n}\right)+\arctan\left(\csc\frac{(2k-1)\pi}{2n}\right)\right]$$

for $k=1,2,3,\ldots$. Took me a bit of time to craft it, but it should work.

1

Here's a nifty trick.

The $n$th roots of unity $\omega_n = e^{\frac{2\pi i j}{n}}$ can be used to filter out elements of sequences.

You probably have already used tricks like $b_n = \frac{a_n + a_n(-1)^n}{2}$ to get a sequence that gives you the value $a_n$ for multiples of $2$ and $0$ otherwise.

If you want this but for a $k$ cycle, simply use $\displaystyle c_n = \frac{\sum_{j=0}^{k-1}a_n \omega_k^n}{k}$ and you can mess with it more to make it more interesting.

You could combine this with the techniques given in the other answers to create any such sequences of $1$'s you like.