5
$\begingroup$

This question already has an answer here:

Suppose we have the following sequence:

{$a_n$} such as:
$a_0 = 1, \\ a_1 = 1, \\ a_2 = -1, \\ a_3 = -1, \\ a_4 = 1, \\ a_5 = 1, \\ ... $

How can we find the general term of this sequence? I tried using a trigonometric function e.g. $\alpha \sin(x+\phi)$, then we impose some constraints on $\alpha$ and $\phi$ to get that sequence, but I get lost, is there any clever way to find the general term?

EDIT: The question is identified as duplicate, but that answer does not solve the question, because I am looking for a solution that does not involve floor function.

$\endgroup$

marked as duplicate by Matthew Towers, user296602, Claude Leibovici, Did, ArsenBerk Jan 20 '18 at 23:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ Lets be clear , you are not looking for general term, this is actually asking what can generate this repeating sequence. From finite terms general terms can no be found as there are infinitely many solutions that will have coinciding terms as the finitely given term. General terms can be only given not deduced. $\endgroup$ – Arjang Jan 14 '18 at 3:06
  • 1
    $\begingroup$ DFT is always the most powerful tool at hand for finding "general terms" of a periodic sequence. $\endgroup$ – Henricus V. Jan 14 '18 at 4:04
  • 1
    $\begingroup$ @Peter Discrete Fourier Transform $\endgroup$ – Henricus V. Jan 14 '18 at 12:09
  • 3
    $\begingroup$ What's your goal? If you just want to describe the sequence, something like $$a_i=\begin{cases}\phantom{-}1&\text{if }i\bmod4\in\{0,1\}\\-1&\text{otherwise}\end{cases}$$ is much clearer than messing around with trigonometric functions. $\endgroup$ – David Richerby Jan 14 '18 at 17:36
  • 2
    $\begingroup$ @Freshman42 OK. If you can really calculate $\sqrt{2}\sin(n\pi/2 + \pi/4)$ or even $n(n-1)/2$ faster than you can calculate $n\bmod 4$ then I can't argue... But you really oughta practice your basic arithmetic. ;-) $\endgroup$ – David Richerby Jan 15 '18 at 21:04
16
$\begingroup$

You could use $\cos(n\pi/2)+\sin(n\pi/2)$. I see this working by thinking about the unit circle. A needle pointing East, North, West, or South always contributes a $0$ from among $\cos(n\pi/2),\sin(n\pi/2)$ and also either $1$ or $-1$. And it just works out.

Trig identities show this is equal to to $\sqrt{2}\sin(n\pi/2+\pi/4)$

Or from a different perspective, $(-1)^{n(n-1)/2}$. The expression $n(n-1)$ is always even, so always divisible by $2$. Sometimes, one of $n,n-1$ is also divisible by $4$, so that you still have an even number after dividing by $2$. As $n$ iterates, first $n$ will be divisible by $4$, then $n-1$ will be divisible by $4$, then $n$ will be divisible only by $2$, then $n-1$ will be divisible only by $2$. And then it all repeats. So the exponent on $(-1)$ is even, even, odd, odd, repeat.

$\endgroup$
  • $\begingroup$ @Freshman42 I added some alternative expressions to the answer. $\endgroup$ – alex.jordan Jan 13 '18 at 23:59
  • $\begingroup$ @Freshman42 Try values $n = 0 .. 8$ to verify it. $\endgroup$ – Todd Sewell Jan 14 '18 at 13:33
  • $\begingroup$ @Freshman42 Because the parity of $n(n-1)/2$ depends on the value of $n$ modulo $4$ (it is divisible by $2$ if and only if either $n$ or $n-1$ is divisible by $4$). $\endgroup$ – user202729 Jan 14 '18 at 14:08
  • $\begingroup$ @user202729: Thank you $\endgroup$ – Freshman42 Jan 14 '18 at 20:23
  • $\begingroup$ @Freshman42 $n(n-1)$ is always even, so always divisible by $2$. Sometimes, one of $n,n-1$ is also divisible by $4$, so that you still have an even number after dividing by $2$. As $n$ iterates, first $n$ will be divisible by $4$, then $n-1$ will be divisible by $4$, then $n$ will be divisible only by $2$, then $n-1$ will be divisible only by $2$. And then it all repeats. So the exponent on $(-1)$ is even, even, odd, odd, repeat. $\endgroup$ – alex.jordan Jan 14 '18 at 21:49
20
$\begingroup$

The general solution of the recurrence $\ a_n=a_{n-4}\ $ is $$a_n=Ai^n+B(-1)^n+C(-i)^n+D$$ where $A,B,C,D$ are arbitrary constants.

The particular solution for your initial values $\ a_0=a_1=1,\ a_2=a_3=-1\ $ is $$a_n=\frac{(1-i)i^n+(1+i)(-i)^n}2.$$ Using the identities $i^n=e^{n\pi i/2}=\cos\frac{n\pi}2+i\sin\frac{n\pi}2$ and $(-i)^n=e^{-n\pi i/2}=\cos\frac{n\pi}2-i\sin\frac{n\pi}2$
we can rewrite this as $$a_n=\cos\frac{n\pi}2+\sin\frac{n\pi}2.$$

$\endgroup$
  • $\begingroup$ bof. Nice, the start from something tangible, a_n=a_(n-4). $\endgroup$ – Peter Szilas Jan 14 '18 at 7:44
5
$\begingroup$

$$(-1)^{\lfloor{n/2}\rfloor},$$ where $\lfloor{\cdot}\rfloor$ is the floor function, or as requested in the comment, $$\sqrt{2}\cdot\sin\big((2n+1)\pi/4\big).$$

$\endgroup$
  • $\begingroup$ I think there is a solution that does not involve floor function $\endgroup$ – Freshman42 Jan 13 '18 at 23:53

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