This course teaches how to install and configure Windows Server 2012 R2. It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

I have a number of x,y value pairs. I want to approximate a function y= a + bx + cx^2 + dx^3 + ex^4 + fx^5 + gx^6 ...

How do I get this function with the use of the known x1, ... xn and y1, ... yn?

How do I get this function with the use of the known x1, ... xn and y1, ... yn?

One can also look for lower degree polynomials and fit them using least square methods.

One way to find an exact interpolation is to look at polynomials of the form

f_k(x) = (x - x_1)*(x - x_2)*...*(x - x_{k-1})*(x - x_{k+1})* ... * (x-x_n)

These are 0 at all sample points except at x_k.

Hence one can easily combine them to a polynomlia with f(x_i)=y_i for all i.

However, it is often the case that polynomial interpolation simply "does not look good" (shows large oscillation and other artefacts). You may want to have a look at spline interpolation (smoothly joined piecewise polynomials).

However, as thehagman points out, this type of polynomial is very dependent on the exact number of points. If you so happen to add the (n+1) point, your initial polynomial may not look at all like the new one. If you're dealing with a real-world application, this can have unintended results.

This is why, if your number of input points may vary, you don't always want to deal with max-degree polys. Instead, you choose something like a cubic spline where the addition or removal of a single point will generally not have any influence on the behavior of the curve outside of the neighborhood of the new point.

Take a look at

http://en.wikipedia.org/wiki/Spline_(mathematics)

http://mathworld.wolfram.com/Spline.html

http://mathworld.wolfram.com/CubicSpline.html

Excell, mathcad, matlab, mathematica, and most statistical programs will have a least square function which will do what you want.

y2 = a + b x2 + c x2^2 + d x2^3 + e x2^4 + f x2^5 + g x2^6 .

...

is a system of linear equations which you can solve for a,b,c,d,e,f,g

If you want to find coefficients that minimize the sum of the squares of the errors, that turns out to be equivalent to solving another system of linear equations, this time with coefficients like:

sum(Yi) = a n + b sum(Xi) + c sum(Xi^2) + d sum(Xi^3 ) + ...

sum(Yi*Xi) = a sum(Xi) + b sum(Xi^2) + c sum(Xi^3) + d sum(Xi^3 ) + ...

sum(Yi*Xi^2) = a sum(Xi^2) + b sum(Xi^3) + c sum(Xi^4) + d sum(Xi^5 ) + ...

...

where sums are over i=1..n for n points

There is no magic wand for data fitting. Giving more details of the problem you are trying to solve would help.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

D= y - a + bx + cx^2 + dx^3 + ex^4 + fx^5 +..

where you have guessed the coefficients abcd..

This would give a 'distance', D, from the line for each point; add the absolute values of these together to get a score for the set of guessed coefficients. you then guess different sets of coefficients until you minimise D - such that the points are as close to the line as you can get.

I think Excel has a function that does it, you will get better results with more powers in the equation, because, I believe, you can always fit n points exactly to a nth - order polynomial.

further reading:

http://en.wikipedia.org/wiki/Curve_fitting

http://zunzun.com/