1
Numerical Analysis
Lecture 5
Interpolation
2
• Interpolation enables us to estimate the data points in between the
given data.
𝑦 = 𝑦1 +
𝑦2 − 𝑦1
𝑥2 − 𝑥1
× 𝑥 − 𝑥1
• Linear Interpolation Formula:
Lagrange Interpolation
3
• The Lagrange interpolation is a method used to approximate the
function of the line or curve that passes through a set of points.
• The degree of Lagrange interpolating polynomial is determined based
on the number of known points
degree = 𝑛 − 1
where n is the number of known points.
Linear Lagrange Interpolation
4
Given two points 𝑥1, 𝑦1 and 𝑥2, 𝑦2 ,
the linear Lagrange interpolating formula is given by:
𝑦 =
𝑥 − 𝑥2
𝑥1 − 𝑥2
𝑦1 +
𝑥 − 𝑥1
𝑥2 − 𝑥1
𝑦2
Linear Lagrange Interpolation
5
Example
Determine the value of y at x = 8 given some set of values (2,6), (5,9) by
using the Lagrange interpolation formula.
Solution
Since we have two known points (𝑛 = 2), then we will use the linear
Lagrange formula.
𝑦 =
(𝑥 − 𝑥2)
(𝑥1 − 𝑥2)
𝑦1 +
(𝑥 − 𝑥1)
(𝑥2 − 𝑥1)
𝑦2
Linear Lagrange Interpolation
6
𝑦 =
(𝑥 − 𝑥2)
(𝑥1 − 𝑥2)
𝑦1 +
(𝑥 − 𝑥1)
(𝑥2 − 𝑥1)
𝑦2
Given, 𝑥1 = 2, 𝑦1 = 6, 𝑥2 = 5, 𝑦2 = 9
The value of y at x = 8 will be:
𝑦 =
(8 − 5)
(2 − 5)
× 6 +
(8 − 2)
(5 − 2)
× 9 =
3
−3
× 6 +
6
3
× 9 = −6 + 18 = 12
Second degree Lagrange interpolation
7
Given three points 𝑥1, 𝑦1 , 𝑥2, 𝑦2 and 𝑥3, 𝑦3
the second degree Lagrange interpolating formula that approximates
the curve that passes through the three points is given by:
𝑦 =
𝑥 − 𝑥2 𝑥 − 𝑥3
𝑥1 − 𝑥2 𝑥1 − 𝑥3
𝑦1 +
𝑥 − 𝑥1 𝑥 − 𝑥3
𝑥2 − 𝑥1 𝑥2 − 𝑥3
𝑦2 +
𝑥 − 𝑥1 𝑥 − 𝑥2
𝑥3 − 𝑥1 𝑥3 − 𝑥2
𝑦3
Second degree Lagrange interpolation
8
Example
Given the three data points (2, 0.5), (2.75, 0.36), and (4, 0.25), find the
second Lagrange interpolating polynomial for f (3).
9

Lec

  • 1.
  • 2.
    Interpolation 2 • Interpolation enablesus to estimate the data points in between the given data. 𝑦 = 𝑦1 + 𝑦2 − 𝑦1 𝑥2 − 𝑥1 × 𝑥 − 𝑥1 • Linear Interpolation Formula:
  • 3.
    Lagrange Interpolation 3 • TheLagrange interpolation is a method used to approximate the function of the line or curve that passes through a set of points. • The degree of Lagrange interpolating polynomial is determined based on the number of known points degree = 𝑛 − 1 where n is the number of known points.
  • 4.
    Linear Lagrange Interpolation 4 Giventwo points 𝑥1, 𝑦1 and 𝑥2, 𝑦2 , the linear Lagrange interpolating formula is given by: 𝑦 = 𝑥 − 𝑥2 𝑥1 − 𝑥2 𝑦1 + 𝑥 − 𝑥1 𝑥2 − 𝑥1 𝑦2
  • 5.
    Linear Lagrange Interpolation 5 Example Determinethe value of y at x = 8 given some set of values (2,6), (5,9) by using the Lagrange interpolation formula. Solution Since we have two known points (𝑛 = 2), then we will use the linear Lagrange formula. 𝑦 = (𝑥 − 𝑥2) (𝑥1 − 𝑥2) 𝑦1 + (𝑥 − 𝑥1) (𝑥2 − 𝑥1) 𝑦2
  • 6.
    Linear Lagrange Interpolation 6 𝑦= (𝑥 − 𝑥2) (𝑥1 − 𝑥2) 𝑦1 + (𝑥 − 𝑥1) (𝑥2 − 𝑥1) 𝑦2 Given, 𝑥1 = 2, 𝑦1 = 6, 𝑥2 = 5, 𝑦2 = 9 The value of y at x = 8 will be: 𝑦 = (8 − 5) (2 − 5) × 6 + (8 − 2) (5 − 2) × 9 = 3 −3 × 6 + 6 3 × 9 = −6 + 18 = 12
  • 7.
    Second degree Lagrangeinterpolation 7 Given three points 𝑥1, 𝑦1 , 𝑥2, 𝑦2 and 𝑥3, 𝑦3 the second degree Lagrange interpolating formula that approximates the curve that passes through the three points is given by: 𝑦 = 𝑥 − 𝑥2 𝑥 − 𝑥3 𝑥1 − 𝑥2 𝑥1 − 𝑥3 𝑦1 + 𝑥 − 𝑥1 𝑥 − 𝑥3 𝑥2 − 𝑥1 𝑥2 − 𝑥3 𝑦2 + 𝑥 − 𝑥1 𝑥 − 𝑥2 𝑥3 − 𝑥1 𝑥3 − 𝑥2 𝑦3
  • 8.
    Second degree Lagrangeinterpolation 8 Example Given the three data points (2, 0.5), (2.75, 0.36), and (4, 0.25), find the second Lagrange interpolating polynomial for f (3).
  • 9.