Mathematical concepts
Linear interpolation
Also called: lerp · interpolate between points · lookup table
Definition
Linear interpolation estimates a value between two known points by assuming a straight line between them.
Picture it
If a thermistor table gives 10 kΩ at 25 °C and 8 kΩ at 30 °C, then 9 kΩ is probably near 27.5 °C. Firmware uses lookup tables with interpolation when the true formula is awkward or expensive to compute.
The maths
y = y0 + (x − x0) × (y1 − y0) / (x1 − x0) lerp(a, b, t) = a + t (b − a), 0 ≤ t ≤ 1
| Quantity | Unit | Symbol |
|---|---|---|
| ratio | dimensionless | 1 |
Worked example
A sensor table gives 1.20 V at 20 °C and 1.40 V at 30 °C. Estimate the temperature at 1.33 V.
- Fraction along = (1.33 − 1.20) / (1.40 − 1.20) = 0.65
- T = 20 + 0.65 × 10 = 26.5 °C
AnswerAbout 26.5 °C.
✓ The number in this answer is recomputed from scratch by an automated test.
Common misconceptions
- Misconception: Interpolating inside the table is usually safe; extrapolating beyond it is guesswork.
- Misconception: Linear interpolation of a strongly curved function needs closely spaced points.