Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any "algorithm" or steps to follow to get a formula from a table of values.


Using this values:

X                Result
1                3
2                5
3                7
4                9

I'd like to obtain:

Result = 2X+1


Maybe using excel?

Edit 2

Additional info:

It is not going to be always a polynomial and it may have several parameters (I think 2).

share|cite|improve this question
Unless you have an assumed functional form, your problem is insoluble. – J. M. Nov 23 '10 at 12:44
@J.M.: I thought so too - but then I found the tool mentioned below! – vonjd Nov 23 '10 at 13:08
up vote 8 down vote accepted

The best tool for doing this is that very, very impressive piece of software:

Edit: For your abovementioned very easy example, even WA will find the right formula:,+5,+7,+9,...

share|cite|improve this answer
The "using building blocks" portion of the software is assuming a functional form (or a family of them as the case may be)... my point is that one cannot just pull a formula from his arse without insight on where the data came from! – J. M. Nov 23 '10 at 13:12
@J.M.: Ok, now I understand what you mean - I agree with that! – vonjd Nov 23 '10 at 13:14
...and more or less, Wolfram Alpha/ Mathematica did exactly what I'm doing in my answer. InterpolatingPolynomial[] uses the Newton divided-difference formula in its implementation. – J. M. Nov 23 '10 at 13:15
I didn't know that - interesting! Thank you – vonjd Nov 23 '10 at 13:17

One way to obtain the desired relationship is to use the regression analysis. In the case that you know what form of the relationship you are expecting, say you know that $f(x) = a * x + b$ it is very simple to find the parameters $a$ and $b$ (see for example). In the case that you don't know what form your formula may take, it is common to use the nonparametric regression techniques.

share|cite|improve this answer

An easier method (assuming that the values were generated by a polynomial) would be to note that successive divided differences $\frac{y_{i+1}-y_i}{x_{i+1}-x_i}$ are constant and equal to 2; thus your function is of the form $y=2x+c$. The constant $c$ is then determined by replacing both $x$ and $y$ with appropriate values, and then solving for $c$.

share|cite|improve this answer
+1: Didn't know that - interesting! Just found this reference: – vonjd Nov 23 '10 at 13:20

I have made a sample in my C# genetic algorithms library, GeneticSharp, that solves your question.

The sample called "Function Builder" receives the function's arguments values and the expected result, then, using genetic algorithms, it try to discover the math function.

Take a look:

GeneticSharp: Function Builder sample

share|cite|improve this answer
It would be useful if there were binary downloads to get this console tool running with latest Mac OS X. Didn't found any link :-( – sreuter Mar 19 at 15:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.