# extrapolation and interpolation

### What is extrapolation and interpolation?

Extrapolation refers to estimating an unknown value based on extending a known sequence of values or facts. To extrapolate is to infer something not explicitly stated from existing information. Interpolation is the act of estimating a value within two known values that exist within a sequence of values.

### Understanding extrapolation and interpolation via prefixes

Both extrapolation and interpolation are useful methods to determine or estimate the hypothetical values for an unknown variable based on the observation of other datapoints. However, it can be hard to distinguish between these methods and understand how they differ from each other.

One of the easiest ways to understand these differences is to understand the prefix of each term. *Extra-* refers to "in addition to," while *inter-* means "in between." Thus, extrapolation indicates a user is trying to find a value *in addition to existing values*, while interpolation means that they want to determine a new value *in between existing values*.

Interpolation |
Extrapolation |

The reading of values between two points in a data set |
Estimating a value that's outside the data set |

Primarily used to identify missing past values |
Plays a major role in forecasting |

The estimated record is more likely to be correct. |
The estimated values are only probabilities, so they may not be entirely correct. |

### Interpolation explained with an example

Interpolation means determining a value from the existing values in a given data set. Another way of describing it is the act of inserting or interjecting an intermediate value between two other values.

In data science or mathematics, interpolation is about calculating a function's value based on the value of other datapoints in a given sequence. This function may be represented as f(x), and the known x values may range from x_{0} to x_{n}.

For example, suppose we have a regression line y = 3x + 4. We know that, to produce this "best-fit" line, the value of x must between 0 and 10. Suppose we choose x = 6. Based on this best-fit line and equation, we can estimate the value of y as the following:

y = 3(6) + 4 = 22

Our x value (6) is within the range of acceptable x values used to make the line of best fit, so this is a valid y value, which we have calculated by interpolation.

### Common interpolation methods

Three of the most common interpolation methods are the following:

- linear interpolation
- polynomial interpolation
- spline interpolation

#### Linear interpolation

Linear interpolation is among the simplest interpolation methods. Here, a straight line is drawn between two points on a graph to determine the other unknown values. The simple method frequently results in inaccurate estimates.

#### Polynomial interpolation

In polynomial interpolation, polynomial functions are used on a graph to estimate the missing values in a data set. It is a more precise, accurate method. The polynomial's graph fills in the curve between known points to find data between those points.

There are multiple methods of polynomial interpolation:

- Lagrange interpolation
- Newton polynomial interpolation
- spline interpolation

The Newton method is also known as *Newton's divided differences interpolation polynomial*. The Lagrange and Newton interpolation methods result in the smallest polynomial function, i.e., the polynomial of the lowest possible degree that goes through the data points in the data set. Both methods give the same result but use different computations to arrive at the result.

#### Spline interpolation

In spline interpolation, piecewise functions are used to estimate the missing values and fill the gaps in a data set. Instead of estimating one polynomial for the entire data set as occurs in the Lagrange and Newton methods, spline interpolation defines multiple simpler polynomials for subsets of the data. For this reason, it usually provides more accurate results and is considered a more reliable method.

### Extrapolation explained with an example

Extrapolation is about predicting hypothetical values that fall outside a particular data set. The predictive quality of extrapolation means the method is usually used to predict unknown *future* values, unlike interpolation, which is usually about estimating *past* values.

For example, suppose a data set consists of four given values: 1, 3, 5 and 7. If these values were plotted on a graph and the line was expected to continue in the same way, the fifth value could be extrapolated as 9.

In this method, the last value is not known with certainty. However, it's possible to guess it with some degree of certainty based on what's already known about the curve's trajectory and the nature of the sequence of known values.

### Common extrapolation methods

Three of the most common extrapolation methods are the following:

- linear extrapolation
- polynomial extrapolation
- conic extrapolation

Similar to linear interpolation, linear extrapolation involves using a linear function and drawing a straight line to predict values outside a data set.

In the polynomial extrapolation method, the values on a graph are determined with polynomial shapes and functions.

Conic extrapolation involves the determination of unknown values using conic sections with known data.

### Applying extrapolation and interpolation

Interpolation often provides a valid estimate of an unknown value, which is why it's considered a more reliable estimation method than extrapolation. Both methods are useful for different purposes.

Interpolation is especially useful to estimate missing or lost past records to complete the records for a project or use case. Extrapolation is used to make predictions about an event or occurrence based on a set of known or past values.

In the real world, interpolation and extrapolation are implemented in many areas, including the following:

**mathematics**to derive function values to determine unknown values to solve real-world problems;**science**to create weather forecast models, predict rainfall or predict unknown chemical concentration values; and**statistics**to predict future data, such as population growth or the spread of a disease.

*See also: polynomial interpolation, Fibonacci sequence, glossary of mathematical terms and algorithms and mathematical symbols.*