I have the first few terms of a sequence, something like

  • $3,5,7,9,11,\ldots$ or
  • $1,2,4,7,\ldots$ or
  • $2,4,8,16,32,\ldots$ or
  • $1,6,3,4,45,186,\ldots$

I want to know what the next term is, or maybe even a general formula for the $n^{\rm th}$ term. Why do people tell me my question is ambiguous or give unhelpful answers like "the next term could be anything"? What is this Lagrange polynomial they talk about?

See this question and my meta answer, for context.

  • 5
    $\begingroup$ See what OEIS finds e.g. for 3,5,7,9,11 or for 1,2,4,7 to find out any such question may have multiple, distinct, well-grounded answers. Which means such problems are ill-posed. $\endgroup$
    – CiaPan
    Commented May 8, 2018 at 9:52
  • 1
    $\begingroup$ I know you want to have a canonical question to link duplicates, but as this is worded, it absolutely belongs on meta. $\endgroup$
    – pipe
    Commented May 8, 2018 at 9:52
  • 5
    $\begingroup$ Damn those elementary school intelligence questions $\endgroup$
    – duhaime
    Commented May 8, 2018 at 10:19
  • $\begingroup$ @pipe FWIW the wording was inspired by this question. My intention was to link to rather than mark duplicates, because specific questions may get useful answers and/or be improved. So I'm not fussed whether it goes here or on meta. $\endgroup$
    – stewbasic
    Commented May 8, 2018 at 21:42
  • $\begingroup$ This type of questions has been discussed here several times in the past. For example: What to do about question that ask about the next term in the sequence? (and other posts lined there) or Number-guessing, sum of all natural numbers and hot trend questions (and other posts linked there). $\endgroup$ Commented May 11, 2018 at 7:19
  • $\begingroup$ And probably I should have also mentioned this post: Guess the next number/guess the relation etc, Especially since there is a very insightful answer by David Speyer. $\endgroup$ Commented May 11, 2018 at 8:34
  • 1
    $\begingroup$ It's simply not a mathematical question. The fact that the next term could be anything isn't unhelpful, it's a mathematical answer. $\endgroup$ Commented May 11, 2018 at 17:25
  • $\begingroup$ @martinsleziak the existing meta questions are aimed at the community. I wanted something aimed at the author of such questions to explain the problem with their question and how to improve it. The monster group example in my answer was inspired by David Speyer's answer. $\endgroup$
    – stewbasic
    Commented May 11, 2018 at 20:31

3 Answers 3


Why it's ambiguous

The question is ambiguous because it doesn't contain enough information to know which sequence is being asked about. For example, there are many sequences whose first five terms are $$ 3,5,7,9,11,\ldots $$ One possibility is the sequence of odd numbers $\geq3$, which continues $$ 3,5,7,9,11,13,15,17,\ldots $$ Another possibility is that all terms after the first five are zero: $$ 3,5,7,9,11,0,0,0,\ldots $$ The second sequence is not very natural, and probably not what the question intended. This illustrates several points:

  • The person posing the question most likely had a specific sequence in mind.
  • From just the information given, we can't be certain what the intended sequence was.
  • We may try to guess the intended sequence. In particular we may guess it is the most natural sequence matching the given terms.

However, whether one sequence is more natural than another is subjective. In this example most people would guess the intended sequence is the first one (the sequence of odd numbers $\geq3$). But what if we are told a sequence begins with these terms? $$ 1,2,4,7,\ldots $$ It could be the number of pieces of a pancake after a number of straight line cuts, or $1$ subtracted from the Fibonacci sequence. Which of those is more natural? Your answer might depend on whether you're interested in the Euler characteristic or AVL trees or delicious pancakes.

Polynomial sequences and interpolation

The first sequence above is an arithmetic progression, so the $n^{\rm th}$ term is given by a linear function of $n$, namely $2n+1$. Such sequences are relatively simple, so we could argue on this basis that it is the "most natural" extension of the given terms. Similarly the $n^{\rm th}$ term of the above pancake sequence is given by a quadratic function of $n$. Perhaps we can consider a sequence to be natural if its $n^{\rm th}$ term is described by a polynomial function of $n$?

This doesn't really work, because we can choose any number we want for the next term and still find a polynomial to match. For example, we might guess that the sequence $$ 1,2,4,7,\ldots $$ is given by the polynomial $n^4-10n^3+\frac{71}2n^2-\frac{101}2n+25$ and the next term is $35$. Perhaps we can avoid this by insisting the polynomial has the lowest possible degree? Now given the terms $$ 2,4,8,16,32,\ldots $$ we would guess that the $n^{\rm th}$ term is $$ \frac1{12}n^4-\frac12n^3+\frac{23}{12}n^2-\frac32n+2 $$ and the next term is $62$. I suggest that a more natural candidate is $2^n$ for the $n^{\rm th}$ term, with the next term being $64$.

The process of finding a polynomial function to fit given terms is called polynomial interpolation, and the Lagrange polynomial gives an explicit formula for it. I won't discuss the details here; the important point is just that we can always find such a polynomial (and we can keep the degree less than the number of given terms).

How to improve the question

The best way to remove ambiguity is to fully specify the sequence, maybe by describing how you got those initial terms. The important part is to give enough information for someone to determine as many terms as they want. For example

I started with 3 and then kept adding 2 to the previous number.

After 1,2, each term is the sum of the previous two terms plus 1.

$a_1=2$ and $a_{n+1}=2a_n$ for $n\geq1$.


If you can't give such a description or it is intractable to compute more terms, it's still possible that someone may have a useful answer. In this case:

  • Give some context about where the terms came from.
  • Ask whether there are any known useful sequences with those terms, rather than for "the sequence" with those terms; this acknowledges the ambiguity.

For example,

A certain modular form produced the coefficients $196884,21493760,864299970,\ldots$. Do these numbers appear in any other context?

Note that for such questions, your first step should be to search the terms you have in The On-Line Encyclopedia of Integer Sequences. Just beware, as explained above, that a sequence matching the terms you have isn't necessarily the sequence you intend.


Because the question is misunderstood

Problems in mathematics often have a level of finality about them. Problems like

Solve the equation $x+2 = 5$ for $x$

have an objectively right answer that completely settles the question. The answer is $x=3$, period. There is no room for anything else.

(unless you do something like change what you mean by "2" or "+" or such... but really, that's asking a different question that's a homonym for the one given above)

However, problems like

What comes next after 1, 2, 4, 8?

don't have that level of finality. Anything could come next. But these questions are still presented as if they were the same as every other math problems.

It's about guessing patterns

The actual skills that questions like this are supposed to be testing is discerning patterns and guessing how they might be extrapolated. This is useful for purposes such as:

  • Research — guessing patterns is an important aspect of doing mathematics. In simplistic terms, it's often much much easier to verify a correct guess than to try and "solve" for the answer. So, you do want to train students in the art of guessing intelligently.
  • Communication — it is often more convenient to write down a few terms of a sequence and trust the reader can figure out what you mean to say. So, there is value in training students in this skill.

Unfortunately, "what comes next" type questions are rarely posed this way.


The "Lagrange polynomial" is a way of constructing a polynomial to fit a given set of data. If you are given $n+1$ data points there is a polynomial of degree at most $n$ which passes through them. If you add another point ("the next term") you can always fit a polynomial of degree at most $n+1$ to the larger set.

So whatever set of points you are given, you can fit a polynomial to that set, and to any extension of it.

What this means is that given a set of points, there are too many polynomials to give a unique fit. There is insufficient data to provide an answer

As an example, you can fit a straight line (linear polynomial) to any two points, but there are many quadratic polynomials through the same two points.

Suppose we have $n$ points $(x_i,y_i)$ and polynomials $p_i(x)$ with $p_i(x_i)=1$ and $p_i(x_j)=0 \text{ if } i\neq j$, then you will find that the polynomial $$L(x)=\sum y_ip_i(x)$$ has $L(x_i)=y_i$

And we can achieve this by setting $$p_i(x)=\frac {(x-x_1)(x-x_2)\dots (x-x_{i-1})(x-x_{i+1}) \dots (x-x_n)}{(x_i-x_1)(x_i-x_2)\dots (x_i-x_{i-1})(x_i-x_{i+1}) \dots (x_i-x_n)}$$ Which is a polynomial of degree $n-1$ [the term with $x_i$ is the one omitted from the top]

  • $\begingroup$ You should probably explain also how this applies to the sequences in the question. $3,5,7,9,11$ is not a sequence of pairs $(x_i,y_i)$. $\endgroup$ Commented May 8, 2018 at 10:45
  • $\begingroup$ @FedericoPoloni For completeness, a sequence is indexed by integers so you get $(1,3), (2,5), (3,7), (4,9), (5,11)$ for the example you have given. There is an obvious candidate $l(x)=2x+1$ here and if $L(x)$ is another polynomial of degree $\le 4$ which passes through the five points then $l(x)-L(x)$ is a polynomial of degree less than $4$ with five zeros, and hence is the zero polynomial. Whence $L(x)=l(x)$. $\endgroup$ Commented May 8, 2018 at 11:22

Not the answer you're looking for? Browse other questions tagged .