Professional Documents
Culture Documents
Chapter Five
Chapter Five
In chapter four, we were concerned with a general problem of interpolation, i.e., given a
set of values (x 0 , y0 ), (x1 , y1 ), … (x n, yn) of x and y, to find a polynomial Pn (x) of degree at
most n such that y(x) and Pn (x) agree at the set of tabulated points. In the present
chapter, we shall be concerned with driving formulas to compute:
dy d 2 y
(i) , , for any value x in [ x0 , xn ]
dx dx 2
xn y n xn
(ii) f ( x) dx , f ( x, y) dx dy
x0 y 0 x0
Numerical Differentiation
The general method for driving Numerical differentiation formulae is to differentiate
the interpolating polynomial.
dy 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
y 0 y0 y0 y0 (3)
du 2! 3! 4!
du 1
and (4)
dx h
By chain rule, we have
dy dy du 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
. y 0 y0 y0 y 0 (5)
dx du dx h 2! 3! 4!
dy
Expression (5) gives the value of at any x which may not be tabulated
dx
1
x−x0
In particular x = x 0 ⇒ u = =0
h
d2y 1 2 11 4
y 0 y 0 2 y 0
3
(8)
dx 2 x x0
h2
dy dy dv 1 2v 1 2 3v 2 6v 2 3 4v 3 18v 2 22v 6 4
. y n yn yn y n (11)
dx dv dx h 2 6 24
dy 1 1 1 1
y n 2 y n 3 y n 4 y n (12)
dx x xn h 2 3 4
d 2 y d dy dv 1 2 6u 6 3 12u 2 36u 22 4
. 2 y n yn y n (13)
dx 2
dv dx dx h 6 24
d2y 1 2 11 4
and y n y n 12 y n
3
(14)
dx 2 x xn
h2
2
Similarly higher derivatives may be obtained by successive differentiation.
Note: In a similar way different formulae can be derived by starting with other
interpolation formulae.
Example: Given the following function
X 1 3 5 7 9 11
Y -3 -9 25 147 405 847
dy d2y
Compute and for
dx dx 2
(a) x=1 (b) x=3 (c) x=11 (d) x=10
Solution: the difference table is
X y y 2 y 3 y 4 y
1 -3
-6
3 -9 40
34 48
5 25 88 0
122 48
7 147 136 0
258 48
9 405 184
442
11 847
(a) Since x= 1 is at the beginning of the table, use Newton’s forward formula.
Here x0 = 1, h = 2 & x = 1
dy 1 1 2 1 3 1 4
y 0 y 0 y 0 y 0
dx x x0 h 2 3 4
1 1 1
6 (40) (48) (0) 6 20 16 0 5 and
dy 1 1
dx x 1 2 2 3 4 2
d2y 1 2 11 4
y 0 y 0 2 y 0
3
dx 2 x x0
h2
d2y 11 1
40 48 2 (0) 4 40 48 0 2
1
2
dx x 1
22
3
(b) Again since x= 3 is near the beginning of the table, use Newton’s forward
formula. Here x0 =1 and x=3 u 1 .
dy 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
y 0 y0 y0 y 0
dx h 2! 3! 4!
dy dy 1 2 1 36 2 4 18 22 6
6 (40) (48) (0) 3 and
dx x 3 dx u 1 2 2! 3! 4!
(c) Since x= 11 is at the end of the table, use Newton’s backward difference formula.
Here xn = 11 and h = 2.
dy 1 1 1 1
y n 2 y n 3 y n 4 y n
dx x xn h 2 3 4
dy 1 1 1 1
442 (184) (48) (0) 275 and
dx x 11 2 2 3 4
d2y 1 2 11 4
y n y n 2 y n
3
dx 2 x xn
h2
d2y 1 11
184 48 2 (0) 58
dx 2 x 11
22
(d) Again since x=10 is near the end of the table , we use Newton’s back ward
difference formula. Here xn=11, h=2 and x=10 u 0.5 .
dy 1 2v 1 2 3v 2 6v 2 3 4v 3 18v 2 22v 6 4
y n yn yn y n
dx h 2 6 24
442 0 2 0 220
1
2
4
d2y 1 2 6u 6 3 12u 2 36u 22 4
and 2
2
y n y n y n
dx h 6 24
Numerical Integration
The primary purpose of numerical integration (also known as quadrature) is the
evaluation of integrals which are either impossible or else very difficult to evaluate
analytically. Numerical integration is also essential for the evaluation of integrals of
functions available only at discrete points. Such functions often arise in the numerical
solution of differential equations or from experimental data taken at discrete intervals.
Numerical integration or quadrature formulas can be developed by replacing f(x) by an
interpolating polynomial Pn (x) and integrating the polynomial to get an approximate
b b
Hence
b xn xn n
I f ( x) dx f ( x) dx h Pn ( x) dx h Pn (u ) du
a x0 x0 0
Each choice of the degree of the interpolating polynomial yields a different Newton-
Cotes formula.
(i) If n=1,
1
u2
x1 1 1
f ( x) dx h P1 (u ) du h y 0 uy 0 du h y 0 u y 0 y 0 y1
h
x0 0 0 2 0 2
5
(ii) If n=2,
u (u 1) 2
x2
2 2
f ( x) dx h P (u) du h y
x0 0
2
0
0 uy 0
2!
y 0 du
2
u2 2u 3 3u 2
y 0 4 y1 y 2
h
h y 0 u y 0 2 y 0
2 12 0 3
(iii) If n=3,
u (u 1) 2 u (u 1)(u 2) 3
X3
3 2
y 0 du y 0 3 y1 3 y 2 y 3
3h
x0
f ( x) dx h P3 (u ) du h y 0 uy 0
0 0
2!
y0
3! 8
1. Trapezoidal rule
b xn x1 x2 x3 xn
a
f ( x) dx
x0
f ( x) dx
x0
f ( x) dx f ( x) dx f ( x) dx
x1 x2
f ( x) dx
xn 1
h
y0 y1 h y1 y 2 h y 2 y3 h y n1 y n
2 2 2 2
y 0 2 y1 y 2 y n 1 y n
h
2
1
2. Simpson’s rule (Simpson’s rule)
3
b xn x2 x4 x6 xn
f ( x) dx f ( x) dx f ( x) dx f ( x) dx f ( x) dx f ( x) dx
a x0 x0 x2 x4 xn 2
h
y0 4 y1 y 2 h y 2 4 y3 y 4 h y 4 2 y5 y6 h y n2 4 y n1 y n
3 3 3 3
y 0 4 y1 y 3 y n 1 2 y2 y 4 y n 2 y n
h
3
3
3. Simpson’s rule
8
b xn x3 x6 x9 xn
f ( x) dx f ( x) dx f ( x) dx f ( x) dx f ( x) dx f ( x) dx
a x0 x0 x3 x6 xn 3
3h
y0 3 y1 3 y 2 y3 3h y3 3 y 4 3 y5 y6 3h y n3 3 y n2 3 y n1 y n
8 8 8
y 0 3 y1 y 2 y 4 y 5 y n 1 y n 2 2 y3 y 6 y 9 y n 3 y n
3h
8
6
1
x
Example: Evaluate 1 x dx with n 6 intervals by the trapezoidal rule
0
x ba 1 0 1
Solution: We have f ( x) , a 0, b 1 and n 6 h .
1 x n 6 6
X 0 1/6 1/3 1/2 2/3 5/6 1
f(x) 0 1/7 1/4 1/3 2/5 5/11 1/2
1 x dx 2 y 2 y1 y 2 y n 1 y n
x h
0
0
1 1 1 1 2 5 1
0 2 0.30512
12 7 4 3 5 11 2
0.6
e
x
dx
h
y 0 3 y1 y3 y5 2 y2 y4 y 6 0.82212
0
3
e
x
dx
3h
y 0 3 y1 y 2 y 4 y5 2 y3 y 6 0.82212
0
8