# How to concatenate two or more linear interpolants?

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?

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?

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.