4

In my work I came across that sequence

$-1,-1,-1,-1,1,1,1,1,\dots$ and repeating this 8-block so on forever

Now I cant find an ( e.g. trigonometric/complex ) expression $f(n)$ ( e.g. $f(n) =(-1)^g(n)$ ) which gives me the sequence starting with $n=2,3,4,5,6,7,8,9,…$ and so on forever.

Ali Caglayan
  • 5,726

7 Answers7

9

Consider the function $f(n)$ such that \begin{equation} f(n) = \left \{ \begin{array}[ll] (-1 & \textrm{ if } n \textrm{ mod } 8 \equiv 0,1,2,3 \\ 1 & \textrm{ if } n \textrm{ mod } 8 \equiv 4,5,6,7 \end{array} \right. \end{equation}

7

I will assume that you really are starting at $2$. If the start is different, modification is easy.

Let $g(n)=\left\lfloor\frac{n+2}{4}\right\rfloor$. Here $\lfloor x\rfloor$ is the "floor" function, the greatest integer $\le x$.

Then your sequence is given by $(-1)^{g(n)}$.

André Nicolas
  • 507,029
6

By symmetry, we can assume $$ f(n) = a_1 \sin\frac{\pi n}{4} +a_3 \sin\frac{3\pi n}{4} +b_1 \cos\frac{\pi n}{4} +b_3 \cos\frac{3\pi n}{4}. $$ Then $$ \begin{aligned} f(1) &= \frac{a_1}{\sqrt{2}} +\frac{a_3}{\sqrt{2}} + \frac{b_1}{\sqrt{2}} -\frac{b_3}{\sqrt{2}} = -1\\ f(2) &= a_1 - a_3 = -1\\ f(3) &= \frac{a_1}{\sqrt{2}} +\frac{a_3}{\sqrt{2}} - \frac{b_1}{\sqrt{2}} +\frac{b_3}{\sqrt{2}} = -1 \\ f(4) &= -b_1 - b_3 = -1. \end{aligned} $$ So $$ \begin{aligned} a_1 &= -\frac{1}{2} -\frac{1}{\sqrt 2}, \\ a_3 &= +\frac{1}{2} -\frac{1}{\sqrt 2}, \\ b_1 &= b_3 = \frac{1}{2}. \end{aligned} $$ So $$\begin{aligned} f(n) &= \left( -\frac{1}{2} -\frac{1}{\sqrt 2} \right) \sin\frac{\pi n}{4} + \left( \frac{1}{2} -\frac{1}{\sqrt 2} \right) \sin\frac{3 \pi n}{4} + \frac{1}{2} \left( \cos\frac{\pi n}{4} + \cos\frac{3 \pi n}{4} \right) \\ &= \sin\frac{\pi n}{4} \cos\frac{\pi n}{2} -\sqrt 2 \cos\frac{\pi n}{4} \sin\frac{\pi n}{2} + \cos\frac{\pi n}{4} \cos\frac{\pi n}{2} \\ &= \sqrt 2 \left[ \sin\frac{\pi (n+1)}{4} \cos\frac{\pi n}{2} - \cos\frac{\pi n}{4} \sin\frac{\pi n}{2} \right]. \end{aligned} $$

5

Let $\zeta = \mathrm{e}^{\mathrm{i} \pi/4}$ and $$f(z) = \frac{1}{4} z \left(\left(\sqrt{2}+(1-\mathrm{i})\right) z^6 +\left(-\sqrt{2}+(1+\mathrm{i})\right) z^4 \\ -\left(\sqrt{2}+(-1+\mathrm{i})\right) z^2 +\sqrt{2}+(1+\mathrm{i})\right).$$ Then $f(\zeta^n)$ is your sequence. (It even starts at $n=2$.)

Brought to you by the joys of Lagrange interpolation (on the eighth roots of $1$).

(I haven't worked through the details, but if we turn this into a trigonometric expression, it looks as if we should get something close to @user293511's answer.)

Eric Towers
  • 67,037
  • Does the formula look more harmoniously if the sequence starts with $n=0$ ? – Wolfgang Tintemann Nov 26 '15 at 16:24
  • @WolfgangTintemann : Not really: $\frac{-1}{2 \left(2+\sqrt{2}\right)}x \left(\left((1+2 i)+\sqrt{-4+3 i}\right) x^6 \+\left(1+\sqrt[4]{-1}\right) x^4-\left((-1)^{3/4}-1\right) x^2+\sqrt{-4-3 i}+(1-2 i)\right)\$. – Eric Towers Nov 26 '15 at 22:16
3

Modified to start at $n=2$:$$f(n)=(-1)^{\frac{(n+2)!}{(n-2)!4!}}$$ This will give you your desired sequence.

Here is a plot of this function.

Mufasa
  • 5,434
  • Very interesting. Its really periodic with length 4 alternating odd/even. I am puzzled. But it works only when I start with $n=0$. How would I alter it when starting with $n=2$ ? f(n)=(-1)^{\frac{(n+4-2)!}{n!4!}} works in CAS. – Wolfgang Tintemann Nov 26 '15 at 00:26
  • 1
    I've amended the expression to start at $n=2$ – Mufasa Nov 26 '15 at 00:28
  • Is this method applicable if I start at e.g. $n=0$ and have a $2^j$-block of $-1$ followed by a $2^j$-block of $+1$ ? What is the theory behind it ? – Wolfgang Tintemann Nov 26 '15 at 00:37
  • I believe the expression $\frac{(n+2^r)!}{n!(2^r)!}$ will give you a repeated sequence of $2^r$ odd numbers followed by $2^r$ even numbers with $n=0...$ – Mufasa Nov 26 '15 at 00:46
  • Funny. Is there a proof for this ( somewhere ) ? – Wolfgang Tintemann Nov 26 '15 at 00:54
  • @WolfgangTintemann: There sure is, though I don't know where. But you may want to look at http://math.stackexchange.com/a/823883/21820, which is closely related. Basically, if you look at the Pascal's triangle modulo 2, you will see a pattern that you can exploit to obtain suitable formulae for repeating patterns with cycle length a power of 2. – user21820 Nov 26 '15 at 14:30
1

Simply observe the 3rd bit

\begin{equation} f(n) = \left \{ \begin{array}[ll] (-1 & \textrm{ if } n \land 2^3 \equiv 0 \\ 1 & \textrm{ if } n \land 2^3 \equiv 1 \end{array} \right. \end{equation}

Or (if my mathematical symbols are correct)

\begin{equation} f(n) = 2 (n \land 2^3) - 1 \end{equation}

I'm trying to express the bit-wise logical and of n with the binary number 01000.

1

By adding a third harmonic to a sine wave I came up with $\sin{x}+(\sqrt2-1)\sin3x$ which has equal value at $x = \frac\pi8, 3\frac\pi8, 5\frac\pi8, 7\frac\pi8, 17\frac\pi8, \dots$ and the negative value at the corresponding missing odd coordinates. The formula does get more complicated when you normalise the values to be $\pm1$ for $n = 2\dots8$ though:

$$f(n) =\frac{\sin(\frac{2x+5}8\pi)+(\sqrt2-1)\sin(\frac{6x+15}8\pi)}{\sin\frac\pi{8}+(\sqrt2-1)\sin\frac{3\pi}8}$$

Neil
  • 193
  • 4
  • 11