Lec02-3 Polynomial Interpolation

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Mauro Sebastián Innocente

PhD, MSc, MEng, FHEA

Autonomous Vehicles &


Artificial Intelligence Laboratory (AVAILab)
Mauro.S.Innocente@gmail.com
https://msinnocente.com/
https://availab.org/

AVAILab
Autonomous Vehicles &
Artificial Intelligence
Laboratory
• Introduction to Polynomial Interpolation
• Lagrange Polynomials

Polynomial Interpolation Mauro S. Innocente


2 | 11
• Introduction to Polynomial Interpolation
• Lagrange Polynomials

Polynomial Interpolation Mauro S. Innocente


3 | 11
𝑔 𝑥𝑖 = 𝑦𝑖 , 𝑖 = 0,1, . . . , 𝑛

𝑔 𝑥 = 𝑎0 + 𝑎1 ⋅ 𝑥 + 𝑎2 ⋅ 𝑥 2 +. . . +𝑎𝑛 ⋅ 𝑥 𝑛

Polynomial Interpolation Mauro S. Innocente


4 | 11
• Example
Given the pairs shown in the table, obtain the polynomial of lowest degree
that interpolates all points exactly.
xi yi
0 5
1 3
2 5
3 23

• Such a polynomial is given by the following expression:


𝑔(𝑥) = 𝑎0 + 𝑎1 ⋅ 𝑥 + 𝑎2 ⋅ 𝑥 2 + 𝑎3 ⋅ 𝑥 3

• Since g(xi) = yi, we have four coefficients and four data points
resulting in the following system of equations:
𝑎0 + 𝑎1 ⋅ 0 + 𝑎2 ⋅ 02 + 𝑎3 ⋅ 03 =5
𝑎0 + 𝑎1 ⋅ 1 + 𝑎2 ⋅ 12 + 𝑎3 ⋅ 13 =3
𝑎0 + 𝑎1 ⋅ 2 + 𝑎2 ⋅ 22 + 𝑎3 ⋅ 23 =5
𝑎0 + 𝑎1 ⋅ 3 + 𝑎2 ⋅ 32 + 𝑎3 ⋅ 33 = 23
Polynomial Interpolation Mauro S. Innocente
5 | 11
• Operating:

𝑎0 + 0 ⋅ 𝑎1 + 0 ⋅ 𝑎2 + 0 ⋅ 𝑎3 = 5
𝑎0 + 1 ⋅ 𝑎1 + 1 ⋅ 𝑎2 + 1 ⋅ 𝑎3 = 3
𝑎0 + 2 ⋅ 𝑎1 + 4 ⋅ 𝑎2 + 8 ⋅ 𝑎3 = 5
𝑎0 + 3 ⋅ 𝑎1 + 9 ⋅ 𝑎2 + 27 ⋅ 𝑎3 = 23

• In matrix form:
𝐀⋅𝐱=𝐛

1 0 0 0 5 𝑎0
1 1 1 1 3 𝑎1
𝐀= ; 𝐛= ; 𝐱= 𝑎2
1 2 4 8 5
1 3 9 27 23 𝑎3

Polynomial Interpolation Mauro S. Innocente


6 | 11
• Solving the system,
x y
𝑎0 = 5 0 5
𝑎1 = 0 1 3
𝐱= 2 5
𝑎2 = −4
𝑎3 = 2 3 23

• And therefore the polynomial function that


interpolates the four data points exactly is given by:

𝑔 𝑥 = 2 ⋅ 𝑥3 − 4 ⋅ 𝑥2 + 5

Polynomial Interpolation Mauro S. Innocente


7 | 11
• Introduction to Polynomial Interpolation
• Lagrange Polynomials

Polynomial Interpolation Mauro S. Innocente


8 | 11
𝑛

𝐿 𝑥 = ෍ 𝑦𝑖 ⋅ 𝑙𝑖 𝑥
𝑖=0
𝑥 − 𝑥𝑚 𝑥 − 𝑥0 𝑥 − 𝑥𝑖−1 𝑥 − 𝑥𝑖+1 𝑥 − 𝑥𝑛
𝑙𝑖 𝑥 = ෑ = ... ⋅ ... , 𝑖 = 0, . . . , 𝑛
𝑥𝑖 − 𝑥𝑚 𝑥𝑖 − 𝑥0 𝑥𝑖 − 𝑥𝑖−1 𝑥𝑖 − 𝑥𝑖+1 𝑥𝑖 − 𝑥𝑛
0≤𝑚≤𝑛
𝑚≠𝑖
1 when 𝑖 = 𝑗
𝑙𝑖 𝑥𝑗 = ቊ
0 when 𝑖 ≠ 𝑗

Polynomial Interpolation Mauro S. Innocente


9 | 11
xi yi
𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥 − 𝑥3 𝑥−1 ⋅ 𝑥−2 ⋅ 𝑥−3
𝑙0 (𝑥) = ⋅ ⋅ =−
0 5 𝑥0 − 𝑥1 𝑥0 − 𝑥2 𝑥0 − 𝑥3 6
1 3
2 5 𝑥 − 𝑥0 𝑥 − 𝑥2 𝑥 − 𝑥3 𝑥⋅ 𝑥−2 ⋅ 𝑥−3
3 23 𝑙1 (𝑥) = ⋅ ⋅ =
𝑥1 − 𝑥0 𝑥1 − 𝑥2 𝑥1 − 𝑥3 2

𝑥 − 𝑥0 𝑥 − 𝑥1 𝑥 − 𝑥3 𝑥⋅ 𝑥−1 ⋅ 𝑥−3
𝑙2 (𝑥) = ⋅ ⋅ =−
𝑥2 − 𝑥0 𝑥2 − 𝑥1 𝑥2 − 𝑥3 2

𝑥 − 𝑥0 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥⋅ 𝑥−1 ⋅ 𝑥−2
𝑙3 (𝑥) = ⋅ ⋅ =
𝑥3 − 𝑥0 𝑥3 − 𝑥1 𝑥3 − 𝑥2 6
3

𝐿(𝑥) = ෍ 𝑦𝑖 ⋅ 𝑙𝑖 (𝑥)
𝑖=0
Polynomial Interpolation Mauro S. Innocente
10 | 11
x y
0 5
5 1 3
𝐿(𝑥) = − ⋅ 𝑥 − 1 ⋅ 𝑥 − 2 ⋅ 𝑥 − 3 2 5
6 3 23
3
+ ⋅𝑥⋅ 𝑥−2 ⋅ 𝑥−3
2
5
− ⋅𝑥⋅ 𝑥−1 ⋅ 𝑥−3
2
23
+ ⋅𝑥⋅ 𝑥−1 ⋅ 𝑥−2
6

Polynomial Interpolation Mauro S. Innocente


11 | 11

You might also like