148Views4Replies

# How to concatenate two or more linear interpolants? Answered

I have a graph, it is not a straight line but a random curve, I want to do linear interpolation of different data set points. I read it here:

http://en.wikipedia.org/wiki/Linear_interpolation#Interpolation_of_a_data_set

And it says that:

"Linear interpolation on a set of data points (x0, y0), (x1, y1), ..., (xn, yn) is defined as the concatenation of linear interpolants between each pair of data points."

So. how can I concatenate two or more linear interpolants?
And can you please also give an example of it?

Tags:

## Discussions

Linear interpolation only involves two points: By "concatenating," the text means that between (x,y)0 and (x,y)1 you use one interpolation function, then between (x,y)1 and (x,y)2 you use a new interpolation function, and so on. At the point where they touch, (x,y)1, both functions will give the identical result (namely, (x,y)1 itself). Of course, with linear interpolation you will not have a smooth first derivative.

For the region (x,y)0 to (x,y)1, the interpolation is:

y(x) = y0 + (x-x0) * (y1-y0) / (x1-x0)

For the region (x,y)1 to (x,y)2, the interpolation is:

y(x) = y1 + (x-x1) * (y2-y1) / (x2-x1)

and so on. If you plug in x1 into both of the above functions, you'll see that you get y1 out, as expected for a concatenation.

Yes, but I was trying to use the same terminology as the OP. With N points, a cubic spline would give a much better approximation, unless the original curve was already mostly linear.

Got to reckon P-WLA makes more sense than "concantenation of linear interpolants"...