How do you find a pattern behind a sequence of integers?

192 Views Asked by At

I'm working with some sequences and could be useful to know how to find a pattern behind them:

I currently have two sequences:

$8,20,20,20,24,36,36,36,40,52,52,52,56...$

$12,16,20,40,40,40,40,40,44,48,52,72,72,72,72,72,76,80...$

I can see the repeating patterns, but how do I write down $a_n= ... $?

The first one goes $(+12,+0,+0,+4,...)$ and repeats itself each time.

The second goes $(+4,+4,+20,+0,+0,+0,+0,+4,...)$

I want to know how to create the two an based on $(+12,+0,+0,+4,...)$ for the first and $(+4,+4,+20,+0,+0,+0,+0,+4,...)$ for the second.

3

There are 3 best solutions below

1
On BEST ANSWER

Using zero-based indexes, $$a_{4n}=8+16n,\\a_{4n+1}=20+16n,\\a_{4n+2}=20+16n,\\a_{4n+3}=20+16n$$ and similar for the second sequence.

If you want a one-liner,

$$a_n=20-2(n\bmod4-1)(n\bmod4-2)(n\bmod4-3)+4(n-n\bmod4).$$

The second takes a more complex polynomial in $n\bmod 8$ (Lagrangian interpolator).

2
On

Well, the true answer is that with limited information and without assuming that the pattern persists, you cannot come up with a unique rule $a_n$ that will be the sequence that you're looking at.

This is because, without assuming that the pattern persists, the next term in the sequence that you have been presented with could be literally anything.

Although, if you do assume that a pattern exists, then this is also a difficult question and depends entirely on the numbers you have been given and on luck. Even then, it is unlikely that you will come up with a unique representation of such a sequence of terms.

For the first sequence you have given, if we assume that the pattern persists, once can guess a representation of the pattern to be the following: $$ \begin{align} a_n = \begin{cases} 4(n+1) & n = 4k + 1 \text{ for } k \in \mathbb{N}_0 \\ 4(4k+5) & n = 4k+r \text{ for } k\in\mathbb{N}_0, r = 2,3,4 \end{cases} \end{align} $$

0
On

The first series can be written as recursive series in the following way $$\begin{align}a_1=&8\\ a_2=&20\\ a_3=&20\\ a_4=&20\\ a_n=&a_{n-4}+16, &\forall n>4 \end{align}$$ The second one can be written in a similar way. $$\begin{align}a_1=&12\\ a_2=&16\\ a_3=&20\\ a_4=&40\\ a_5=&40\\ a_6=&40\\ a_7=&40\\ a_8=&40\\ a_n=&a_{n-8}+32, &\forall n>8 \end{align}$$