3

There is a sequence with the values $0, 0, 0, 0, 1, 0, 0, 0, 0, 1, \ldots$ (basically there are always four 0s followed by a 1, then it repeats).

Is there a function for this sequence?

Here are two experiments for similar sequences:

For a sequence of $0, 1, 0, 1,\ldots$ it is: $$f(x)=\frac{(-1)^{x+1}+1}{2}=x\bmod 2$$ For a sequence of $0, 0, 1, 0, 0, 1,\ldots$ it is: $$f(x)=1-(((x+1) \bmod 3)-1)^2$$ For a sequence of $0, 0, 0, 1, 0, 0, 0, 1,\ldots$ it is: $$f(x)=?$$ For a sequence of $0, 0, 0, 0, 1, 0, 0, 0, 0, 1,\ldots$ it is: $$f(x)=?$$

Georg
  • 141
  • 5
    For any value of n, why not take $f(x) = n^{-1} \sum_{i= 1}^{n} \zeta_{n}^{x}$ where $\zeta_n$ is an $n^{th}$ root of unity? –  Sep 05 '15 at 09:25
  • @PadraigÓCatháin, the root of unity must be primitive for your formula to work, and you're missing an $i$ (the exponent should be $i x$) – kodlu Sep 05 '15 at 09:31
  • 3
    I should think you mean $x {\mod 2}$ rather than $x {\mod 1}$. – JDH Sep 05 '15 at 09:44
  • 1
    See http://math.stackexchange.com/a/823883/21820 which is essentially the same question. – user21820 Sep 05 '15 at 12:23
  • In the first displayed equation, by "$x\mod1$" you probably mean "$x\mod2$". – bof Sep 05 '15 at 23:02
  • Here is another option: $a_0=0,a_1=0,a_2=0,a_3=1,a_n=a_{n-4}$. – barak manos Sep 06 '15 at 04:03
  • I just want to say, you're looking for a formula, not a function. A function is any rule that turns a number into another number. Thus, simply defining $f(x)$ to be $1$ if $x$ is a multiple of $4$ and $0$ otherwise is a function. – Akiva Weinberger Sep 06 '15 at 04:42
  • (Also, "rule" isn't the best way to say it, because some functions don't seem to follow any rule we can describe. You can think of a function $f$ as an infinite collection of formulas, like: $f(0)=a$, $f(1)=b$, $f(2)=c$, etc. If the function is defined on all real numbers, it's even more formulas.) – Akiva Weinberger Sep 06 '15 at 04:45
  • I wasn't sure in the last sequence, is $s1$ a typo? Should it be $s_1$? Just $1$? – Asaf Karagila Sep 06 '15 at 06:05
  • 1
    https://en.wikipedia.org/wiki/Periodic_sequence#Periodic_0.2C_1_sequences – Mats Granvik Feb 12 '16 at 17:30

7 Answers7

42

I just want to point out a basic misconception in the question. You ask, "Is there a function for the sequence?" But the definition of a sequence is that it is a map (that is, a function) from N, the natural numbers, to some domain. So the answer is trivially yes.

What you meant to ask was probably, is there a way to express this function in terms of some given set $S$ of functions? But unless you say precisely what $S$ contains, one cannot answer.

P. S. A well-known theorem states that any purely periodic sequence of period n can be expressed as a linear combination of the n'th roots of unity. Maybe this is what you wanted.

  • 2
    This is definitely the Right Answer, but I'm not sure the nth roots of unity are what OP actually wants. That brings complex numbers into what appears to be a basic algebra problem. – Kevin Sep 06 '15 at 02:46
9

For example:

$$f(x) = (((4\cos(2x\pi/5) + 1)^2)/5 - 1)/4$$

or

$$f(x) = 1-(x^4 \mod 5)$$

See OEIS A079998 for more information.

Note: they are both $f(0)=1$. You get you sequence for $x \geq 1$.

Myshkin
  • 216
5

For given n and x = 0, 1, 2...

$$ \left \lfloor{{x \bmod n}\over{n-1}} \right \rfloor $$

Or:

$$ \left \lfloor {{1} \over {99999}} \cdot 10^x \right \rfloor \bmod 10 $$

$$ {1 \over 99999} = 0,(00001) $$

Fun fact: this is probably the simplest way to generate any repeatable sequence you need. Simply divide required sequence by a number consisting of equal number of nines, for instance: $$ {82742 \over 99999} = 0,827428274282742... $$

Spook
  • 946
5

$$ f(x) = \begin{cases} 0 & x \not\equiv 4 \pmod 5 \\ 1 & x \equiv 4 \pmod 5 \end{cases} $$

Or with the Iverson bracket,

$$ f(x) = \left[x \equiv 4 \pmod 5\right]$$

However, one of the ones you were probably looking for is

$$ f(x) = \frac{1}{5} \sum_{k=0}^4 \zeta^{k(x-4)} $$

where $\zeta$ is any primitive (complex) fifth root of unity; e.g. $\exp(2 \pi \mathbf{i} / 5)$, which can also be written as the principal value of the complex exponential $(-1)^{2/5}$. (there is a (messy) formula for this constant in radicals)

This formula is a special case of the Discrete Fourier Transform, which can be used to come up with a formula like this for any periodic sequence of complex numbers.

Naturally you could take the real part and write

$$ f(x) = \frac{1}{5} \sum_{k=0}^4 \cos\left(\frac{2 \pi}{5} k (x-4) \right) $$

3

Take any periodic function $g$ of period $5$ that has at least one value that appears once only, let $g(4)$ WLOG. For example $g(n)=\sin\left(\frac{2\pi n}{5}\right)$.

Then the Lagrangian interpolant

$$f(n)=\frac{(g(n)-g(0))(g(n)-g(1))(g(n)-g(2))(g(n)-g(3))}{(g(4)-g(0))(g(4)-g(1))(g(4)-g(2))(g(4)-g(3))}$$ does the trick.

1

Generating functions is a way to express a sequence. For this example we would like a closed form of the function $$ g(x) = a_0 + a_1x + a_2x^2 + a_3x^3 + a_4x^4 + a_5x^5 + a_6x^6 + a_7x^7 + a_8x^8 + a_9x^9 + \cdots $$ where $a_0=0,a_1=0,a_2=0,a_3=0,a_4=1,a_5=0,a_6=0,a_7=0,a_8=0,a_9=1,\dots$ We want thus a closed form for $$ \eqalign{ g(x) &= x^4 + x^9 + x^{14} + x^{19} + \cdots \cr &= x^4 (1 + x^5 + x^{10} + x^{15} + \cdots) \cr &= {x^4 \over 1 - x^5} \cr } $$

nickchalkida
  • 1,495
  • 1
    $g(0) = 0$, $g(1) = \text{undefined}$, $g(2) \approx -0.5$ ... this doesn't seem to be at all what we are looking for. And besides, $g(x)$ only works for $|x| < 1$ (otherwise the geometric series diverges) – Justin Sep 05 '15 at 17:44
  • A generating function is a different way to express a sequence than the OP is looking for. He simply wants a function that eats an index and spits out the sequence element with that index. – hmakholm left over Monica Sep 05 '15 at 19:08
0

(1+(-1)^z)/2 z=((n+1)(n+2)(n+3)/2) - 1

z = splitter

The formula for sequence {0,0,0,1,0,0,01,...} I call this as quadrivariate periodic zeroth dimensional sequence. Because i am still looking for formula for first dimension {1,1,1,1,2,2,2,2,3,3,3,3,...} and higher dimensions.

I am also looking for formula for {0,0,0,0,1,...} in terms of n without the use of modular math.

Bivariate periodic sequences {0,1,0,1,...} and Trivariate periodic sequences {0,0,1,0,0,1,...} were already constructed up to m dimension.

Univariate {0,0,0,0,...} sequences include the arithmetic sequences and the regular polygonal numbers and the integers raised to common power.