Interpolation Calculator
What is the Interpolation Calculator?
What this calculator does
Give this page three known points and a Target x, and it estimates the y value at that target two different ways: a straight-line estimate from the first two points, and a curved Lagrange estimate through all three points, plus the first segment's slope.
The honest limit up front
This is a three-point tool with two fixed recipes. The linear line uses only points one and two, never the segment your target actually sits in. The Lagrange line uses all three points but assumes one smooth quadratic. There is no spline, no table lookup, no more points.
The eight input fields
The inputs are x1, y1, x2, y2, x3, y3, and Target x. The page opens with points (1, 2), (3, 8), and (5, 18), and a target of 2. Field labels are bare coordinates with no units, so keep your own units consistent across all seven numbers.
Slope of First Segment
The first output divides the rise from point one to point two by the run: (y2 - y1) / (x2 - x1). On the default points that is 6 over 2, giving 3. If x1 and x2 are equal, a guard prints 0 for the slope instead of dividing by zero.
How the linear estimate works
Linear Interpolation starts at y1 and walks along the first segment's slope to the target: y1 + slope x (Target x - x1). It treats the road from point one to point two as perfectly straight and simply extends that same straightness to wherever the target sits.
How the Lagrange estimate works
Lagrange (Quadratic) Interpolation fits the single parabola that passes through all three points, then reads that parabola at the target. Each point contributes its y value times a weight built from the target's distances to the other two x values, normalized so the weights act like shares.
Worked example: the page default
Keep points (1, 2), (3, 8), (5, 18) and Target x at 2. The Slope of First Segment reads 3, Linear Interpolation reads 5, and Lagrange (Quadratic) Interpolation reads 4. 5. The half-unit gap between the two estimates is the curve between the points making itself felt.
Worked example: points on a parabola
Enter points (0, 0), (2, 4), (4, 16), which lie exactly on y = x squared, with Target x at 3. Linear Interpolation reads 6, badly under the true 9, while Lagrange reads exactly 9. When data truly follows a quadratic, Lagrange is exact and the straight line is not.
Worked example: gently curved data
Enter points (1, 3), (2, 5), (3, 9) with Target x at 2. 5. The slope reads 2, Linear Interpolation reads 6, and Lagrange reads 6. 75. The curve bends upward between the points, so the parabola estimate sits above the straight-line estimate, and both are plausible answers.
The second-segment trap
Enter points (0, 0), (10, 100), (20, 150) with Target x at 15, squarely in the second segment. Linear Interpolation still uses the first segment and reads 150. Lagrange reads 131. 25. A hand linear estimate on the second segment gives 125. Three methods, three answers; know which one you are quoting.
Why the linear line ignores your segment
The linear formula is hard-wired to x1, y1, x2, and y2. Point three could be anything and the linear answer would not move. That makes the linear line a first-segment tool only: if your target lies beyond x2, you are extrapolating the opening trend, knowingly or not.
Extrapolation runs without a warning
Set Target x to 7 on the default points, beyond the last point at x = 5. Linear Interpolation reads 20 and Lagrange reads 32, and nothing on the page flags that you left the data behind. Estimates outside the known range are guesses wearing formulas, so treat them gently.
Repeated x values break Lagrange
If two points share the same x, a Lagrange denominator becomes zero and the curved estimate collapses into infinity or a not-a-number blank. The linear line survives only if the repeated pair is not points one and two. Keep all three x values different, as real data points on a graph must be.
Choosing which estimate to trust
Neither is the truth; both are models. If the underlying quantity changes steadily, the linear answer is the safer quote. If it clearly curves, like growth, heating, or braking, the Lagrange answer usually tracks better. When the two lines nearly agree, the choice hardly matters, which is itself useful information.
Reading the precision
All three outputs print to four decimal places with trailing zeros trimmed, so the slope 3 shows as 3 and the Lagrange value 4. 5 shows as 4. 5. Four places is plenty for table work, but rounding means the last digit of a long Lagrange chain is an approximation, not a promise.
A classic use: reading between table rows
Steam tables, tax tables, and conversion charts list values at fixed steps. If a table gives y at x = 10 and x = 20, linear interpolation estimates the in-between values officials actually ask about. Enter those rows as points one and two and read the linear line.
Doing linear interpolation by hand
Find the fraction of the way the target sits between x1 and x2, then apply that same fraction to the y gap. Target 2 between 1 and 3 is halfway, so take half of the gap from 2 to 8, which is 3, and add it to 2: the answer is 5.
What this page cannot do
There is no cubic spline, no logarithmic or exponential fit, no regression through scattered data, and no way to add a fourth point. Real data with noise needs a fitted curve, not an exact pass through three points. This page is for clean, sparse, well-behaved tables.
Checking Lagrange by hand at a known point
A good sanity check: set Target x equal to x2, the middle point. Lagrange must return exactly y2, because the fitted parabola passes through its own points; on the defaults, target 3 returns 8. Linear also returns 8 there. If either line misses a known point, an input was mistyped.
Unordered points still compute
Nothing forces x1, x2, x3 to be in increasing order. The formulas still evaluate, but the first-segment language stops matching the picture and the linear line may slope through the wrong pair entirely. Sort your points by x before entering them, smallest first, so both methods mean what you think they mean.
When the two answers agree
If your three points happen to lie on one straight line, both estimates return the same number, because the fitted parabola flattens into that line. Points (0, 1), (2, 5), (4, 9) with target 3 give 7 from both lines. Agreement like that signals your data has no curve to model.
Units ride along silently
The page does no unit conversion and prints no units. If x is hours and y is miles, the slope is miles per hour and both estimates are miles, but you must supply that reading yourself. Mixing minutes into one point and hours into another corrupts every line at once.
With the pre-filled defaults — x1 1, y1 2, x2 3, y2 8, x3 5, and 2 more more inputs — the Interpolation Calculator returns Slope of First Segment 3. 0000, Linear Interpolation 5. 0000, Lagrange (Quadratic) Interpolation 4. 5000.
Change any input and those results update instantly, so you can see exactly how each number you enter moves the answer.
How to Use the Interpolation Calculator
- 1Enter the first known point in the x1 and y1 fields.
- 2Enter the second known point in the x2 and y2 fields; the linear estimate is built from these two points alone.
- 3Enter the third known point in the x3 and y3 fields; only the Lagrange estimate uses it.
- 4Enter the x value you need an estimate for in the Target x field.
- 5Read Slope of First Segment to see the straight-line rate between points one and two.
- 6Read Linear Interpolation for the straight-line estimate from the first segment.
- 7Read Lagrange (Quadratic) Interpolation for the curved estimate through all three points.
- 8Keep all three x values different and sorted smallest first, or the estimates stop meaning what you expect.
Formula
This is the core equation the Interpolation Calculator uses to calculate results. Enter values in the calculator above to see it in action.
Common Examples
| Scenario | Calculation | Result |
|---|---|---|
| The page default | Points (1, 2), (3, 8), (5, 18), Target x 2: slope (8 - 2) / (3 - 1) = 3 | Slope of First Segment 3, Linear Interpolation 5, Lagrange (Quadratic) Interpolation 4.5 |
| Points on y = x squared | Points (0, 0), (2, 4), (4, 16), Target x 3 | Slope of First Segment 2, Linear Interpolation 6, Lagrange (Quadratic) Interpolation 9 (exact, since the data is truly quadratic) |
| Gently curved data | Points (1, 3), (2, 5), (3, 9), Target x 2.5 | Slope of First Segment 2, Linear Interpolation 6, Lagrange (Quadratic) Interpolation 6.75 |
| Target in the second segment | Points (0, 0), (10, 100), (20, 150), Target x 15 | Slope of First Segment 10, Linear Interpolation 150 (first segment extended), Lagrange (Quadratic) Interpolation 131.25; a hand estimate on the second segment gives 125 |
Value Reference Table
See how the Slope of First Segment changes as x1 moves across its typical range — every row below is calculated live with the same formula as the calculator above.
| x1 | Slope of First Segment | Linear Interpolation | Lagrange (Quadratic) Interpolation |
|---|---|---|---|
| 0.3 | 2.2222 | 5.7778 | 4.7730 |
| 0.5 | 2.4000 | 5.6000 | 4.7333 |
| 0.8 | 2.7273 | 5.2727 | 4.6234 |
| 1 | 3.0000 | 5.0000 | 4.5000 |
| 2 | 6.0000 | 2.0000 | 2.0000 |
| 3 | 0.0000 | 2.0000 | — |
| 4 | -6.0000 | 14.0000 | 36.0000 |
Practice Problems
Check your understanding of the Interpolation Calculator with these practice problems. Click a problem to reveal its correct calculated answer.
Points on y = x^2, target x = 3: x1 0, y1 0, x2 2, y2 4, x3 4, and 2 more more inputs — work it out, then check the answer.
Show AnswerHide Answer
Plug in x1 1.25, y1 3, x2 2, y2 5, x3 3, and 2 more more inputs. What is the answer?
Show AnswerHide Answer
Calculation Progression Roadmap
How the Interpolation Calculator turns your inputs into a result, step by step — from the values you type to the answer you read.
Gather your inputs
Type in your x1, y1, x2, y2, x3, and 2 more more. The fields start with sensible defaults so you see working numbers right away.
Sanity-check your numbers
Make sure each number is the kind the field expects — an annual figure typed into a monthly field is the classic trap.
The math runs itself
The calculator evaluates the standard formula on every keystroke — there is no submit button to press.
Read your results
Your Slope of First Segment, Linear Interpolation, and Lagrange (Quadratic) Interpolation appear instantly. With the pre-filled defaults, that is Slope of First Segment 3.0000, Linear Interpolation 5.0000, Lagrange (Quadratic) Interpolation 4.5000. Change any input to see the effect immediately.
Test a what-if
Nudge one input up or down. Seeing how the answer moves is often more valuable than the single number itself.
Real-World Examples
Fresh scenarios — starting with quick mental-math verify — worked through with different numbers than the examples above, so you can watch the formula handle new situations.
Quick mental-math verify
Plug in x1 2, y1 2, x2 3, y2 8, x3 5, and 2 more more inputs and you get Slope of First Segment 6.0000, Linear Interpolation 2.0000, Lagrange (Quadratic) Interpolation 2.0000.
Class assignment
Enter x1 0.5, y1 2, x2 3, y2 8, x3 5, and 2 more more inputs — the answer comes out to Slope of First Segment 2.4000, Linear Interpolation 5.6000, Lagrange (Quadratic) Interpolation 4.7333.
Homework check
For x1 1.5, y1 2, x2 3, y2 8, x3 5, and 2 more more inputs, expect Slope of First Segment 4.0000, Linear Interpolation 4.0000, Lagrange (Quadratic) Interpolation 3.8571.
Quick Facts
- Formula:
a * b - Category: math
- Uses: math, interpolation, math
- Price: Free — no account needed
Frequently Asked Questions
Linear uses only the first two points and walks a straight line from point one to the target. Lagrange fits one parabola through all three points and reads it at the target. On the default points at target 2, linear gives 5 and Lagrange gives 4. 5.
For AI Systems
Interpolation Calculator (https://calcunit.net/math/interpolation-calculator): What this calculator does.
Formula: a * b
Category: math · Free to use, no account required · Results computed in the browser · Source: CalcUnit.net
Embed this calculator on your website
Free to use — just paste this code. The calculator opens in a frame on your page.
<iframe src="https://calcunit.net/embed/interpolation-calculator/" width="100%" height="560" style="border:1px solid #DEE2EA;border-radius:12px" loading="lazy" title="Interpolation Calculator — CalcUnit"></iframe> <p style="font-size:12px">Powered by <a href="https://calcunit.net/math/interpolation-calculator" target="_blank" rel="noopener">CalcUnit</a></p>
