Interpolation
Interpolation
INTERPOLATION
𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ ⋯ ⋯ + 𝑎𝑛 𝑥 𝑛
For n+1 data points, there is one and only one polynomial of order n that passes
through all the points. For example, there is only one straight line (that is, a first-order
polynomial) that connects two points. Similarly, only one parabola connects
a set of three points.
Polynomial interpolation:
1. Newton’s divided-difference interpolating polynomial
2. Lagrange interpolating polynomial
x 𝑓1 𝑥 = 𝑏0 + 𝑏1 𝑥 − 𝑥0
x0 x x1
a0+a1x+a2x2
y2=f(x2)
• Given (x0, y0), (x1, y1) and (x2, y2)
y1=f(x1)
• A parabola passes from these
three points
y0=f(x0)
x
x0 x1 x2 Quadratic interpolation formula
𝑓2 𝑥 = 𝑏0 + 𝑏1 𝑥 − 𝑥0 + 𝑏2 𝑥 − 𝑥0 𝑥 − 𝑥1
𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ ⋯ ⋯ + 𝑎𝑛 𝑥 𝑛
Note that although this equation might seem to differ from the general
polynomial the two equations are equivalent.
𝑓2 𝑥 = 𝑏0 + 𝑏1 𝑥 − 𝑏1 𝑥0 + 𝑏2 𝑥 2 + 𝑏2 𝑥0 𝑥1 − 𝑏2 𝑥𝑥0 − 𝑏2 𝑥𝑥1
𝑎0 = 𝑏0 − 𝑏1 𝑥0 + 𝑏2 𝑥0 𝑥1
𝑎1 = 𝑏1 − 𝑏2 𝑥0 − 𝑏2 𝑥1
𝑎2 = 𝑏2
𝑓2 𝑥 = 𝑏0 + 𝑏1 𝑥 − 𝑥0 + 𝑏2 𝑥 − 𝑥0 𝑥 − 𝑥1
𝑓 𝑥1 − 𝑓 𝑥0
• at x = x1 ; f2 (x) = f2 (x1) = b0 + b1x1 𝑏1 =
𝑥1 − 𝑥0
𝑓 𝑥2 − 𝑓 𝑥1 𝑓 𝑥1 − 𝑓 𝑥0
−
𝑥2 − 𝑥1 𝑥1 − 𝑥0
𝑏2 =
𝑥2 − 𝑥0
𝑓𝑛 𝑥
= 𝑓 𝑥0 + 𝑥 − 𝑥0 𝑓 𝑥1 , 𝑥0 + 𝑥 − 𝑥0 𝑥 − 𝑥1 𝑓 𝑥2 , 𝑥1 , 𝑥0 + ⋯ ⋯ ⋯
+ 𝑥 − 𝑥0 𝑥 − 𝑥1 ⋯ ⋯ 𝑥 − 𝑥𝑛−1 𝑓 𝑥𝑛−1 , 𝑥𝑛 , ⋯ , 𝑥0
The near row that has smaller sequence number row is called as base raw.
Solution:
xi f(xi) f1 [ ] f2 [ ] f3 [ ] f4 [ ]
0 -5 6 2 1 0
1 1 12 6 1 0
3 25 30 11 1 base row
4 55 63 15
6 181 108
7 289
𝑓𝑛 𝑥
= 𝑓 𝑥0 + 𝑥 − 𝑥0 𝑓 𝑥1 , 𝑥0 + 𝑥 − 𝑥0 𝑥 − 𝑥1 𝑓 𝑥2 , 𝑥1 , 𝑥0 + ⋯ ⋯ ⋯
+ 𝑥 − 𝑥0 𝑥 − 𝑥1 ⋯ ⋯ 𝑥 − 𝑥𝑛−1 𝑓 𝑥𝑛−1 , 𝑥𝑛 , ⋯ , 𝑥0
𝑓 3.5 = 𝑓 3 + 𝑥 − 3 𝑓1 [ ] + 𝑥 − 3 𝑥 − 4 𝑓2 [ ] + 𝑥 − 3 𝑥 − 4 𝑥 − 6 𝑓3 [ ]
Solution:
x f(xi) f1 [ ] f2 [ ] f3 [ ]
1 4 6 1 0
2 10 10 1 0 base row
5 40 15 1 0
7 70 18 1
8 88 22
11 154
𝑓 4 = 𝑓 2 + 𝑥 − 2 𝑓1 [ ] + 𝑥 − 2 𝑥 − 5 𝑓2 [ ]
𝑓 4 = 10 + 4 − 2 × 10 + 4 − 2 4 − 5 × 1 → 𝑓 4 = 28
𝑓 𝑥1 − 𝑓 𝑥0 𝑓 𝑥1 − 𝑓 𝑥0
𝑓 𝑥1 , 𝑥0 = = → ∆𝑓0 = ∆𝑥. 𝑓 𝑥1 , 𝑥0
𝑥1 − 𝑥0 ∆𝑥
Similarly we can get ∆𝑓1 = ∆𝑥. 𝑓 𝑥2 , 𝑥1
∆𝑘 𝑓𝑖 = 𝑘! ∆𝑥 𝑘 𝑓 𝑥𝑖+𝑘 , ⋯ , 𝑥𝑖
∆𝑘 𝑓𝑖
𝑓 𝑥𝑖+𝑘 , ⋯ , 𝑥𝑖 = 𝑘
𝑘! ∆𝑥
i=0;
𝑛 𝑘−1
∆𝑘 𝑓0 ∆𝑘 𝑓0
𝑓 𝑥𝑘 , ⋯ , 𝑥0 , = 𝑓𝑛 𝑥 = ෑ 𝑥 − 𝑥𝑖
𝑘! ∆𝑥 𝑘 𝑘! ∆𝑥 𝑘
𝑘=0 𝑖=0
• For n=2 : 𝑓2 𝑥 =
𝑥 − 𝑥1 𝑥 − 𝑥2
𝑥0 − 𝑥1 𝑥0 − 𝑥2
𝑓 𝑥0 +
𝑥 − 𝑥0 𝑥 − 𝑥2
𝑥1 − 𝑥0 𝑥1 − 𝑥2
𝑓 𝑥1 +
𝑥 − 𝑥0 𝑥 − 𝑥1
𝑥2 − 𝑥0 𝑥2 − 𝑥1
𝑓 𝑥2
• To generalize, nth order polynomial is the summation of (n+1) nth order polynomials
Solution:
𝑛
𝑛 𝑥 − 𝑥𝑗
𝐿𝑖 𝑥 = ෑ
𝑓𝑛 𝑥 = 𝐿𝑖 𝑥 𝑓 𝑥𝑖 𝑥𝑖 − 𝑥𝑗
𝑗=0
𝑖=0 𝑗≠𝑖
𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥3 𝑥 − 𝑥4 𝑥 − 𝑥5
𝑓 𝑥0 𝐿0 𝑥 = 𝑓 𝑥0
𝑥0 − 𝑥1 𝑥0 − 𝑥2 𝑥0 − 𝑥3 𝑥0 − 𝑥4 𝑥0 − 𝑥5
𝑥 − 𝑥0 𝑥 − 𝑥2 𝑥 − 𝑥3 𝑥 − 𝑥4 𝑥 − 𝑥5
𝑓 𝑥1 𝐿1 𝑥 = 𝑓 𝑥1
𝑥1 − 𝑥0 𝑥1 − 𝑥2 𝑥1 − 𝑥3 𝑥1 − 𝑥4 𝑥1 − 𝑥5
Solution:
𝑥 − 𝑥0 𝑥 − 𝑥1 𝑥 − 𝑥3 𝑥 − 𝑥4 𝑥 − 𝑥5
𝑓 𝑥2 𝐿2 𝑥 = 𝑓 𝑥2
𝑥2 − 𝑥0 𝑥2 − 𝑥1 𝑥2 − 𝑥3 𝑥2 − 𝑥4 𝑥2 − 𝑥5
𝑥 − 𝑥0 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥4 𝑥 − 𝑥5
𝑓 𝑥3 𝐿3 𝑥 = 𝑓 𝑥3
𝑥3 − 𝑥0 𝑥3 − 𝑥1 𝑥3 − 𝑥2 𝑥3 − 𝑥4 𝑥3 − 𝑥5
𝑥 − 𝑥0 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥3 𝑥 − 𝑥5
𝑓 𝑥4 𝐿4 𝑥 = 𝑓 𝑥4
𝑥4 − 𝑥0 𝑥4 − 𝑥1 𝑥4 − 𝑥2 𝑥4 − 𝑥3 𝑥4 − 𝑥5
Solution:
𝑥 − 𝑥0 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥3 𝑥 − 𝑥4
𝑓 𝑥5 𝐿5 𝑥 = 𝑓 𝑥5
𝑥5 − 𝑥0 𝑥5 − 𝑥1 𝑥5 − 𝑥2 𝑥5 − 𝑥3 𝑥5 − 𝑥4