# Algebraically Deriving a function from a Table of Values

Is there an algebraic solution to deriving a function from a table of values, for example: \begin{array} {|r|r|} \hline x &f(x) \\ \hline 1 &2 \\ \hline 2 &4 \\ \hline \end{array}

which produces $f(x)=2x$

\begin{array} {|r|r|} \hline x &f(x) \\ \hline 1 &1 \\ \hline 2 &4 \\ \hline 3 &9 \\ \hline \end{array}

which produces $f(x)=x^2$

How can this be derived algebraically? And what will result if you are given a table of values that does not represent a function? Is it possible to find a table of values that is similar that will result in a function?

Context: I'm writing software that interprets an image and finds it's outline, then converts the outline to a set of polynomials that when drawn, create an outline similar within a degree of the original images outline

• You can't derive a single function from a table of values if you don't have the whole values of that functions, since there are infinitely many functions which satisfy $f(1)=2$ and $f(2)=4$. Mar 21, 2015 at 21:53
• Given any such table there are infinite polynomials which agree with the tables. See for instance Lagrange interpolation. Mar 21, 2015 at 21:55
• Is there a best fit polynomial? What is the mathematical concept behind finding the best fit polynomial?
– user126888
Mar 21, 2015 at 22:11
• There is a best fit polynomial: For $n$ given values, there is exactly one polynomial of degree $n-1$ fitting the values. Finding it is just solving a linear system of equations. It might be the case, however, that you don't really want a polynomial (a polynomial interpolation often gets weird near the end points) but for example a spline. You have to choose something, look e.g. on Wikipedia. Mar 21, 2015 at 22:34
• The first one could have been $f(x)=2^x$ as another solution. Mar 21, 2015 at 23:20

There is, if you restrict yourself to for example "polynomials of degree $n$". Given how broad the function concept is, it is easy to see how ill-posed your question is. Just consider the class of functions $f(x) = 2$ for $x=1$, $f(x) = 4$ for $x=2$, $f(x) = y(x)$ for every other $x$. Every conceivable function $y(x)$ constructs an $f(x)$ that fulfils your criteria!
Even if you restrict yourself to continuous functions, there is in general infinitely many functional solutions to your constraints. In genereal however, for $n+1$ data points, a $n$ degree polynomial that interpolates the data points is uniquely given.