Is there a simple function that generates the series; $1,1,2,1,1,2,1,1,2...$ or $-1,-1,1,-1,-1,1...$

8.5k Views Asked by At

I'm thinking about this question in the sense that we often have a term $(-1)^n$ for an integer $n$, so that we get a sequence $1,-1,1,-1...$ but I'm trying to find an expression that only gives every 3rd term as positive, thus it would read; $-1,-1,1,-1,-1,1,-1,-1...$

Alternatively a sequence yielding $1,1,2,1,1,2,1,1,2...$ could also work, as $n$ could just be substituted by it in $(-1)^n$

18

There are 18 best solutions below

5
On

Let $F_n$ be the Fibonacci sequence $0,1,1,2,3,5,8,13,21,34,...$ then a possible sequence is $$(-1)^{F_{n+1}}$$

0
On

You can check out OEIS which gives you several ways to generate your sequence.

For example:

$$a_n=2-((n+1)^2 \pmod 3)$$

$$a_n=\frac{4}{3} - \frac{\cos(2\pi n/3)}{3} - \frac{\sin(2\pi n/3)}{\sqrt3}$$

2
On

How about $$a_n=\frac 23\cos\left(\frac{2\pi n}3\right)+\frac 43\ $$

2
On

If you want something purely in terms of elementary operations, you could use the closed form:

$$\frac{2}{3}\left(-\frac{1}{2} + \omega^n + \omega^{2n}\right)$$

Where $\omega=\frac{-1+\sqrt{3}i}{2}$ is a complex cube root of unity. When $3|n$ we get $\omega^n =\omega^{2n} = 1$. On the other hand, when $n$ is not divisible by $3$, $\omega^n$ and $\omega^{2n}$ will be the two roots of the polynomial:

$$z^2 + z + 1$$

And from Vieta we get $\omega^n + \omega^{2n} = -1$.

0
On

You could use a simple trig function whose period is $3$. We can therefore try a function of the form $$f(x)=a\cos\left(\frac{2\pi x}{3}\right)+b$$

Substituting the coordinates $(0,2),(1,1)$ gives the values of $a,b$ and we end up with $$f(x)=\frac 23\cos\left(\frac{2\pi x}{3}\right)+\frac 43$$ and this generates the required sequence.

0
On

Let $\omega \neq 1$ be a cubic root of unity. We have that $1 + \omega + \omega^2 = 0$, i.e. $\omega + \omega^2 = -1$. Also, $w^{-1} = \omega^2$ and $\omega^3 = 1$.

Put $a_n = \omega^n + \omega^{-n}$. We get the sequences

\begin{eqnarray*} a_0 &=& \omega^{0} + \omega^{0} = 2 \\ a_1 &=& \omega^{1} + \omega^{-1} = \omega^{1} + \omega^{2} = -1 \\ a_2 &=& \omega^{2} + \omega^{-2} = \omega^{2} + \omega^{1} = -1 \\ \end{eqnarray*}

and then the sequence repeats.

If you put $b_n = \frac{2 a_n -1}{3}$, then you get $1, -1, -1, 1, -1, -1, \cdots$.

1
On

Here is my proposal, for $n \ge 1$:

$$1+\left\lfloor \frac{1}{n^{(n \pmod {3})}} \right\rfloor - \left\lfloor \frac{1}{n}\right\rfloor$$

It will provide the sequence: $\{1,1,2,1,1,2,...\}$

5
On

$$(-1)^{(n\,\text{mod}\, 3)!}$$

Edit. a simpler solution, without a factorial and starting with $n=2$:

$$(-1)^{(n\,\text{mod}\, 3)+1}$$

0
On

How about:

$$(n\bmod3)^2-3(n\bmod3)+1$$

5
On

$$-1+2\left \lfloor {\frac n 3} \right \rfloor -2\left\lfloor \frac {n-1}3 \right\rfloor $$ , where $n$ starts from $1$.

1
On

$a(0) = a(1) = -1$
$a(n) = a(n-1) \times a(n-2)$

0
On

Lemma:fibonacci numbers generates:

$odd-odd-even-odd-odd-even-odd-odd-\dots$

proof:

If

$F_i=odd$

$F_{i+1}=odd$

Then we have:

$F_{i+2}=even$

$F_{i+3}=odd$

$F_{i+4}=odd$

then the system reapeates.

It gives the formula:

$(-1)^{F_{n}}$

This gives the closed form:

$$(-1)^{(\frac{1}{\sqrt{5}}((\frac{1+\sqrt{5}}{2})^{n+1}-(\frac{1-\sqrt{5}}{2})^{n+1})}$$

Which is really ugly.I will introduce Lucas numbers to make this better.

Lucas numbers look like fibonacci numbers but $F_1=1$ and $F_2=3$.

Which gives the same odd and even resault.Then we can write:

$(-1)^{L_n}$

That gives the closed form:

$$(-1)^{(\frac{1+\sqrt{5}}{2})^n+(\frac{1-\sqrt{5}}{2})^n}$$

0
On

Iverson bracket notation makes it easy to say exactly what you mean here:

$a_n = 2\cdot[\text{$n$ is a multiple of $3$}] - 1$

or, shorter but more (probably excessively) confusing:

$a_n = 2[3\mid n] - 1$

4
On

No operators!

$f(x) = \begin{cases} -1 & \text{if}~x=0\\ -1 & \text{if}~x=1\\ 1 & \text{if}~x=2\\ f(x-3) & \text{otherwise}\\ \end{cases}$

0
On

This works for positive and negative integers of $x$ and produces a sequence of $1,1,2,1,1,2,...$

$y = 2 - (x^2 \text{ mod } 3)$

Or for the sequence $-1,-1,1,-1,-1,1,...$

$y = 1 - 2(x^2 \text{ mod } 3)$

5
On

Yet another one:

$$1 + \left\lfloor \frac{n \bmod 3}{2} \right\rfloor$$

0
On

Another one:

$$2\times((n+1\bmod3) \bmod 2)-1$$

0
On

my 2 cents, how about

$a_{n+1}=(-1)^{r(a_n)(1-a_n)}$ where $a_0 = 1$ and $r \in \{1,2,3\}$ which is similar to the logistic map in general I think that using a one dimensional chaotic polynomial could help.