From: rusin@vesuvius.math.niu.edu (Dave Rusin) Newsgroups: sci.math Subject: Re: Formula on a group of number Date: 2 Dec 1997 14:41:24 GMT In article <65ti9r$sic3@news.fiberlink.net>, RICKY CHU wrote: >I am looking for a methodology to find a formula from a group of numbers so as >to know the next number. You and everybody else. If I could always do that, then I could predict today's closing average on the New York Stock Exchange, using only the numbers from previous days. But of course "the next number" could be anything, couldn't it? If you think the terms in the sequence come from some well-known pattern, you could visit http://www.research.att.com/~njas/sequences and ask if the terms you do have fit into any known sequence. >Dr. math told me to use the following formula to find it >out. However, it can't get the following numbers. > >a + b(n) + c(n^2) + d(n^3) + e(n^4) +... = number. If you _assume_ the n-th term of the sequence is given by some polynomial in n, then yes, you can determine what the polynomial must be, assuming you have more terms than the degree of the assumed polynomial. The technique is Lagrange interpolation. Given a sequence y_0, y_1, y_2, y_3, ..., if y_n is a polynomial function P(n) of n, you can discover P as follows: 1. Initialize P(n) to be the constant polynomial P(n) = y_0 2. For each i > 0, replace P(n) by the polynomial P(n) + (y_i - P(i)) * (n*(n-1)*(n-2)*...*(n-i+1)) / i! 3. Stop when you run out of data, or when P has the desired degree. Do you see how step 2 works? The new polynomial is different from the old, but they have the same value at n = 0, 1, 2, ..., i-1. On the other hand, the new one's value at n = i is precisely y_i. Exercise: determine the next term in this sequence: 1, 2, 4, 8, 16, 32, ___ (surprise!) dave