CH-5, Math-5 - Lecture - Note
CH-5, Math-5 - Lecture - Note
5.1 Introduction
On many occasions we are given only a few discrete set of values. To study the behavior of the
function through those points a technique known as interpolation is introduced. Polynomial is a
function which is easy to handle. The method of finding a polynomial that fits a selected set of
points ( x , f ( x )) which behaves nearly the same way as the true function will be considered.
Example 5.1 : Find the polynomial of least degree which takes the values
x 1 1 2 5
f(x) 9 3 6 39
Solution: There are four set of values given. Let the approximated polynomial be
f ( x )≈a0 +a1 (x +1 )+a2 (x +1 )(x −1)+a 3 ( x +1)( x−1 )(x −2)
Using the values of x and f(x) in turn, we get
From x=−1 , f (−1 )=9 , we get
9=a0
=2 x 2 −3 x +4
5.3 Divided Differences
Interpolating polynomials can be expressed in a variety of forms, and among these the Newton
divided difference form is probably the convenient and efficient one.
x , x ,⋅⋅⋅, x n be
Let the values of f ( x ) corresponding to the arguments 0 1
f ( x 0 ), f ( x1 ),⋅⋅⋅, f (x n ) .
x
The first divided difference for arguments 0 and x 1 is defined by:
f ( x 1 )−f ( x 0 )
f [ x 0 , x 1 ]=
x 1 −x 0
x
The second divided difference for arguments 0 , x 1 and x 2 is defined as:
f [ x 1 , x 2 ]−f [ x 0 , x 1 ]
f [ x 0 , x 1 , x 2 ]=
x 2−x 0
Similarly higher divided differences are defined. The nth divided differences with (n+1)
f [ x 1 , x 2 ,⋯, x n ]−f [ x 0 , x 1 ,⋯, x n−1 ]
f [ x 0 , x 1 , x 3 ,⋯, x n ]=
arguments is defined by x n −x 0
Property 1: The divided differences are symmetric about their arguments i.e. does not depend
on the order of the arguments.
Property 2: The nth divided differences of a polynomial of degree n is constant
x: 1 1 2 3 4
f(x) : 7 1 8 29 68
(ii) The needed differences are enclosed by the double lined box.
By Newton’s divided difference formula, we get
f ( x )=−7+3( x+1)+2( x+1)( x−1 )+1( x +1 )(x −1)( x−2 )
and f (5)=−7+3(6 )+2(6 )(4 )+1(6 )(4 )(3 )
=−7 +18+48+ 72=131
(iii) Here f (1)f (2 )=(−1 )(8)=−8<0
Thus a root is in (1, 2).
From the table, we have
x f(x) 1DD
1 1
2 8 9
Thus the root is the solution of
f ( x )=−1+9 ( x−1)=0
Spring 2023-2024
or
x=1+ 19 ≈1. 111
(iv) The polynomial g( x ) can be written as
g( x )=f ( x )+b( x+1)( x−1)( x−2)( x−3 )( x−4 )
where b is a constant.
Taking x=5 , we have
g(5 )=f (5)+b (6 )( 4 )(3)(2 )(1)
or 203=131+ 144 b
203−131 72 1
b= = =
Hence 144 144 2
The required polynomial is
g( x )=f ( x )+ 12 ( x+1)( x−1 )( x−2)( x−3 )( x−4 )
p( x )=f ( x n )+f [ x n , x n−1 ]( x−x n )+f [ x n , xn−1 , x n−2 ]( x−x n )( x−x n−1 )+⋯
+f [ x n , x n−1 , x n−2 ,⋯, x 0 ]( x−x n )( x−x n−1 )⋯( x−x 0 )
and is called the Newton Backward Divided Difference formula.
Lagrange polynomial of degree one passing through two points ( x 0 , y 0 ) and ( x 1 , y 1 ) is written
as
x−x 1 x−x 0
L1 ( x )= y 0+ y
x 0 −x 1 x1 −x 0 1
Lagrange polynomial of degree two passing through three points ( x 0 , y 0 ) ,( x 1 , y 1 ) and ( x 2 , y 2 )
is written as
( x−x 1 )( x−x 2 ) ( x−x 0 )( x−x 2 ) ( x−x 0 )( x−x 1 )
L2 ( x )= y 0+ y1 + y
( x 0−x 1 )( x 0 −x 2 ) ( x 1−x 0 )( x 1 −x2 ) ( x 2−x 0 )( x 2−x 1 ) 2
Lagrange polynomial of degree three passing through four points ( x 0 , y 0 ) ,( x 1 , y 1 ) , ( x 2 , y 2 )
and ( x 3 , y 3 ) is written as
( x−x 1 )( x−x 2 )(x −x3 ) (x −x0 )( x−x 2 )( x−x 3 )
L3 (x )= y 0+ y
( x 0 −x1 )( x 0 −x 2 )( x 0 −x 3 ) (x 1 −x 0 )( x1 −x 2 )( x1 −x 3 ) 1
( x−x 0 )( x−x 1 )( x−x 3 ) (x− x0 )( x−x 1 )( x−x 2 )
+ y 2+ y
( x 2 −x 0 )( x 2 −x 1 )( x 2 −x 3 ) ( x 3 −x 0 )(x 3 −x 1 )( x3 −x 2 ) 3
Spring 2023-2024
Example 5.3
The following table gives the values of an empirical function f(x) for certain values of x.
x 0 1 2 3
f(x) 4 1 8 29
y 4 1 8 29
x 0 1 2 3
Then
( y+4 )( y−8)( y−29) ( y +4 )( y +1 )( y−29 ) ( y +4 )( y+1)( y−8)
x=0+1 +2 +3
(−1+4 )(−1−8 )(−1−29 ) (8+4 )(8+1 )(8−29 ) (29+4 )(29+1)(29−8)
When y=0 , then
( 4 )(−8 )(−29) (4 )(1 )(−29 ) (4 )(1)(−8 )
x=0+1 +2 +3
(3 )(−9 )(−30 ) (12 )(9)(−21 ) (33)(30 )(21)
=1 . 1457+0 .1023−0 . 0046
=1 . 2434
Spring 2023-2024
Exercise 5.4 The upward velocity of a rocket is given as a function of time below:
t (s) 10 15 20 22.5 30
v(t) (m/s) 227 363 517 603 903
i. Construct a divided-difference table for the above data.
ii. Determine the value of the velocity at t=17 seconds using two suitable points.
iii. Determine the value of the velocity at t=17 seconds using three suitable points.
iv. Find the polynomial which passes through all the points and find v (35).
v. Use Lagrange interpolating polynomial to estimate
a. the value of t for v ( t )=400 using two suitable points.
b. the value of t for v ( t )=400 using three suitable points.
vi. Write down MATLAB codes using “polyfit(x, y, n)” and “polyval(p, x)” for the
following.
a. Find the polynomial of least degree that incorporates all the values in the table. and
estimate the velocities corresponding to .t=17 , 25∧35 seconds.
b. Draw the figure showing fitted polynomial and the given points.
Solution:
i.
t v(t) v1[ ] v2[ ] v3[ ] v4[ ]
10 227
15 363 27.2
20 517 30.8 0.36
22.5 603 34.4 0.48 0.0096
30 903 40.0 0.56 0.0053 0.00021
ii. Note that 15<17< 20 and using the relevant part of the table
t v(t)
15 363
20 517 30.8
we have the linear polynomial v ( t )=363+30.8 ( t−15 ) .
And v ( 17 ) ≈ 363+30.8 ( 2 ) =424.6 .
15 363
20 517 30.8
22.5 603 34.4 0.48
The polynomial with 3 points is v ( t )=363+30.8 ( t−15 )+ 0.48 (t−15 )( t−20 ) .
And v ( 17 )=363+30.8 ( 2 ) +0.48 ( 2 ) (−3 )=421.72 .
v. For a given v we need to calculate the value of t, so consider the Lagrange polynomial in
reverse order.
v 363 517
a. With two points consider
t 15 20
( v −517 ) (v−363)
and the Lagrange polynomial is t=15 +20
(363−517) (517−363)
For v=400 ,
15(−117) 20(37) 2495
t= + = =16.2013 .
−154 154 154
25.0000 695.8000
30.0000 903.0000
1000
Velocity v(t)
>> pt=polyfit(t,v,4);
600
>> t1=linspace(5,35,500);
% generates 500 values
400
>> v1=polyval(pt,t1); %
calculates values of v
200
>> plot(t, v,'o',t1,v1);
>> title('Graph of v against t');
>> xlabel('Time (t)'); 0
5 10 15 20 25 30 35
>> ylabel('Velocity v(t)'); Time (t)
Spring 2023-2024
Exercise 5.1
t(s) 1 3 4 7
v(m/ 3 5 21 201
s)
i. Construct a divided-difference table for the above data.
ii. Find the polynomial of least degree that incorporates the values in the table.
iii. Find the acceleration at time t=6 s.
iv. Find the distance function when S ( 0 )=2.
x 4 5 7 9 11
f (x) 62 95 185 307 461
x -2 -1 0 3
i. Construct a f(x) 12 14 10 22 divided-difference table
for the above data.
ii. Find the polynomial of least degree that incorporates the values in the table and find f (8).
iii. Given g ( 8 )=1202 , find the polynomial g( x ) that also takes the values of the above table.
iv. Use Lagrange interpolation formula to find
a. a real root of f ( x )=0 using linear approximation.
b. a real root of f ( x )=0 using all the points.
v. Write down MATLAB codes using “polyfit(x, y, n)” and “polyval(p, x)” to plot the
figure showing fitted polynomial and the given points.
Spring 2023-2024