You are on page 1of 8

KIRINYAGA UNIVERSITY

DEPARTMENT OF PURE AND APPLIED SCIENCES

COURSE CODE : SPM2321

COURSE TITLE: NUMERICL ANALYSIS I

LECTURER: ANTHONY KINYANJUI

MODULE 04: LAGRANGE AND TAYLOR’S SERIES INTERPOLATIONS

OBJECTIVE:

AT THE END OF LECTURE, A STUDENT WILL BE ABLE TO CALCULATE


THE POLYNOMIAL EQUATIONS USING LINEAR, QUADRATIC AND
CUBIC LAGRANGE AND TAYLOR’S SERIES INTERPOLATIONS.

1
Lagrange Interpolation

Consider the function 𝑦 = 𝑓(𝑥) as x takes the values 𝑥0 , 𝑥1, 𝑥2 , … 𝑥𝑛 the


corresponding values of y :𝑦0 , 𝑦1 , 𝑦2 , … 𝑦𝑛 for a given table of values (𝑥𝑘 , 𝑦𝑘)
k=0,1,2,…n.

The process of estimating the value of y for any intermediate value of x is called
interpolation within the given range. The process of computing the value of y for a
given value of x that lies outside the table of x is called extrapolation.

Lagrange interpolation

(i) Linear interpolation


To generate a linear interpolation polynomial, we only require two data
points (𝑥0 , 𝑦0 ) (𝑥1 , 𝑦1 )

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

Find the linear Lagrange interpolation polynomial fitting the data points below,
and use it to evaluate the value of y at the stated points

(i)

X 2 3
Y 1 5

Y (2.5) and Y(11)

Solution
2
x0 = 2
y0 = 1
x1 = 3
y1 = 5

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

𝑥−3 𝑥−2
𝑦=( ) (1) + ( ) (5) .
2−3 3−2

𝑦 = 4𝑥 − 7 .

𝑦(2.5) = 4(2.5) − 7 = 3

𝑦(11) = 4(11) − 7 = 37
(ii)

X −3 −5
Y 2 3

𝑦(−3.5)𝑎𝑛𝑑 𝑦(−4)

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

𝑥+5 𝑥+3
𝑦=( ) (2) + ( ) (3) .
−3+5 −5+3

3
−𝑥+1
𝑦= .
2

1 1
𝑦(−3.5) = − (−3.5) + = 2.25
2 2

−1 1
𝑦(−4) = (−4) + = 2.5
2 2

(ii) Quadratic Lagrange interpolation polynomial


It is based on 3 data points(𝑥0 , 𝑦0 ) (𝑥1, 𝑦1 ) (𝑥2 , 𝑦2 ) and interpolating
polynomial is given by

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


𝑦= 𝑦 + 𝑦
(𝑥0 − 𝑥1 ) (𝑥𝑜 − 𝑥2 ) 0 (𝑥1 − 𝑥0 ) (𝑥1 − 𝑥2 ) 1
(𝑥−𝑥0 ) (𝑥−𝑥1 )
+ 𝑦
(𝑥2 − 𝑥0 ) (𝑥2 − 𝑥1 ) 2
(i) Generate a quadratic Lagrange interpolating polynomial and use it to
find the stated functional values

X 1 3 7
Y 2 5 1

𝑦(2)𝑎𝑛𝑑 𝑦(10)

𝑥 − 3) (𝑥 − 7) (𝑥 − 1)(𝑥 − 7)
𝑦= (2) + (5)
(1 − 3)(1 − 7) (3 − 1)(3 − 7)
(𝑥 − 1)(𝑥 − 3)
+ (1)
(7 − 1)(7 − 3)
4
−7𝑥 2 +76𝑥−21
𝑦=
24

−7(2)2 +76(2)−21
𝑦(2) = = 103/24
24

−7(10)2 +76(10)−21
𝑦(10) = =39/24
24

Generate a quadratic Lagrange interpolation polynomial and use it to find the


stated functional value

X 5 2 4
Y 1 2 0

𝑦(2)𝑎𝑛𝑑 𝑦(10)

(ii) Cubic Lagrange interpolating polynomial


It is based on four points(𝑥0 , 𝑦0 ) (𝑥1 , 𝑦1 ) (𝑥2 , 𝑦2 )(𝑥3 , 𝑦3 )

(𝑥−𝑥1 ) (𝑥−𝑥2 )(𝑥−𝑥3 )


𝑦= 𝑦
(𝑥0 − 𝑥1 ) (𝑥𝑜 − 𝑥2 )((𝑥𝑜 −𝑥3 ) 0
(𝑥−𝑥0 ) (𝑥−𝑥2 )(𝑥−𝑥3 )
+ 𝑦
(𝑥1 − 𝑥0 ) (𝑥1 − 𝑥2 ) (𝑥1 − 𝑥3 ) 1
(𝑥−𝑥0 ) (𝑥−𝑥1 )(𝑥−𝑥3 )
+ 𝑦
(𝑥2 − 𝑥0 ) (𝑥2 − 𝑥1 ) (𝑥2 − 𝑥3 ) 2
(𝑥−𝑥0 ) (𝑥−𝑥1 )(𝑥−𝑥2 )
+ 𝑦
(𝑥3 − 𝑥0 ) (𝑥3 − 𝑥1 ) (𝑥3 − 𝑥2 ) 3

5
Generate a cubic Lagrange interpolating polynomial and use it to find the stated
functional values.

X 2 1 7 4
Y 1 0 2 0

(𝑥 − 1)(𝑥 − 7)(𝑥 − 4) (𝑥 − 2)(𝑥 − 7)(𝑥 − 4)


𝑦= (1) + (0)
(2 − 1)(2 − 7)(2 − 4) (1 − 2)(1 − 7)(1 − 4)
(𝑥 − 2)(𝑥 − 1)(𝑥 − 4)
+ (2)
(7 − 2)(7 − 1)(7 − 4)
(𝑥 − 2)(𝑥 − 1)(𝑥 − 7)
+ (0)
(4 − 2)(4 − 1)(4 − 7)

or

(𝑥 − 1)(𝑥 − 7)(𝑥 − 4) (𝑥 − 2)(𝑥 − 1)(𝑥 − 4)


𝑦= (1) + (2)
(2 − 1)(2 − 7)(2 − 4) (7 − 2)(7 − 1)(7 − 4)

11𝑥 3 − 122𝑥 2 + 379𝑥 − 268


𝑦=
90

11(3)3 − 122(3)2 + 379(3) − 268


𝑦(3) = = 34/45
90

11(9)3 − 122(9)2 + 379(9) − 268 2


𝑦(9) = = 14
90 9

6
Taylor’s Series interpolation

If a polynomial p(x) is written as Taylor’s series interpolation the f(x) at a point 𝑥0


we have

(𝑥 − 𝑥0 )2 ′′
′(
(𝑥 − 𝑥0 )3 ′′ ′(𝑥0 )
𝑝(𝑥 ) = 𝑓(𝑥0 ) + (𝑥 − 𝑥0 )𝑓 𝑥0 ) + 𝑓 (𝑥0 ) + 𝑓
2! 3!
(𝑥 − 𝑥0 )𝑛 𝑛
+ 𝑓 (𝑥0 )
𝑛!

Is regarded as interpolate polynomial of degree nsatisfying the condition 𝑝𝑘 (𝑥0 ) =


𝑓 𝑘 (𝑥0 ) 𝑘 = 0,1 ,2, … 𝑛 where k represents the order of derivative

𝑝′ (𝑥0 ) = 𝑓 ′ (𝑥0 ),𝑝′′ (𝑥0 ) = 𝑓 ′′ (𝑥0 )

Solved problem

Obtain the Taylor’s series expansion about x=1 up to the second degree
1
function𝑓 (𝑥 ) = . Also find the error bound if the approximation is to be used
𝑥 2 +1

around [1,1.4]

Solution

x0 = 1 , f(x0) = f(1) = 1/2

2x
f ′ (x) = − f ′ (x0 ) = f ′ (1) = −1/2
(x2 +1)2

−2+6x2 ′
f ′′ (x) = f (x0 ) = f ′ (1) = 1/2
(x2 +1)3

(𝑥 − 𝑥0 )2 ′′
′(
(𝑥 − 𝑥0 )𝑛 𝑛
𝑃(𝑥 ) = 𝑓(𝑥0 ) + (𝑥 − 𝑥0 )𝑓 𝑥0 ) + 𝑓 (𝑥0 ) + 𝑓 (𝑥0 )
2! 𝑛!
1 (𝑥−1)2 1
𝑃 (𝑥 ) = 1/2 + (𝑥 − 1)(− ) + ( )
2 2! 2

7
1 1 (𝑥−1)2
𝑃 (𝑥 ) = − (𝑥 − 1) + +⋯
2 2 4

1 1 (0.5−1)2
𝑃 (0.5) = − (0.5 − 1) + = 0.8125
2 2 4

1 1
𝑃 (−0.5) = − (−0.5 − 1)+= 1.8125
2 2

(𝑥−1)3
𝑅2 ≤ 𝑀3 𝑤ℎ𝑒𝑟𝑒 𝑀3 = 𝑀𝑎𝑥1≤𝑥≤1.4⃒𝑓 ′′′ (𝑥)⃒
3!

24𝑥(1−𝑥 2 )
𝑓 ′′′ (𝑥 ) =
(1+𝑥 2 )4

24𝑥(1−𝑥 2 )
𝑀3 = 𝑀𝑎𝑥1≤𝑥≤1.4⃒ (1+𝑥 2 )4
⃒ = 2.016 𝑎𝑡 𝑥 = 1.4

(𝑥−1)3
The error bound is (2.016) = 0.336(𝑥 − 1)3
3!

Tutorial problem

1. Evaluate 𝑦(4.2111) using Lagrange interpolation for

X 4.1168 4.19236 4.20967 4.46908


Y 0.213631 0.21342 0.21441 0.218788

2. Given 𝑓 (𝑥 ) = 𝑒 −𝑥 , [0 ≤ 𝑥 ≤ 1] about 𝑥 = 0. Evaluate 𝑓 (3)𝑎𝑛𝑑 𝑓(9) and


find error bound.

You might also like