What it is
The online interpolation and extrapolation service (linear interpolation/extrapolation) helps you calculate the value of a linear function when f(x) is known at two different points, and also calculates the equation of the straight line. The service automatically chooses the right calculation method — you just enter the values at two arbitrary points and the point at which the value should be calculated.
Interpolation (from Latin interpolatio — alteration, remaking) in mathematics and statistics is a way to calculate an intermediate value of a function from several already known values. For example, there is a function f(x) whose values are known at x0 and x2; interpolation helps to find f(x1) provided that x1 belongs to the interval from x0 to x2. If x1 lies outside the interval (x0, x2), interpolation will not help — use extrapolation instead.
Extrapolation is a way to calculate the value of a function outside the known range. If f(x) is known at x1 and x2, extrapolation helps to find f(x0) or f(x3) when x0 is below and x3 above the interval from x1 to x2. If the point is inside the interval (x1, x2), you need interpolation.
These methods are often called "linear interpolation" and "linear extrapolation"; they give a 100% correct result for the equation of a straight line.
How it is calculated
Both interpolation and extrapolation are based on the proportion
(y1 − y0) / (y2 − y0) = (x1 − x0) / (x2 − x0)
— the increment of the value at the first point relates to the increment of the value at the second point as the increment of the argument at the first point relates to the increment of the argument at the second (all relative to the zero reference point). From this proportion it is easy to derive the formula for any value:
y1 = y0 + (x1 − x0) · (y2 − y0) / (x2 − x0)
The fraction (y2 − y0) / (x2 − x0) is the slope k, giving the line equation f(x) = k·x + b with b = y0 − k·x0.
Example
Given f(10) = 100 and f(20) = 300, find f(15) and f(25):
- Slope k = (300 − 100) / (20 − 10) = 20, b = 100 − 20·10 = −100, the line is f(x) = 20x − 100.
- Interpolation: f(15) = 100 + (15 − 10)·20 = 200 — the point is inside the interval.
- Extrapolation: f(25) = 100 + (25 − 10)·20 = 400 — the point is outside.
Another example: f(1) = 2.5, f(3) = 6.5 ⇒ k = 2, and at 4.2 (upward extrapolation) f = 2.5 + 3.2·2 = 8.9.
Good to know
- The two x values must be different — otherwise no line can be drawn.
- For a straight line the result is exact. For a curve (quadratic, exponential) linear interpolation is an approximation, the better the closer the nodes; extrapolation loses accuracy quickly with distance.
- For functions of two variables there is bilinear interpolation (double interpolation).
- If more than two points are known and the dependence is non-linear, you can also use the services Interpolation — Newton polynomial and Interpolation — Lagrange polynomial.
Where it is used
- Reference tables — engineering standards, heat-transfer, density and vapour-pressure tables: a value between table rows.
- Engineering and metrology — two-point sensor calibration, converting a 4–20 mA signal into a physical quantity.
- Finance and economics — a rate for an intermediate term, an estimate between two reporting dates, a simple trend forecast.
- Graphics, animation, games — smooth colour or position transitions (lerp) between two keyframes.
- Science and studying — intermediate values in lab work, checking homework.
How to use
- Enter two known points, x1, f(x1) and x2, f(x2), and in xN the point where you need the value.
- Press "Calculate". If you tick the box inside the "Calculate" button, the calculator recalculates automatically on every change of the input data.
- The calculator determines by itself whether it is interpolation or downward/upward extrapolation and shows the line equation f(x).
- Fractions, decimal commas, roots, trigonometry and powers work (examples are listed under the form). The link to the calculation can be copied.