Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Introduction

There are a few different types of interpolation techniques.  One relies on creating a curve of
best fit taking into account the entire data set.  This is addressed in the topic Trendline
Coefficients and Regression Analysis.  Another technique uses piecewise linear
interpolation.  As the name implies it fits a straight line to each consecutive pair of data
points and uses the appropriate straight line for interpolation.  It is this technique that is
discussed in this section.  Other techniques rely on smooth curves that pass through all the
data points.  These typically are Cubic Spline or Bezier curves and are outside the scope of
this section.

An example of piecewise linear interpolation:

Figure 1 Figure 2 --
Each consecutive pair of points is connected by a straight
line

Also, suppose that the ranges containing the X and Y values are named XVals and YVals
respectively.  If necessary, use Insert | Name > Define... to name cell ranges.

Note that the x values must be sorted in ascending order.

The basics
Using linear interpolation, given any two points (x0, y0) and (x1, y1) and the value x2, where
x0≤x2≤x1 the corresponding y2 value is given by

y2 = y0 + (y1-y0) / (x1-x0) * (x2-x0)

For example, given two data points (x0, y0) = (10.75, 25.003) and (x1, y1) = (30.8, 33.33) the y
value that corresponds to the x-value given by x2 = 11 would be

y2 = 25.003 + (33.33 - 25.003) / (30.8 - 10.75) * (11 - 10.75) or y2 = 25.1068

Applying the basics to a data set in Excel


Given any data set (such as the one if Figure 1 above), and a target X value, the first step is to
find the 2 X-values that bracket it.  These 2 values will correspond to x0 and x1.
Suppose the target X value is given by a cell named TargetVal as in:

Use the MATCH function to find which x-value corresponds to x0 for this targetVal.

Name the cell containing the formula with the MATCH function as MatchIdx.

This is the index into the XVals range that corresponds to the x0 value.  The index for the x1
value, will be one greater than MatchIdx.  The actual x0 value is given by INDEX(XVals,
MatchIdx) and the x1 value by INDEX(XVals, MatchIdx+1)

The corresponding y values, i.e., y0 and y1, are the same indices applied to the YVals range:
INDEX(YVals, MatchIdx) and INDEX(YVals, MatchIdx+1)

Hence, we can now construct the desired result as:

Note this is exactly the same as = y0 + (y1-y0) / (x1-x0) * (x2-x0)

Alternative formulations
It is possible to simplify the analysis with other built-in Excel functions.  The FORECAST
function is normally used for interpolation with an entire data set.  However, if its arguments
are only two data points, its result will be the same as a piecewise linear interpolation.

One can also use the OFFSET function to further simplify the formula.

You might also like