# Construct / find the simplest function based on data

Let's say I have these 7 natural numbers (all between 0 and 255):

255, 23, 45, 32, 87, 52, 146


How can I find a function F(x) that, once computed, gives me back these values, ie.

f(1) = 255
f(2) = 23
f(3) = 45
...


I'm not sure what's the technical term to use for this, but I trust you got the picture.

All the above numbers are just examples (except that all values are natural number between 0 and 255).

All I really care is that I need the simplest possible function that can give me such result, be it polynomial, quartic or any other type of function.

I used to be good at math, but it's been at least 10 years since I took my last math class, so please bear with me!

• Lagrange interpolation provides a nice general polynomial answer. However, suppose that $f(1)=2$, $f(2)=4$, $f(3)=8$, and so on. Then $f(n)=2^n$ is a simple formula, while the Lagrange interpolation polynomial is fairly messy. Mar 17, 2012 at 17:50
$$f(x)={1291x^6-31029x^5+296455x^4-1434195x^3+3689254x^2-4761696x+2423520\over 720}$$