Linear Interpolation

Linear Interpolation

Oftentimes in physics or engineering, we know the value of a quantity at certain points but not others. For example take a look at this saturation table for water. We know the thermodynamic properties of water at certain temperatures (, , ,…). However, suppose we want to know the saturation pressure of water at . What do we do? It’s not on the table!

Teacher Cupcake

Linear interpolation allows us to figure out the values between entires in that table. It is easiest to think about linear interpolation in terms of the graph of a straight line. Take a look at the simple graph of a line below.

Linear Graph

Suppose we know the values of two points on the graph: and . We want to determine the value of at some point along the line connecting the two known points. First, we can write out a simple ratio that relates the known values to the unknown values.

Now, we can multiply each side of the expression by .

Finally, we can move to the other side of the equation to get the formula for .

Going back to the saturation table from before, suppose I want to determine the saturation pressure for water at (). We will let the variables represent pressure and the variables represent temperature. Plugging in the appropriate values gives:

Linear interpolation is not just restricted to table entires. Suppose I have some continuous function . I can pick two points along the curve and estimate the value of the function at some point between them using the equation above. However, we have to be careful - our estimate may not be very accurate if the function is very curvy.

Visualizing the Error in Linear Interpolation

There are lots of websites that derive the error bounds in linear interpolation (e.g. here and here and here and here). Instead of doing yet another error derivation, I would like to visualize what linear interpolation is actually doing. From there, it is easy to see where the error comes from.

In the graph below, I have plotted an equation that has lots of bends and wiggles:

You can adjust the values of the endpoints and the point of interpolation. The readout will tell you the percent error of the interpolated value () versus the actual value of the function at . Think about a couple of things as you play with the simulation:

  1. How does the error change as the known points get farther apart?
  2. How does the error change between the extra curvy parts of the graph and the straighter parts of the graph?
Endpoint A (0.00, 6.00)
Endpoint B (3.00, 5.17)
Interpolated Point (C) (1.50, 5.58)
Percent Error 129.62 %