# How to identify the pattern of a sequence

Are there some particular methods for identifying the following types of number series?

• $6, 10, 19, 44, 93, \cdots$ (Difference being prime no's square starting from 2)

• $1, -2, 15, 52, -512, \cdots$ ( $^*2-4,\ ^*-6+3,\ ^*4-8,\ ^*-10+5$, and so on)

• $4, -2, -7, 25, 95,\cdots$ ( $^*-1+2,\ ^*2-3,\ ^*-3+4,\ ^*4-5$, and so on)

I mean they do not follow the arithmetic or geometric series nor do their common difference seem to follow any AM-GM pattern. So, is there any generalized mathematical theorems on these types of number series? Or we have to do it on a trial & error basis using intuition?

• If you ask a mathematician, they would tell you: Step 1) go to oeis.org. Step 2) type the first few terms. – user259242 Nov 4 '16 at 9:27
• @user259242 doesn't always work – katipra Nov 4 '16 at 9:34
• @user259242 is there more rigid way to find the logic – katipra Nov 4 '16 at 9:35
• As for the sequence a), consider successive differences: $1,4,9,25,49$ are all squares (but for some reason $16$ and $36$ do not appear). – Crostul Nov 4 '16 at 10:58
• Try $$\sum_{n=0} c_n z^n = \dfrac\sum_{n=0} b_n z^n}{1 + \displaystyle \sum_{n=1} a_n z^n$$ where $c_n$ is the known sequence. Multiply the left by the denominator on the right. Equate the coefficients of the $z$ powers to find equations for $b_k$ wrt $a_j$s. try to terminate the sequences in a finite number of steps. Note all $a_n = 0$ is trivial $b_n = c_n$. I don't think the solution will be unique. – arthur Nov 4 '16 at 11:21

As other users have said, usually people goes to OEIS to find the sequence. What not everybody knows is that OEIS has a feature to send the sequence by email called "Superseeker" and, as OEIS says: "This program will accept a sequence of integers and try very hard to find an explanation."

Fortunately, there is a "Superseeker" help page, that explains what methodologies are used to "try very hard to find" the sequence. I think it is very sophisticated and accurate, so here is an excerpt of the ways it tries to identify a pattern (all credits to OEIS, written here only for the purpose of answering OP's question and because OEIS is IMHO an authoritative reference in regards to integer sequences and pattern recognition):

1. Test if $a(n)$ is a polynomial in $n$ [$a(n)$ denotes the $n^{th}$ term]. In other words, are the differences of some order constant?

2. Test if the differences of some order are periodic. (Suppose the $k^{th}$ order differences are $d(1), ...,d(n)$. They are said to be periodic if there is a number $p$, the period, with $1 \le p \le n-2$, such that $d(i) = d(j)$ whenever $i = j \pmod{p}$.

3. Test if any row of the difference table of some depth is essentially constant. This detects such sequences as $4^n - n^4$. (Let the usual difference table be $a(0), a(1), a(2), \cdots$, $b(0), b(1), \cdots$, $c(0), c(1), \cdots , /cdots$. This is the difference table of depth $1$. The table of depth $2$ has as top row $a(0), b(0), c(0), \cdots$ and so on.

4. For a $2$-valued sequence, compute the six characteristic sequences associated with the sequence and look them up in the OEIS.(Suppose the sequence takes only the values $X$ and $Y$. The six characteristic sequences, all equivalent to the original, are: replace $X,Y$ by $1,2$; by $2,1$; the positions of the $X's$, of the $Y's$; the run lengths; and the derivative, i.e. the positions where the sequence changes.

5. Form the generating functions (g.f.) for the sequence for each of the following $6$ types: ogf ordinary generating function, egf exponential generating function, revogf reversion of ordinary generating function, revegf reversion of exponential generating function, lgdogf logarithmic derivative of ordinary generating function, lgdegf logarithmic derivative of exponential generating function, and attempt to represent them as rational functions, hypergeometric series, or the solution to a linear differential equation with polynomial coefficients.

6. Look for a linear recurrence with polynomial coefficients for the coefficients of the above $6$ types of g.f.'s.

7. Look for a polynomial equation in $y$ and $x$ for the g.f. y(x) of each of the above $6$ types.

8. Apply the transformations listed below to the sequence and look up the result in the OEIS. Stop when $50$ matches have been found. (Note: there is a very long list of transformations in the help page).

9. Test if the sequence is a Beatty sequence. (A Beatty sequence is one in which the $n^{th}$ term is $[nz]$, where $z$ is irrational. The complementary sequence is $[ny]$, where $\frac{1}{x} + \frac{1}{y} = 1$. Refs: N. J. A. Sloane, Handbook of Integer Sequences, $1973$, p. $29$; R. Honsberger, Ingenuity in Mathematics, $1970$, p. $93$. If this is a Beatty sequence the value given for $z$ will produce the given terms, but this value of $z$ is very far from being unique.)

The list continues with transformations and other types of possible recurrences. It provides as well a long list of mathematical packages very useful for pattern recognition.

is there any generalized mathematical theorems on these types of number series?

I'll risk an unsatisfactory answer too long for a comment: essentially, "no".

The sequences school kids work on often come from arithmetic or geometric series, which is probably why you suggest trying them first. But there are no general rules for "these types of number series".

When mathematicians look for patterns they usually have some reason to expect a particular form, so their intuition informs the search. Knowing the source of a sequence in advance really matters. If I encountered your first one while thinking about number theory I might guess something involving primes after I noticed that the differences were all squares but that 16 and 36 were missing.

Any finite sequence can be continued in many ways that look as if they extend a pattern - you can always do this with a polynomial by taking enough differences. (This google search for successive differences polynomial finds lots of links.)

When a mathematician thinks she's found a new pattern she then tries to prove it goes on forever - that requires more than checking the next few terms. It's fun.

I think it is possible with neural networks, specifically with recurrent neural network.

From the nodes of the neural network, you may be able to come up with a complex notation using forward propagation.

However, there are still quite a lot of hyperparameters that you need to define first. For example: 1) Regularization 2) number of hidden layers 3) length of the input (for RNN) and so on....

Some of these hyperparameters like the number of hidden layers will end up in the final forward propagation.