How do I find a formula $a_n$ for the following periodic sequence: $$0,1,3,4,4,3,1,0,0,1,3,4,4,3,1,0,...$$
The period of the above sequence is 8 with sub-sequence $\{0,1,3,4,4,3,1,0\}$ repeating.
How do I find a formula $a_n$ for the following periodic sequence: $$0,1,3,4,4,3,1,0,0,1,3,4,4,3,1,0,...$$
The period of the above sequence is 8 with sub-sequence $\{0,1,3,4,4,3,1,0\}$ repeating.
Any periodic sequence can be constructed by element-wise addition, subtraction, multiplication and division of periodic sequences consisting of zeros and ones. Periodic zero and one sequences can be expressed as sums of trigonometric functions:
$$ \sum_{k=1}^{k=1} \cos (-2\pi\frac{n(k-1)}{1})/1 = 1,1,1,1,1,1,1,1,1...\\ \sum_{k=1}^{k=2} \cos (-2\pi\frac{n(k-1)}{2})/2 = 0,1,0,1,0,1,0,1,0...\\ \sum_{k=1}^{k=3} \cos (-2\pi\frac{n(k-1)}{3})/3 = 0,0,1,0,0,1,0,0,1,0,0,1,0,0,1...\\ …\\ \sum_{k=1}^{k=N} \cos (-2\pi\frac{n(k-1)}{N})/N = 0,0,0...,1 \text{ sequence with period } N\\ $$
https://en.wikipedia.org/wiki/Periodic_sequence#Periodic_0.2C_1_sequences
You need to add up a linear combination of 8 of these sequences, and you're done.
I got the discrete function $a(n)$ as
$$a_n=3-\lfloor|3.5-((n-1)\ mod\ 8)|\rfloor+\lfloor\frac{3-\lfloor|3.5-((n-1)\ mod\ 8)|\rfloor}{2}\rfloor$$
Though it looks very sophisticated it can be very easily obtained.
My approach:
I have tried to approach the problem logically.
First try finding $a(x)$ for $x=1,2,...,8$. Later we can replace $x$ with $((n-1)\ mod\ 8) +1$
Since it is symmetric around $4.5$, the function has some component of form $\pm|4.5-x|$ (i.e. $\pm\{3.5,2.5,1.5,0.5,0.5,1.5,2.5,3.5\}$).
We can manipulate the above form to obtain $3-\lfloor|4.5-x|\rfloor$ (i.e $\{0,1,2,3,3,2,1,0\}$).
To obtain the desired sequence $$\displaystyle\{0,1,3,4,4,3,1,0\}=\{0,1,2,3,3,2,1,0\}+\lfloor\frac{\{0,1,2,3,3,2,1,0\}}{2}\rfloor$$ just add $\displaystyle \lfloor\frac{3-\lfloor|4.5-x|\rfloor}{2}\rfloor$.
So we have $$a(x)=3-\lfloor|4.5-x|\rfloor+\lfloor\frac{3-\lfloor|4.5-x|\rfloor}{2}\rfloor$$
To get $a(n)$ for all natural numbers n put $x\rightarrow((n-1)\ mod\ 8) +1$
Following @RobertFrost's observation, probably one of the more compact expressions for this sequence is $$\big\lfloor 4.5 \sin^2(\frac{\pi}{8}(n-0.5))\big\rfloor.$$