0% found this document useful (0 votes)
29 views

Lagrange Interpolation

This document discusses Lagrange interpolation, which is a method of polynomial interpolation that uses divided differences to generate polynomial interpolants. It provides examples of using Lagrange interpolation to find a polynomial that passes through given data points and to approximate values between points. The key aspects are that Lagrange interpolation finds the unique polynomial of the lowest possible degree that interpolates a given set of data points, and it can be used to interpolate values for any x between the initial x-values.

Uploaded by

Moaviya Akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Lagrange Interpolation

This document discusses Lagrange interpolation, which is a method of polynomial interpolation that uses divided differences to generate polynomial interpolants. It provides examples of using Lagrange interpolation to find a polynomial that passes through given data points and to approximate values between points. The key aspects are that Lagrange interpolation finds the unique polynomial of the lowest possible degree that interpolates a given set of data points, and it can be used to interpolate values for any x between the initial x-values.

Uploaded by

Moaviya Akram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Numerical Analysis

and Computation
(Interpolation)
Lagrange Interpolation

Lab Instructor: Miss Aqsa Afzal


Interpolation
Consider a function 𝑦 = 𝑓(𝑥) given by a Table of values (𝑥𝑘, 𝑦𝑘) where 𝑘 = 0,1,2, … 𝑛
As 𝑥 takes values 𝑥0, 𝑥1, 𝑥2, … , 𝑥𝑛 then the corresponding values of 𝑦 are 𝑦0, 𝑦1, 𝑦2, … , 𝑦𝑛
The process of estimating the values of 𝑦 for some 𝑥 in 𝑥0 < 𝑥 < 𝑥𝑛, not present in the
Table is called “interpolation”.

𝒙 𝒚
𝑥0 𝑦0
𝑥1 𝑦1
𝑥2 𝑦2
: :
: :
: :
𝑥𝑛 𝑦𝑛
For example, if 𝑥 denotes the number of days and 𝑦 denotes the height of some
plant at that day then we can find data of missing days using interpolation.

No of Day (𝑥) Height of plant (𝑦)


Day 1 2 cm
Day 2 2.5 cm
Day 3 3.5 cm
Day 5 5 cm
Day 7 6.5 cm
Day 8 6.8 cm
Day 9 7 cm
Polynomial Interpolation
Approximate the unknown function behind the data in the tabular form by a
polynomial 𝑃(𝑥) is called polynomial interpolation.
1) Newton’s Interpolation Formulas
I. Newton Forward difference Interpolation Formula
II. Newton Backward difference Interpolation Formula
III. Newton divided difference Interpolation Formula

2) Lagrange Interpolation
Lagrange Interpolation:
Given some list of abscissas and ordinates (𝑥𝑘, 𝑦𝑘) where 𝑘 = 0,1,2, … 𝑛 ,
We have to find polynomial 𝑃𝑁(𝑥) of degree N which passes through those
points.

If we are given only two points i.e. (𝑥0, 𝑦0) and (𝑥1, 𝑦1)
The maximum we can find is a line so
𝑃1(𝑥) = 𝑎0 + 𝑎1𝑥

If we are given only three points i.e. (𝑥0, 𝑦0), (𝑥1, 𝑦1) and (𝑥2, 𝑦2)
The maximum we can find is a line so
𝑃2(𝑥) = 𝑎0 + 𝑎1𝑥 + 𝑎2𝑥2

Similarly, in case of four given points


𝑃3(𝑥) = 𝑎0 + 𝑎1𝑥 + 𝑎2𝑥2 + 𝑎3𝑥3
• If we are given only two points i.e. (𝑥0, 𝑦0) and (𝑥1, 𝑦1)
The maximum we can find is a line which is polynomial of degree 1

To find 𝑃1(𝑥) using Lagrange interpolation

𝑃1(𝑥) = 𝐿0𝑦0 + 𝐿1𝑦1

(𝑥 − 𝑥1) (𝑥 − 𝑥0)
𝑃1 (𝑥) = 𝑦0 + 𝑦1
(𝑥0 − 𝑥1) (𝑥 1 − 𝑥 0)

• If we are given only three points i.e. (𝑥0, 𝑦0) , (𝑥1, 𝑦1) and (𝑥2, 𝑦2). The
maximum we can find is parabolic equation which is polynomial of degree 2

To find 𝑃2(𝑥) using Lagrange interpolation

𝑃2(𝑥) = 𝐿0𝑦0 + 𝐿1𝑦1 + 𝐿2𝑦2


(𝑥 − 𝑥1)(𝑥 − 𝑥2) (𝑥 − 𝑥0)(𝑥 − 𝑥2) (𝑥 − 𝑥0)(𝑥 − 𝑥1)
𝑃2 (𝑥) = 𝑦0 + 𝑦1 + 𝑦2
(𝑥0 − 𝑥1)(𝑥0 − 𝑥2) (𝑥1 − 𝑥0)(𝑥1 − 𝑥2) (𝑥2 − 𝑥0)(𝑥2 − 𝑥1)

In general

𝑃𝑁(𝑥) = 𝐿0𝑦0 + 𝐿1𝑦1 + 𝐿2𝑦2 + ⋯ + 𝐿𝑁𝑦𝑁

𝑃𝑁(𝑥) = ∑ 𝐿𝑗𝑦𝑗
𝑗=0
Question 1: Find the Lagrange polynomial that passes through (2,11), (4,10.5),
(7,7) hence manipulate the value of 𝑦 at 𝑥 = 5
Solution: First we write data in tabular form to make it easy to understand
𝑿 𝒀
𝑥0 = 2 𝑦0 = 11
𝑥1 = 4 𝑦1 = 10.5
𝑥2 = 7 𝑦2 = 7

Since we have 3 data points, so maximum we can find is polynomial of degree 2


𝑃2(𝑥) = 𝐿0𝑦0 + 𝐿1𝑦1 + 𝐿2𝑦2

(𝑥 − 𝑥1)(𝑥 − 𝑥2) (𝑥 − 𝑥0)(𝑥 − 𝑥2) (𝑥 − 𝑥0)(𝑥 − 𝑥1)


𝑃2(𝑥) = 𝑦0 + 𝑦1 + 𝑦2
(𝑥0 − 𝑥1)(𝑥0 − 𝑥2) (𝑥1 − 𝑥0)(𝑥1 − 𝑥2) (𝑥2 − 𝑥0)(𝑥2 − 𝑥1)
Put all the data points
(𝑥 − 4)(𝑥 − 7) (𝑥 − 2)(𝑥 − 7) (𝑥 − 2)(𝑥 − 4)
𝑃2(𝑥) = 11 + 10.5 + 7
(2 − 4)(2 − 7) (4 − 2)(4 − 7) (7 − 2)(7 − 4)
𝑃2(𝑥) = (1.1𝑥2 − 12.1𝑥 + 30.8) + (−1.75𝑥2 + 15.75𝑥 − 24.5) +
(0.4667𝑥2 − 2.8𝑥 + 3.7333)

L= 𝐿0𝑦0
𝐿1 𝑦 1
𝐿2 𝑦 2

1.1 −12.1 30.8


L= −1.75 15.75 −24.5
0.4667 −2.8 3.7333

𝑃2(𝑥) = (−0.1833𝑥2 + 0.85𝑥 + 10.0333)

𝑃2(5) = 9.7000
Question 2: Use appropriate Lagrange polynomial of degree one, two and three
to approximate the following:
𝑓(0.43) if 𝑓(0) = 1, 𝑓(0.25) = 1.64872 , 𝑓(0.5) = 2.71828 , 𝑓(0.75) =
4.48169
Solution:
Since we have 4 data points, so maximum we can find is polynomial of
degree ?
For 𝑃1: 𝑃1(𝑥) = 𝐿0𝑦0 + 𝐿1𝑦1

(𝑥 − 𝑥1) (𝑥 − 𝑥0)
𝑃1 (𝑥) = 𝑦0 + 𝑦
(𝑥0 − 𝑥1) (𝑥1 − 𝑥0) 1

So, which 2 data points should we consider from the given data.?
Since 0.43 lies between 0.25 and 0.5 so we should consider these two points.
𝑿 𝒀
𝑥0 = 0.25 𝑦0 = 1.64872
𝑥1 = 0.5 𝑦1 = 2.71828

Put all the data points in equation of 𝑃1

(𝑥 − 0.5) (𝑥 − 0.25)
𝑃1(𝑥) = 1.64872 + 2.71828
(0.25 − 0.5) (0.5 − 0.25)

Put the missing value to interpolate

(0.43 − 0.5) (0.43 − 0.25)


𝑃1(0.43) = 1.64872 + 2.71828
(0.25 − 0.5) (0.5 − 0.25)

𝑃1(0.43) = 2.4188
For 𝑃2: 𝑃2(𝑥) = 𝐿0𝑦0 + 𝐿1𝑦1 + 𝐿2𝑦2

(𝑥 − 𝑥1)(𝑥 − 𝑥2) (𝑥 − 𝑥0)(𝑥 − 𝑥2) (𝑥 − 𝑥0)(𝑥 − 𝑥1)


𝑃2(𝑥) = 𝑦0 + 𝑦1 + 𝑦2
(𝑥0 − 𝑥1)(𝑥0 − 𝑥2) (𝑥1 − 𝑥0)(𝑥1 − 𝑥2) (𝑥2 − 𝑥0)(𝑥2 − 𝑥1)

So, which 3 data points should we consider from the given data.?
Since 0.43 lies close to ending data. so we should consider these two points
skip first data point.

𝑿 𝒀
𝑥0 = 0.25 𝑦0 = 1.64872
𝑥1 = 0.5 𝑦1 = 2.71828
𝑥2 = 0.75 𝑦2 = 4.48169

Put all the data points in equation of 𝑃2


(𝑥 − 0.5)(𝑥 − 0.75) (𝑥 − 0.25)(𝑥 − 0.75)
𝑃2(𝑥) = 1.64872 + 2.71828
(0.25 − 0.5)(0.25 − 0.75) (0.5 − 0.25)(0.5 − 0.75)
(𝑥 − 0.25)(𝑥 − 0.5)
+ 4.48169
(0.75 − 0.25)(0.75 − 0.5)

Put the missing value to interpolate

(0.43 − 0.5)(0.43 − 0.75) (0.43 − 0.25)(0.43 − 0.75)


𝑃2(0.43) = 1.64872 + 2.71828
(0.25 − 0.5)(0.25 − 0.75) (0.5 − 0.25)(0.5 − 0.75)
(0.43 − 0.25)(0.43 − 0.5)
+ 4.48169
(0.75 − 0.25)(0.75 − 0.5)

𝑃2(0.43) = 2.3489
Concept of inverse Lagrange:
If 𝑦(1) = 4, 𝑦(3) = 12, 𝑦(4) = 19. Find 𝑥 when 𝑦(𝑥) = 7
There are two possibilities
1. Inverse the formula of langrage. Write all x as y’s and all y’s as x.
2. Switch the initial data. Write abscissas as ordinates and ordinates as abscissas
and use the same formula that we learned.

You might also like