0% found this document useful (0 votes)
14 views14 pages

Lecture No. 10

apna smj k le lo

Uploaded by

Malik Zuraiz
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)
14 views14 pages

Lecture No. 10

apna smj k le lo

Uploaded by

Malik Zuraiz
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/ 14

Divided Differences

Let us assume that the function is known for several values of , for
. The divided differences of orders are now defined recursively as:
y[ x0 ]  y ( x0 )  y0
is the zero-th order divided difference
The first order divided difference is defined as
y  y0
y[ x0 , x1 ]  1
x1  x0
Similarly, the higher order divided differences are defined in terms of lower order divided
differences by the relations of the form
y[ x1 , x2 ]  y[ x0 , x1 ]
y[ x0 , x1 , x2 ] 
x2  x0
Generally,
1
y[ x0 , x1 ,K , xn ]   y[ x1 , x2 ,K , xn ]  y[ x0 , x1,K , xn1 ]
xn  x 0
Standard format of the Divided Differences

We can easily verify that the divided difference is a symmetric function of its arguments.
That is,
y0 y1
y[ x1 , x0 ]  y[ x0 , x1 ]  
x0  x1 x1  x0
y[ x1 , x2 ]  y[ x0 , x1 ]
y[ x0 , x1 , x2 ] 
Now x2  x0
1  y2  y1 y1  y0 
   
x2  x0  x2  x1 x1  x0 
Therefore
y0 y1 y2
y[ x0 , x1 , x2 ]   
( x0  x1 )( x0  x2 ) ( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 )
This is symmetric form, hence suggests the general result as
y0 y1 yk
y[ x0 ,K , xk ]   L 
( x0  x1 ) L ( x0  xk ) ( x1  x0 ) L ( x1  xk ) ( xk  x0 ) L ( xk  xk 1 )
OR
k
yi
y[ x0 ,..., xk ]   k
i 0  ( xi  x j )
i 0
i j

Example:
Construct the Newton’s divided difference table for values of and

Solution:

x F(x) 1st 2nd 3rd


difference difference difference
1 -3 15-3/3-
1=6
2 0 0-(-3)=3 33-15/4-2 9-6/4-1=1

=9
3 15 15-0=15 57-33/5-3 12-9/5-
2=1
=12
4 48 48-15=33 87-57/6-4 15-12/6-3

=15 =1
5 105 105-48=57
6 192 192-105=87 NEWTON’S
DIVIDED
DIFFERENCE INTERPOLATION FORMULA
Let be a function which takes values corresponding to
We choose an interpolating polynomial, interpolating at
in the following form
y  f ( x)  a0  a1 ( x  x0 )  a2 ( x  x0 )( x  x1 )
 L  an ( x  x0 )( x  x1 )L ( x  xn 1 )
Here, the coefficients are so chosen as to satisfy above equation by the pairs
Thus, we have
y ( x0 )  f ( x0 )  y0  a0 
y ( x1 )  f ( x1 )  y1  a0  a1 ( x1  x0 ) 

y ( x2 )  f ( x2 )  y2  a0  a1 ( x2  x0 )  a2 ( x2  x0 )( x2  x1 ) 
L 

yn  a0  a1 ( xn  x0 )  a2 ( xn  x0 )( xn  x1 )  L  an ( xn  x0 ) L ( xn  xn 1 ) 

The coefficients can be easily obtained from the above system of equations, as they
form a lower triangular matrix.
The first equation gives
a0  y ( x0 )  y0
The second equation gives
y1  y0
a1   y[ x0 , x1 ]
x1  x0
Third equation yields
y2  y0  ( x2  x0 ) y[ x0 , x1 ]
a2 
( x2  x0 )( x2  x1 )
Which can be rewritten as
  y1  y0  
 y2  y1    ( x1  x0 )   ( x2  x0 ) y[ x0 , x1 ]
 x1  x0 
a2   
( x2  x0 )( x2  x1 )
That is

y2  y1  y[ x0 , x1 ]( x1  x2 ) y[ x1 , x2 ]  y[ x0 , x1 ]
a2  
( x2  x0 )( x2  x1 ) x2  x0
Thus, in terms of second order divided differences, we have
a2  y[ x0 , x1 , x2 ]
Similarly, we can show that
Newton’s divided difference interpolation formula can be written as
y  f ( x)  y0  ( x  x0 ) y[ x0 , x1 ]  ( x  x0 )( x  x1 ) y[ x0 , x1 , x2 ]
 L  ( x  x0 )( x  x1 )K ( x  xn 1 ) y[ x0 , x1 ,..., xn ]
Newton’s divided differences can also be expressed in terms of forward, backward and central
differences. They can be easily derived.
Assuming equi-spaced values of abscissa, we have

y1  y0 y0
y[ x0 , x1 ]  
x1  x0 h
y1 y0

y[ x1 , x2 ]  y[ x0 , x1 ] h   y0
2
y[ x0 , x1 , x2 ]   h
x2  x0 2h 2!h 2
By induction, we can in general arrive at the result
 n y0
y[ x0 , x1 ,K , xn ] 
n !h n
Similarly,
y  y0 y1
y[ x0 , x1 ]  1 
x1  x0 h

y2 y1

y[ x1 , x2 ]  y[ x0 , x1 ] h h  2 y2
y[ x0 , x1 , x2 ]   
x2  x0 2h 2!h 2
In General,we have
 n yn
y[ x0 , x1 ,..., xn ] 
n !h n
Also, in terms of central differences, we have
X 0 1 4
y1  y0  y1/ 2
y[ x0 , x1 ]  
x1  x0 h
 y3/ 2  y1/ 2

y[ x1 , x2 ]  y[ x0 , x1 ] h h  2 y1
y[ x0 , x1 , x2 ]   
x2  x0 2h 2!h 2

In general, we have the following pattern

 2 m ym 
y[ x0 , x1 ,..., x2 m ]  2m 
(2m)! h 

 2 m 1
ym  (1/ 2) 
y[ x0 , x1 ,..., x2 m 1 ] 
(2m  1)!h 2 m 1 

Divided Differences

X Y 1st D.D 2nd D.D 3rd D.D


0 1
1 1 0
2 2 1 1/2 -1/2
4 5 3/2 1/6
Find the
interpolating polynomial by (i) Lagrange’s formula and (ii)Newton’s divided difference formula
for the given data and hence show that they represent the same interpolating polynomial.
Solution The divided difference table for the given data is constructed as follows

i) Lagrange’s interpolation formula gives

( x  1)( x  2)( x  4) ( x  0)( x  2)( x  4)


y  f ( x)  (1)  (1)
(1)(2)(4) (1  0)(1  2)(1  4)
( x  0)( x  1)( x  4) ( x  0)( x  1)( x  2)
 (2)  (5)
(2)(2  1)(2  4) 4(4  1)(4  2)
( x3  7 x 2  14 x  8) x3  6 x 2  8 x x3  5 x 2  4 x
  
8 3 2
5( x  3 x  2 x)
3 2

24
x 3x 2 2
3
   x 1
12 4 3
(ii) Newton’s divided difference formula gives
Y 2 1 4

1  1
y  f ( x )  1  ( x  0)(0)  ( x  0)( x  1)    ( x  0)( x  1)( x  2)   
2  12 
3 2
x 3x 2
   x 1
12 4 3
We observe that the interpolating polynomial by both Lagrange’s and Newton’s divided
difference formulae is one and the same.
Note!
Newton’s formula involves less number of arithmetic operations than that of Lagrange’s.
Example
Using Newton’s divided difference formula, find the quadratic equation for the following data.
Hence find y (2).

Solution:
The divided difference table for the given data is constructed as:
X Y 1st D.D 2nd D.D

0 2

1 1 -1 1/2

4 4 1

Now, using Newton’s divided difference formula, we have


1
y  2  ( x  0)(1)  ( x  0)( x  1)  
2
1
 ( x 2  3 x  4)
2
Hence, y (2) = 1.
Example
Find the equation of a cubic curve which passes through the points (4 , -43) , (7 , 83) , (9 , 327)
and (12 , 1053) using Dividing Difference Formula.
Solution
The Newton’s divided difference table is given by

X Y 1st divided 2nd divided 3rd


difference difference divided
difference
4 -43
7 83 42
9 327 122 16
12 1053 242 24 1
Example
A function y = f (x) is given at the sample points x = x , x and x . Show that the Newton’s
0 1 2
divided difference interpolation formula and the corresponding Lagrange’s interpolation formula
are identical.
Solution
For the function y = f (x), we have the data ( xi , yi ), i  0,1, 2.
The interpolation polynomial using Newton’ divided difference formula is given as
y  f ( x)  y0  ( x  x0 ) y[ x0 , x1 ]
( x  x0 )( x  x1 ) y[ x0 , x1 , x2 ]
Using the definition of divided differences, we can rewrite the equation in the form
(y  y )  y0
y  y0 ( x  x0 ) 1 0  ( x  x0 )( x  x1 ) 
( x1  x0 )  ( x0  x1 )( x0  x2 )
y1 y2 
  
( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 ) 
 ( x  x) ( x  x0 )( x  x1 ) 
 1  0   y0
 ( x0  x1 ) ( x0  x1 )( x0  x2 ) 
 ( x  x0 ) ( x  x0 )( x  x1 )  ( x  x0 )( x  x1 )
   y1  y2
 1 0
( x  x ) ( x1  x 0 )( x1  x2 
) ( x 2  x 0 )( x2  x1 )
On simplification, it reduces to
( x  x1 )( x  x2 ) ( x  x0 )( x  x2 ) ( x  x0 )( x  x1 )
y y0  y1  y2
( x0  x1 )( x0  x2 ) ( x1  x0 )( x1  x2 ) ( x2  x0 )( x2  x1 )
which is the Lagrange’s form of interpolation polynomial.
Hence two forms are identical.
Newton’s Divided Difference Formula with Error Term
Following the basic definition of divided differences, we have for any x
y ( x)  y0  ( x  x0 ) y[ x, x0 ] 
y[ x, x0 ]  y[ x0 , x1 ]  ( x  x1 ) y[ x, x0 , x1 ] 

y[ x, x0 , x1 ]  y[ x0 , x1 , x2 ]  ( x  x2 ) y[ x, x0 , x1 , x2 ] 


y[ x, x0 ,..., xn 1 ]  y[ x0 , x1 ,..., xn ]  ( x  xn ) y[ x, x0 ,..., xn ]
Multiplying the second Equation by (x – x ), third by (x – x )(x – x ) and so on,
0 0 1
and the last by

(x – x )(x – x ) … (x – x ) and adding the resulting equations, we obtain


0 1 n-1
y ( x)  y0  ( x  x0 ) y[ x0 , x1 ]  ( x  x0 )( x  x1 ) y[ x0 , x1 , x2 ] L
( x  x0 )( x  x1 )L ( x  xn 1 ) y[ x0 , x1 ,..., xn ]   ( x)
Where
 ( x)  ( x  x0 )( x  x1 )L ( x  xn ) y[ x, x0 ,..., xn ]
Please note that for x = x , x , …, x , the error term  ( x ) vanishes
0 1 n
Error Term in Interpolation Formula

Error Term in Interpolation Formulae


We know, if y (x) is approximated by a polynomial Pn (x) of degree n then the error is given by
 ( x)  y ( x)  Pn ( x),
Where
 ( x)  ( x  x0 )( x  x1 )L ( x  xn ) y[ x, x0 ,..., xn ]
Alternatively it is also expressed as
 ( x)  ( x) y[ x, x0 ,..., xn ]  K ( x)
Now, consider a function F (x), such that
F ( x)  y ( x)  Pn ( x)  K ( x)
Determine the constant K in such a way that F(x) vanishes for x = x0, x1, …, xn and also for an
arbitrarily chosen point x , which is different from the given (n + 1) points.

Let I denotes the closed interval spanned by the values x0 ,..., xn , x . Then F (x) vanishes (n + 2)
times in the interval I.
By Rolle’s theorem F ( x ) vanishes at least (n + 1) times in the interval I, F ( x) at least n
times, and so on.
Eventually, we can show that F ( n 1) ( x) vanishes at least once in the interval I, say at x  
Thus, we obtain
0  y( n1) ( )  Pn( n1) ( )  K ( n1) ( )
Since Pn(x) is a polynomial of degree n, its (n + 1)th derivative is zero. Also, from the definition
of  ( x)
( n1) ( x)  (n  1)!.
Therefore we get
y ( n 1) ( )
K
(n  1)!
Hence
y ( n 1) ( )
 ( x)  y ( x)  Pn ( x)  ( x )
(n  1)!

for some in the interval I.


Thus the error committed in replacing y (x) by either Newton’s divided difference formula or by
an identical Lagrange’s formula is
y ( n 1) ( )
 ( x)  ( x) y[ x, x0 ,..., xn ]  ( x)
(n  1)!

INTERPOLATION IN TWO DIMENSIONS


Let u be a polynomial function in two variables, say x and y, in particular quadratic in x and
cubic in y, which in general can be written as
u  f ( x, y )  a0  a1 x  a2 y  a3 x 2
 a4 xy  a5 y 2  a6 y 3  a7 y 2 x  a8 yx 2
 a9 y 3 x  a10 y 2 x 2  a11 y 3 x 2
This relation involves many terms. If we have to write a relation involving three or more
variables, even low degree polynomials give rise to long expressions. If necessary, we can
certainly write, but such complications can be avoided by handling each variable separately.
If we let x, a constant, say x = c, the equation simplifies to the form
u  xc  b0  b1 y  b2 y 2  b3 y 3
Now we adopt the following procedure to interpolate at a point (1, m) in a table of two variables,
by treating one variable a constant say x = x1. The problem reduces to that of a single variable
interpolation.
Any one of the methods discussed in preceding sections can then be applied to get
f (x , m). Then we repeat this procedure for various values of x say x = x , x , …, x keeping y
1 2 3 n
constant. Thus, we get a new table with y constant at the value y = m and with x varying. We can
then interpolate at x = 1.
Example
2 2
Tabulate the values of the function f (x) = x +y -y
for x = 0,1,2,3,4 and y = 0,1,2,3,4.
Using the table of the values, compute f(2.5, 3.5) by numerical double interpolation
Solution
The values of the function for the given values of the given values of x and y are given in the
following table

X ………. Y …………
0 1 2 3 4
0 0 0 2 6 12
1 1 1 3 7 13
2 4 4 6 10 16
3 9 9 11 15 21
4 16 16 18 22 28

X …….. Y ……..
0 1 2 3 4
0 0 0 2 6 12
1 1 1 3 7 13
2 4 4 6 10 16
3 9 9 11 15 21
4 16 16 18 22 28
Y f

Cont! Using quadratic interpolation in both x and y directions we need to consider three points in
x and y directions. To start with we have to treat one variable as constant, say x. Keeping x = 2.5,
y = 3.5 as near the center of the set, we choose the table of values corresponding to x = 1,2, 3 and
y = 2, 3, 4.
Cont! The region of fit for the construction of our interpolation polynomial is shown in different
color in the table
Cont ! Thus using Newton’s forward difference formula, we have

At x=1
Y f f 2 f

2 3
3 7 4 2
4 13 6

Cont ! Similarly

At x=2
Y f f 2 f
2 6
3 10 4 2
4 16 6

Cont !
Similarly

At x=3
Y f f 2 f

2 11
3 15 4 2
4 21 6

y  y0 3.5  2
with p   1.5
h 1
Cont !
y  y0 3.5  2
with p   1.5
h 1
p ( p  1) 2
f (1,3.5)  f 0  pf 0   f0
2!
(1.5)(0.5)
 3  (1.5)(4)  (2)  9.75
2
Cont !
(1.5)(0.5)
f (2,3.5)  6  (1.5)(4)  (2)  12.75
2
(1.5)(0.5)
f (3,3.5)  11  (1.5)(4)  (2)  17.75
2
Cont !
Therefore we arrive at the following result

At x=3.5
Y f f 2 f

1 9.75
2 12.75 3 2
3 17.75 5

Cont !
2.5  1
Now defining p  1.5
1
(1.5)(0.5)
f (2.5,3.5)  9.75  (1.5)(3)  (2)  15
2
Cont !

From the functional relation, we also find that


f (2.5,3.5)  (2.5) 2  (3.5) 2  3.5  15
And hence no error in interpolation!!!

DIFFERENTIATION USING DIFFERENCE OPERATORS


Introduction
Consider a function of single variable y = f (x). If the function is known and simple,
we can easily obtain its derivative (s) or can evaluate its definite integral
However, if we do not know the function as such or the function is complicated and is given in a
tabular form at a set of points x ,x ,…,x , we use only numerical methods for differentiation or
0 1 n
integration of the given function.
We shall discuss numerical approximation to derivatives of functions of two or more variables in
the lectures to follow when we shall talk about partial differential equations.
In what follows, we shall derive and illustrate various formulae for numerical differentiation of a
function of a single variable based on finite difference operators and interpolation.
Subsequently, we shall develop Newton-Cotes formulae and related trapezoidal rule and
Simpson’s rule for numerical integration of a function.
We assume that the function y = f (x) is given for the values of the independent variable x = x
0
+ ph, for p = 0, 1, 2, … and so on. To find the derivatives of such a tabular function, we proceed
as follows
Case I:
Using forward difference operator ∆ and combining equations

E f ( x)  f ( x  h)
and
  E 1

hD  log E  log(1  )
Remember the Differential operator, D is known to represents the property

d 
f ( x)  f ( x) 
Df ( x) 
dx 
2 
D f ( x)  2 f ( x)  f ( x) 
2 d "

dx 
This would mean that in terms of ∆ :

1  2 3  4 5 
D       L 
h 2 3 4 5 
Therefore
1  2 f ( x0 )  3 f ( x0 )
Df ( x0 )  f ( x0 )   f ( x0 )  
h 2 3
 4 f ( x0 )  5 f ( x0 )  d
  L   f ( x0 )
4 5  dx
in other words
1  2 y0 3 y0  4 y0 
Dy0  y0   y0    L 
h 2 3 4 

Also, we can easily verify


2
1   2 3  4 
D  2  
2
  L 
h  2 3 4 
1  11 5 
 2   2  3   4  5  L 
h  12 6 
  y0   y0
2 3

d 2 y0 1  
D y0 
2
 y0  2
h    4 y0   5 y0  L 
11 5
dx 2 
 12 6 

Case II:
Using backward difference operator , we have 
hD   log(1  )
On expansion, we have
1  2 3  4 
D      L 
h 2 3 4 

we can also verify that


2
1   2 3  4 
D  2  
2
  L 
h  2 3 4 
1  11 5 
 2   2  3   4  5  L 
h  12 6 
Hence
d
yn  Dyn  yn
dx
1  2 yn  3 yn  4 y n 
  yn    L 
h 2 3 4 
yn  D yn
2

and 
2 
1 11 5
  2 yn   3 yn   4 yn   5 yn  L 
h 12 6 
2
The formulae for Dy and D y are useful to calculate the first and second derivatives at the
0 0
beginning of the table of values in terms of forward differences; while formulae for y’ and y’’
n n
2
The formulae for Dy and D y are useful to calculate the first and second derivatives at the
0 0
beginning of the table of values in terms of forward differences; while formulae for y’ and y’’
n n
Case III: Using central difference operator δ and following the definitions of differential
operator D, central difference operator δ and the shift operator E, we have
  E1/ 2  E 1/ 2  ehD / 2  e hD / 2
hD
 2sinh
2
Therefore, we have
hD 
 sinh 1
2 2

But,
1 x 3 1 3 x 5
sinh 1 x  x  
2 3 2 4 5
1 3  5 x 7
 L
2 46 7
Using the last two equations we get
hD    3 3 
    5 L 
2  2 6  8 40  32 

That is,
1 1 3 3 5 
D      L 
h 24 640 
Therefore

d
y  y  Dy
dx
1 1 3 5 
  y   3 y   y L 
h 24 640 
Also
1  2 1 4 3 6 
D2  2 
     L 
h  12 90 
Hence
1  2 1 1 
y  D 2 y  2 
 y   4 y   6 y L 
h  12 90 
For calculating the second
derivative at an interior tabular
point, we use the equation

1  2 1 4 3 6 
D2  2 
     L 
h  12 90 
while for computing the firstderivative at an interior tabular point, we in general use another
convenient form for D, which is derived as follows. Multiply the right hand
side of
d 1 1 3 5 
y  y  Dy    y   3 y   y L 
dx h 24 640 
by

1  ( 2 4)
which is unity and noting the Binomial expansion

1 2
 1 2 1 2
1     1   
 4  8
3 4 15
   6 L
128 48  64
we get
 1 2 3 4 
D 1     L 
h 8 128 
 1 3 3 5 
     L 
 24 640 
On simplification, we obtain

 1 3 4 5 
D      L 
h 6 120 

Therefore the equation can also be written in another useful form as

 1 3 1 5 
y  D   y   y   y L 
h 6 30 
The last two equations for y” and y’ respectively are known as Stirling’s formulae for computing
the derivatives of a tabular function. Similar formulae can be derived for computing higher order
derivatives of a tabular function.
The equation for y’ can also be
written as
 12 (1) 2 (2) 2 5 (1) 2 (2) 2 (3) 2 7 
y   y   3 y   y  y L 
h 3! 5! 7! 
In order to illustrate the use of formulae derived so far, for computing the derivatives of a
tabulated function, we shall consider some examples in the next lecture.

You might also like