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

  • 2
    $\begingroup$ 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$. $\endgroup$
    – Workaholic
    Mar 21, 2015 at 21:53
  • 3
    $\begingroup$ Given any such table there are infinite polynomials which agree with the tables. See for instance Lagrange interpolation. $\endgroup$
    – Git Gud
    Mar 21, 2015 at 21:55
  • $\begingroup$ Is there a best fit polynomial? What is the mathematical concept behind finding the best fit polynomial? $\endgroup$
    – user126888
    Mar 21, 2015 at 22:11
  • 1
    $\begingroup$ 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. $\endgroup$
    – Noiralef
    Mar 21, 2015 at 22:34
  • $\begingroup$ The first one could have been $f(x)=2^x$ as another solution. $\endgroup$
    – JB King
    Mar 21, 2015 at 23:20

1 Answer 1


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.

  • $\begingroup$ I see. However, is there a best solution to my context, simply the best solution, but not the solution? $\endgroup$
    – user126888
    Mar 21, 2015 at 22:10
  • $\begingroup$ Yes --- but first, you have to give a precise definition of "best". That's most of the battle, working out exactly what it is that makes one solution better (for your particular purposes) than another. $\endgroup$ Mar 21, 2015 at 23:06
  • $\begingroup$ @Michaelwm By "best", you probably mean "simplest". In that sense, most people would probably agree that the lowest possible degree polynomial is the "best". $\endgroup$ Mar 22, 2015 at 11:48

You must log in to answer this question.