Find formula from values

The best tool for doing this is that impressive piece of software: http://www.nutonian.com/products/eureqa/

Edit: For your abovementioned very easy example, even WA will find the right formula: http://www.wolframalpha.com/input/?i=3,+5,+7,+9,...

Edit 2: Unfortunately Nutonian was bought by DataRobot and their product is no longer freely available (not even for academic use). Yet in many cases other solutions exist, see e.g. my blog post here: Symbolic Regression, Genetic Programming… or if Kepler had R.


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$.


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