15

The sequence is $f = 0, 1, 0, 1, \ldots$

I want to find a general formula for the $n$th element. The sequence starts at $n = 0$ (the $0$ here is not the first element $0$ but rather denotes the $0$th position).

One easy and obvious solution is: $n$th $f = n \bmod 2$. This works because even positions have $0$ and odd positions have $1$.

However, this question is part of a homework and modulus has not been discussed (or part of the syllabus or even a prerequisite). And so I am hesitant to use it.

Is there another way to solve this problem using only basic arithmetic operations (one that a beginning high schooler knows of)?

Abhishek Kumar
  • 171
  • 1
  • 6
  • 2
    Do beginning high-schoolers know about Wolfram Alpha? Go to that website and type `Boole[OddQ[Range[0, 99]]]` in the box. – Bill Thomas Sep 25 '18 at 21:05
  • Not sure if you accept recurrence formulas, but that then you would have simple one $a_{n+1}=1-a_{n}$ with $a_0=0$. – Sil Oct 12 '18 at 08:08

8 Answers8

18

$a_n=(1/2)(1+(-1)^{n+1})$, $n=0,1,2,.....$

Peter Szilas
  • 19,725
  • 2
  • 14
  • 28
10

The expression for the $n$th element of that sequence $f$ should take account of the products of $(-1)$.

As every number $n$ that appears in your sequence is just $$n = \frac{1}{2} + k,$$ where $$k = \pm\frac{1}{2},$$ then the general expression for the $n$th term $f_n$ would be the sum of the term $k$ to the $n$th: $$f_n = \frac{1}{2} + (-1)^n \left(\frac{1}{2}\right).$$

Considering that your sequence starts with the value $0$ in the first term. $(-1)^1 = -1, (-1)^2 = 1$, and so on.

Mr. Brooks
  • 932
  • 1
  • 17
  • 41
diego araujo
  • 331
  • 1
  • 7
7

Consider whether you can adjust the sequences from either of:

  • $(-1)^n$
  • $\cos(\pi n)$

to get what you are looking for, for example by adding a constant and/or multiplying by a constant

Henry
  • 142,043
  • 9
  • 114
  • 228
6

Have you learned about exponents yet, including the special cases $x^0$ and $x^1$? Here's a slightly more complicated definition using those exponents: $f(0) = 0$, $f(1) = 1$ (that's what software developers would call "initialization") then $$f(n) = f(n - 2)^{f(n - 1)}$$ for $n > 1$.

You could also do $f(n) = f(n - 2)$, though you could come across a smart-aleck with that one.

Bill Thomas
  • 516
  • 1
  • 6
  • 21
6

First, some notes:

  • If you were to explain the functions you use (same goes for modulus), maybe your homework would get accepted anyway.
  • $\lceil{x}\rceil$ denotes the ceiling function which takes as input the real number $x$ and gives as output the least integer greater than or equal to $x$, i.e. $\lceil{5.3}\rceil=6$.
  • $\lfloor{x}\rfloor$ denotes the floor function which takes as input the real number $x$ and gives as output the greatest integer less than or equal to $x$, i.e. $\lfloor{5.3}\rfloor=5$.
  • When $x$ is an integer, then $\lceil{x}\rceil=\lfloor{x}\rfloor=x$.

With this mind:

Your sequence $$\{f_n\}=0,1,0,1,0,1,\dots$$ can be generated by the function $$f_n=\left\lceil\frac{n}{2}\right\rceil-\left\lfloor\frac{n}{2}\right\rfloor,\;\ n\in\mathbb{Z}^{\ge0}$$ For each even positive integer $n$ (including $0$), the ceiling and floor function evaluate to equal values, canceling each other out; $f_n=0$.

For each odd positive integer $n$, the ceiling and floor function evaluate to values differing by $1$; $f_n=1$.

Jameson
  • 835
  • 4
  • 16
5

Is the sequence just an eternal alternation of 0 and 1? Then all you need to do is put in a couple dozen alternations in the OEIS, find https://oeis.org/A000035, then just sit back and read until you find a formula you like.

Least significant bit of $n$, lsb(n).

This works even if $n$ is negative, but it gets a little bit into computer science.

Also decimal expansion of $\frac{1}{99}$.

Yeah... if you ignore the integer 0 in 0.01010101010101010101010101010101...

Also the binary expansion of $\frac{1}{3}$.

Though I'm not sure this applies under the IEEE 754 floating point format specification.

There's a whole bunch more to look at. I personally like the recurrence relation $a(n) = 1 - a(n - 1)$, which is of course initialized with $a(0) = 0$.

Robert Soupe
  • 14,268
  • 2
  • 27
  • 57
5

You could compact the alternating sign formula with $$f(n) = \sin \left( \frac{n \pi}{2} \right)^2$$

Applying $$(\sin(x))^2= \left( \frac{1}{2} \right)(1 - \cos(2x)) $$

So you get $0, 1, 0, 1, 0, 1, \ldots$

Mr. Brooks
  • 932
  • 1
  • 17
  • 41
Saul Mendoza
  • 231
  • 1
  • 10
1

We can apply the sign function:

$$a_n=\mathrm{sgn}(1-(-1)^n)\qquad\qquad n=0,1,2,\ldots$$

epi163sqrt
  • 94,265
  • 6
  • 88
  • 219