6
$\begingroup$

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 ?

$\endgroup$
  • 3
    $\begingroup$ The definition of $x[n]$ is not at all clear. Where does $n$ come into play? $\endgroup$ – lulu Jan 1 '18 at 2:15
  • 4
    $\begingroup$ 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 $ $\endgroup$ – lulu Jan 1 '18 at 2:21
  • $\begingroup$ Thank You, this answers my question. $\endgroup$ – Saqib Shah Jan 1 '18 at 2:26
8
$\begingroup$

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!

$\endgroup$
3
$\begingroup$

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$.

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.