Find sequence formula

Enter the first numbers in the sequence. Use question mark (?) for values that you don't know.

The elements of sequence are numbered, starting from 1.

a1a2a3 …

In an arithmetic progression the difference between one number and the next is always the same. 1 4 7 10 13… is an example of an arithmetic progression that starts with 1 and increases by 3 for each position in the sequence. This sequence can be described using the linear formula an = 3n − 2.

In a geometric progression the quotient between one number and the next is always the same. 2 4 8 16… is an example of a geometric progression that starts with 2 and is doubled for each position in the sequence. This sequence can be described using the exponential formula an = 2n.

If neither quotient nor difference is constant it might be a good idea to look at the difference between the differences. If it turns out that the difference between the differences is constant it means that the sequence can be described using a second degree polynomial. 2 5 10 17 26… is an example of such a sequence. If we look at the difference between the five initial numbers we find that they are 3 5 7 9 and, as you can see, the differences between these numbers are 2. This tells us that it is possible to describe the sequence as a second degree polynomial but it does not give us any information about how.

To establish the polynomial we note that the formula will have the following form.

an = p × n2 + q × n + r

The task now is to find the values of p, q and r. By substituting n and an for some elements in the sequence we get a system of equations.

1 = p × 12 + q × 1 + r ⇒ 1 = p + q + r
4 = p × 22 + q × 2 + r ⇒ 4 = 4p + 2q + r
7 = p × 32 + q × 3 + r ⇒ 7 = 9p + 3q + r
...and so on...

To be able to solve a system of equations with three unknown variables there need to be at least three equations. By solving the system of equations above we get p = 1, q = 0 and r = 1 which gives us the following formula.

an = n2 + 1

Sometimes it can be necessary to use polynomials of higher degree than two but the method is essentially the same. To solve a third degree polynomial the difference between the differences between the differences need to be constant. For fourth degree polynomials we would have to look at yet another level of differences.

Note that as long as you have a finite sequence of numbers it is always possible to find a polynomial that can describe it. If n numbers are known it is always possible to find a polynomial of degree n - 1 that match all the numbers, but this does not necessarily describe any true pattern of the sequence. For this the polynomial degree would have to be two (preferable three or more) degrees lower than the number of known numbers in the sequence. This is something to think about when using the tool on this page. The reason the tool does not always find a polynomial has to do with technical limitations that makes the numeric precision not good enough for polynomials of higher degrees.

In addition to what has been mentioned already the tool can also recognize the sequence of prime numbers and the Fibonacci sequence. There are of course many more ways to construct sequences but the ones mentioned here are some of the most common.