Linear Interpolation

Consider the following problem, which is very common in engineering. If the values of y vs. x are given in a table like the one below, how can we estimate the value of y , which corresponds to x = 2.51?

x y
2.34 16.8
2.67 23.8
3.01 24.8
3.23 25.9

There are two parts to the solution of the problem.

a) We must locate the interval of the table, which sandwiches the given value of x as tight as possible. Looking at the table we see that the appropriate interval for x = 2.51 is the first, i.e. 2.34 <= x <= 2.67. This identification is very simple when we do it with our eyes and brain. But it may become quite involved if we want our program to do it and especially when the table has many-many lines ( think about something as long as a telephone book, without Rainman present)

b) Having located the two table lines above and below our data entry, it is now time to write the equation of a straight line between the two points on the x-y plane whose coordinates are given by these two table lines. We can then use this relationship to predict y.

Show that one obtains:

We can explain it as follows: If y is to be calculated using linear interpolation then the point x,y ( represented by the smiling face in the figure below) must fall exactly on the red line which connects the two points illustrated by the crosses. If we write the slopes of the red line and blue line and equate them , we obtain the above relationship

Accordingly we obtain for x = 2.51, the slope as: (23.8 - 16.8) / ( 2.67 - 2.34) = 21.2121

And hence: y = 16.8 + 21.2121 * ( 2.51 - 2.34) = 20.406

 

Jacob Y. Kazakia © 2001 All rights reserved