# Approximating/Fitting a function to points

1. Aug 2, 2009

### thomas49th

Hi, given a function of x, where x increases in uniform increments (ie x goes 1, 2, 3) and y culmalatively increases in the domain x>0, what methods are there to fit a function it to? I want to know method/algorithm that can fit a line/curve to it. So given these points

(1,4)
(2,5)
(3,2)
(4,7)
(5,1)
(6,1)

I want a Cartesian equation (y= function of x) that can accurately plot a curve through these points - like how a taylor series can be used to approximate functions, but I want to be able to produce a function, or approximate one without. I know that the more disperse the points are from each other the higher the degree of the polynomial (if a polynomial method is used)

Thanks
Thomas
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

2. Aug 2, 2009

### John Creighto

There are infinite possibilities.

You can not determine a unique taylor series unless you have infinite days (i.e. know every derivative. However, you can do a polynormial fit for the form:

$$y=a+bx+cx^2+ex^3+fx^4+gx^5$$

For each point, you plug in a value for y and x and you end up with six equations and six unknowns. This is a type of bilinear fit and more generally:

$$y=a_1f_1(x)+...+a_nf_n(x)$$

where the functions $$f_1(z)..f(n)$$ are independent over the points $$(x_1,y_1),...,(x_n,y_n)$$.

It is generally not a good idea to fit a lot of points with a higher order polynomial because the fit can be real wavy (noisy). For interpolation, piece wise fits are preferred. Also if you are trying to discover any relationship between the points, it is better to have more data, then unknowns. You won't fit the points exactly but if the data was given at random there would be less variance in your estimates. When you are trying to fit more data then you have unknowns you decide on some optimization criteria like minimum mean squared error.

3. Aug 2, 2009

### AUMathTutor

Generally speaking, you try to guess the behavior of the trend from the source. Common choices include exponentials, logarithms, polynomials, and rationals. Trig functions, too. Just play around. Unless you have some clue as to what the function should look like, you can come up with functions that hit all of those points, that hit some of them, and that are pretty close, ad infinitum.