English .   Español  .

The application of Appropriate Technology

# Appendix 5: Interpolation

Page Contents

### Introduction

Interpolation is a method for finding the value of a variable when non-linear data is provided at discrete points (i.e. we do not know the mathematical function of the variable). It involves drawing straight lines between these discrete points and then using the geometric rule for similar triangles to derive the value of a variable at a location between the discrete points.

### Theory

Consider the set of data below:

 X Y 0 0 1 1 2 4 3 9 4 16 5 25

This data can be represented graphically as below:

Figure 12

Imagine we want to find out what the value of Y is for a value of X = 2.4. If we know the function of X (in this case it is X2) then it is easy Y = 2.42 = 5.76. But if we don’t know the function of X (which is more generally the case especially with non-linear data) then how do we find the value for Y ? This is where we can use the approximate method known as interpolation.

Interpolation assumes that we have drawn a straight line between points A and B above, this will give us the following general situation (Figure 13.):

Figure 13

So how do we find Y3 knowing, X1, X2, X3, Y1 and Y2 ?

Well, we note that the triangles ABE and ACD are similar, that is they share the same angles. This means that the ratio of their sides will be similar. So we can say :

Lengths CD/AD = BE/AE, this can be rewritten as:

$\dfrac{\left( Y_3-Y_1\right )}{\left (X_3-X_1\right )}=\dfrac{\left( Y_2-Y_1\right )}{\left (X_2-X_1\right )}$

We are trying to find Y3, so we can rearrange the above equation to isolate Y3.

$\left( Y_3-Y_1\right )=\dfrac{\left (X_3-X_1\right )\times \left( Y_2-Y_1\right )}{\left (X_2-X_1\right )}$

and so:

$Y_3=Y_1+\dfrac{\left (X_3-X_1\right )\times \left( Y_2-Y_1\right )}{\left (X_2-X_1\right )}$

(30)

This is the general interpolation equation.

We can use this equation to approximate the value of any function if we know the coordinates of the points either side (X1, X2) and (Y1, Y2) and the X or Y coordinate of the point we are trying to find.

### Example

Take the example in the theory section above for Y=X2.

What is the value of Y when X=2.4 ?

Answer : We know the following values : X1 = 2, X2 = 3, Y1 = 4, Y2 = 9 and X3 = 2.4. Substitute these into the general interpolation equation (30) given above to give:

$Y_3=4+\dfrac{\left (9-4\right )\times \left (2.4-2 \right )}{\left (3-2\right )}$

And so, the approximation is Y3 = 6. The actual answer is 5.76 (see above), but this is not a bad approximation if we did not know the function.

### Notes

1. The above method should be used in the water pipe friction tables to estimate head losses.
2. The more data points the more accurate this method becomes.
3. The coordinates X1 and Y1 are always associated together, likewise for coordinates X2 and Y2. They define the two discrete points on the curve.