Numerical Methods for Engineers

Interpolation and curve fitting

Use this for “Fit a quadratic through (1, 2), (2, 3) and (4, 11) and estimate y at x = 3.”

Chart

f(x) = 3 − 2x + x201234560510152025xy(3, 6)(1, 2)(2, 3)(4, 11)
f(3) = 6
Ringed: the nodes (1, 2), (2, 3), (4, 11)
This is an example. Type your own values to start a new problem.
x₀
Node 0, x
example
y₀
Node 0, y
example
x₁
Node 1, x
example
y₁
Node 1, y
example
x₂
Node 2, x
example
y₂
Node 2, y
example
x
Point to estimate
example
L₀
Weight of node 0
worked out (not typed)
L₁
Weight of node 1
worked out (not typed)
L₂
Weight of node 2
worked out (not typed)
y
Estimated value
calculated

Formulas

L₀
=
(
x
−
x₁
)
×
x
−
x₂
(
x₀
−
x₁
) × (
x₀
−
x₂
)
−
1
3
=
(3
−
2)
×
3 − 4
(1 − 2) × (1 − 4)
L₁
=
(
x
−
x₀
)
×
x
−
x₂
(
x₁
−
x₀
) × (
x₁
−
x₂
)
1
=
(3
−
1)
×
3 − 4
(2 − 1) × (2 − 4)
L₂
=
(
x
−
x₀
)
×
x
−
x₁
(
x₂
−
x₀
) × (
x₂
−
x₁
)
1
3
=
(3
−
1)
×
3 − 2
(4 − 1) × (4 − 2)
y
=
y₀
×
L₀
+
y₁
×
L₁
+
y₂
×
L₂
6
=
2
×
(−
1
3
)
+
3
×
1
+
11
×
1
3

Assumptions

•
The three node x values differ; the quadratic through them is unique.
•
Lᵢ(x) is 1 at node i and 0 at the other two nodes, so y passes through every node.
•
Between the nodes this interpolates; outside them it extrapolates, and the error can grow fast.

Step-by-step

WE KNOW
x = 3, x₀ = 1, y₀ = 2, x₁ = 2, y₁ = 3, x₂ = 4, y₂ = 11
FIND
weight of node 0 (L₀), weight of node 1 (L₁), weight of node 2 (L₂), estimated value (y)
Step 1 · Find weight of node 0 (L₀)
Use L₀ = (x − x₁) × (x − x₂) ÷ ((x₀ − x₁) × (x₀ − x₂))
Node 0’s basis: the product is 0 at the other two nodes, and dividing by its value at node 0 makes it 1 there.
L₀
=
(3
−
2)
×
3 − 4
(1 − 2) × (1 − 4)
L₀
=
(3
−
2)
×
3 − 4
(−1) × (−3)
L₀
=
−
1
3
L₀
=
−
1
3
Step 2 · Find weight of node 1 (L₁)
Use L₁ = (x − x₀) × (x − x₂) ÷ ((x₁ − x₀) × (x₁ − x₂))
Node 1’s basis: the product is 0 at the other two nodes, and dividing by its value at node 1 makes it 1 there.
L₁
=
(3
−
1)
×
3 − 4
(2 − 1) × (2 − 4)
L₁
=
(3
−
1)
×
3 − 4
−2
L₁
=
2
×
−1
−2
L₁
=
−
2
−2
L₁
=
1
Step 3 · Find weight of node 2 (L₂)
Use L₂ = (x − x₀) × (x − x₁) ÷ ((x₂ − x₀) × (x₂ − x₁))
Node 2’s basis: the product is 0 at the other two nodes, and dividing by its value at node 2 makes it 1 there.
L₂
=
(3
−
1)
×
3 − 2
(4 − 1) × (4 − 2)
L₂
=
(3
−
1)
×
3 − 2
3 × 2
L₂
=
2
6
L₂
=
1
3
Step 4 · Find estimated value (y)
Use y = y₀ × L₀ + y₁ × L₁ + y₂ × L₂
Weight
each
node’s
y
by
its
Lagrange
basis
value
and
add:
the
quadratic’s
value
at
x
.
y
=
2
×
(−
1
3
)
+
3
×
1
+
11
×
1
3
y
=
−
2
3
+
3
+
3
2
3
y
=
6
Check
Put the numbers back in. Both sides should match.
−
1
3
=
(3
−
2)
×
3 − 4
(1 − 2) × (1 − 4)
✓
1
=
(3
−
1)
×
3 − 4
(2 − 1) × (2 − 4)
✓
1
3
=
(3
−
1)
×
3 − 2
(4 − 1) × (4 − 2)
✓
6
=
2
×
(−
1
3
)
+
3
×
1
+
11
×
1
3
✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.

More problem types

© 2026 SME. All rights reserved.