Numerical Differentiation and Integration: By: Habtamu Garoma
Numerical Differentiation and Integration: By: Habtamu Garoma
CHAPTER 6
Numerical Differentiation and Integration
u u 1 2 u u 1 u 2 3
y x y x0 uh y0 uy0 y0 y0 ... 1
2 3!
x x0
where y (x) is a polynomial of degree n in x and u
h
dy dy du 1 dy du 1
since
dx du dx h du dx h
1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
= y0 y0 y0 y0 ... ... 2
h 2 6 24
dy
This gives the value of at any x which may be any where in the
dx
interval.
dy dy 1 1 2 1 3 1 4
y y y y ...
h
0 0 0 0
dx x x0 dx u 0 2 3 4
d2y d dy du d dy 1
dx 2 du dx dx du dx h
1 2 6u 2 18u 11 4
y 0 u 1 3
y 0 y0 ...
h2 12
d3y 1 3 12u 18 4
y y ...
h3
0 0
dx 3 12
Setting x x 0 , i.e. u 0
d2y 1 2 11 4
2
2
y 0 3
y 0 y0 ... and
dx h 12
d3y 1 3 3 4
3
3 y 0 y 0 ...
dx h 2
v v 1 2 v v 1 v 2 3
y x y x n vh y n vyn yn y n ... ...
2 3!
v xn
where v
h
dy dy dv 1 dy
dx dv dx h dv
By: Habtamu Garoma 9/8/21
Cont’d
6
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
d2y 1 2 6v 2 18v 11 4
y n v 1 3
y n y n ...
dx 2 h 2 24
d3y 1 3 12v 18 4
y n 12 y n ...
dx 3 h 3
Setting x x n
dy 1 1 1 1
yn 2 yn 3 yn 4 yn ...
dx x xn h 2 3 4
d2y 1 2 11
2
yn 3 yn 4 yn ...
dx 2 x xn
h 12
d3y 1 3 3
3
yn 4 yn ...
dx 3 x xn
h 2
minimum given the tabular values. Using any one of the methods
then using the concepts how to find maximum and minimum in calculus
dy 1 2u 1 2 3u 2 6u 2 3
y0 y0 y0 ...
dx h 2 6
dy 2u 1 2 3u 2 6u 2 3
0 y0 y0 y0 ... 0
dx 2 6
By: Habtamu Garoma 9/8/21
Example 1
9
and 1971.
x p p 2 p 3 p 4 p
1931 40.62
20.18
-1.03
1941 60.80 5.49
19.15
4.46 -4.47
1951 79.95 1.02
23.61
5.48
1961 103.56
29.09
1971 132.65
x 1931
1931 1931
x 0 1931 u 0
10
dp dp 1 1 1 1
( ) p0 2 p0 3 p0 4 p0 ...
dx x 1931 dx u 0 h 2 3 4
1 1 1 1
20.18 1. 03 5. 49 4. 47
10 2 3 4
2.36425
When x 1941
1941 1931
u 1
10
By: Habtamu Garoma 9/8/21
Cont’d
12
Putting u = 1, in
dp 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
p0 p0 p0 p0 ... and
dx h 2 6 24
dp 1 1 1 1
We get, 20.18 1.03 5.49 4.47
dx u 1 10 2 6 12
= 1.83775
1961 1971
So v 1
10
By: Habtamu Garoma 9/8/21
Cont’d
13
dp 1 2v 1 2 3v 2 6v 2 3
p n pn p n ...
dx v 1 h 2 6 v 1
1
1 1
29.09 5.48 1.02
1
4.47 = 2.65525
10 2 6 12
1971 1971
When x 1971 so v 0
10
dp 1 1 1 1
pn 2 pn 3 pn 4 pn ...
dx u 0 2 2 3 4
1 1 1 1
29.09 5.48 1.02 4.47 = 3.10525
10 2 3 4
t: 1 3 5 7 9
1 85.3
10.8
3 74.4 3.3
-7.5 -2.3
5 67.0 1.0 1.6
-6.5 -0.7
7 60.5 0.3
-6.2
9 54.3
d
Since represents the rate of cooling, we have
dt
t t0 t 1
u
2 2
d 1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
0 0 0 0 ...
dt 2 2 6 24
d 1 1 1 1
10.8 (3.3) 2.3 (1.6)
dt u 1 2 2 6 12
1
10.8 1.65 0.383333333 0.1333333333 = - 4.316666667
2
d 1
ii)
(1.25) 1
10.8 2 (3.3)
(0.8125
2.3 1.1875 (1.6)
dt u 1.25 2 2 6 24
= - 3.9671875
By: Habtamu Garoma 9/8/21
Example 3
17
value of y.
x: 0 2 3 4 7 9
x y f x 2 f x 3 f x 4 f x
0 4
11
2 26 7
1
32
3 58 11 0
54 1
4 112 16 0
118 1
7 466
22
228
9 922
By: Habtamu Garoma 9/8/21
Cont’d
19
By Newton’s divided difference formula
y f x f x0 x x0 f x0 , x1 x x0 x x1 f x0 , x1 , x2 ...
= x 2 x 3x 4
3 2
y ' ( x) 3x 2 4 x 3
y ' 6 3 6 4 6 3 135
2
3x 2 4 x 3 0
There is no value of x that satisfies this equation since the roots are
Consider f x dx .
b
This integral represents the area between y f (x) , the x –axis and the
Now suppose set of (n+ 1) paired values are given. First as we did in
p x dx
b
polynomial Pn (x) and obtain n which can approximate the value for
a
p x dx .
b
n
a
By: Habtamu Garoma 9/8/21
Cont’d
21
A general quadrature formula for equidistant spacing
(Newton-Cote’s formula)
formula as
u u 1 2 u u 1 u 2 3
y x y0 uy0 y0 y0 ...1
2! 3!
x x0
where u , h is the interval of differencing.
h
y (x) of Newton.
x x0 x x0
Since xn x0 nh and u un
h h
x 0 nh
f x dx f x dx
xn
Thus x0 x0
x 0 nh
Pn x dx where Pn (x) is interpolating polynomial of degree n.
x0
n u u 1 2 u u 1 u 2 3
y0 uy0 y0 y0 ...hdu
0
2! 3!
n u u 1 2 u 3 3u 2 2u 3
h y0 uy0 y0 y0 ...du
0
2! 3!
By: Habtamu Garoma 9/8/21
Cont’d
23
n
u u 3 2
u 4
u 3
u 2
u2 3 2 4
h uy0 y0 y0
2
y0 ...
3
2 2! 3!
0
n2 1 n3 n 2 2 1 n4 3 2 3
h ny0 y0 y0 n n y0 ...(2)
2 2 3 2 6 4
x 0 nh x0 h 1
f x dx f x dx h 1. y0 y0
x0 x0
2
1
h y0 y1 y0
2
h
y0 y1
2
By: Habtamu Garoma 9/8/21
Cont’d
25
x 0 nh
f x dx f x dx
xn
x0 x0
x 0 nh x0 2h x 0 nh
f x dx f x dx ... f x dx
x0 x0 h x 0 n 1 h
h
y0 y1 h y1 y2 ... h yn 1 yn
2 2 2
h
y0 yn 2 y1 y2 ... yn 1
2
Even though this method is very simple for calculation, the error in
this case is significant
By: Habtamu Garoma 9/8/21
Truncation error in Trapezoidal Rule
26
In the neighborhood of x x0 , we can expand y f (x ) by Taylor series in
y x y0 x x0 y '
x x0
2
y0'' ... 1
0
2!
x1
ydx y0 x x0 y0
x1 x x0 ''
2
y0 ...dx
'
x0 x0
2!
x x0 ' x x0 ''
x1
2 3
y0 x y0 y0 ...
2! 3! x0
y0 x1 x0 x1 x0
2
'
y
x1 x0
3
y0'' ...
0
2! 3!
h 2 ' h3 ''
hy0 y0 y0 ... (2)
2! 3!
By: Habtamu Garoma 9/8/21
Cont’d
27
If h is the equidistant length, then also
h
y0 y1 Area of the first trapezium = A0 say
x1
x0
ydx
2
y x1 y1 y0 x1 x0 y
' x1 x0
2
y0'' ...
0
2!
h 2 ''
y0 hy y0 ...
'
0
2!
h h h 2 ''
A0 y0 y1 y0 y0 hy0
'
y0 ...
2 2 2!
h2 ' h3 ''
hy0 y0 y0 ...
2 2.2!
By: Habtamu Garoma 9/8/21
Cont’d
28
x1 1 1
x0 ydx A0 h y 3! 2.2! ...
3 ''
0
1
h3 y0'' ...
2
1 3 ''
The error made in the first interval ( x0 , x1 ) is h y0 ...
2
1 3 ''
Similarly the error in the ith interval h yi 1
2
E
nh 3
12
M
where M max y 0'' , y1'' , y 2'' ,...
b a h2
M if the interval is (a, b) and h
ba
12 n
18 4
f x dx h 2 y0 4y0 2 y0 since other terms vanish
x2
x
23 2
1
h 2 y0 2 y1 y0 E 1 y0
2
3
1
h 2 y0 2 y1 2 y0 y2 2 y1 y0
3
1 4 1
h y2 y1 y0
3 3 3
h
y2 4 y1 y0
3
By: Habtamu Garoma 9/8/21
Cont’d
31
h h
f x dx y2 4 y3 y4 and f x dx yi 4 yi 1 yi 2
x4 xi 2
Similarly, x2 3 xi 3
h
f x dx y n2 4 y n1 y n
xn
xn 2 3
xn x2 x
f ( x) dx 4 f x dx ... f x dx
xn
x0
f ( x) dx
x0 x2 xn 2
h
y0 4 y1 y2 y2 4 y3 y4 ... yn 2 4 yn 1 yn
3
h
y0 yn 2 y2 y4 ... yn 2 4 y1 y3 ... yn 1
3
By: Habtamu Garoma 9/8/21
Simpson’s three-eighths Rule
32
x3 9 19 1 81
x0
f ( x)dx h 3 y0 y0 2 y0 27 9 3 y0
2 22 6 4
9 9 3
h 3 y0 y1 y0 E 1 y0 E 1 y0
2 3
2 4 8
9 9 9 3
h 3 y0 y1 y0 y2 2 y1 y0 y3 3 y2 3 y1 y0
2 2 4 8
3h
y3 3 y2 3 y1 y0
8
x0 nh x 3h x0 6 h x nh
f ( x)dx 0 f ( x)dx f x dx ... 0
f x dx
x0 x0 x 3h x0 ( n3) h
0
3h
y0 3 y1 3 y2 y3 y3 3 y4 3 y5 y6 ... yn 3 3 yn 2 3 yn 1 yn
8
3h
y0 yn 3 y1 y2 y4 y5 ... yn 2 yn 1 2 y3 y6 yn
8
multiple of 3.
obtain
y y0 x x0 y ' x x0
2
y ''
x x0 '''
3
y0 ... ...1
0 0
2! 3!
x x x x x x 2
x x 3
x0 x0
2 ydx 2 y0 dx
0 ' 0 ' ' 0 '''
y 0 y 0 y 0 ...
1! 2! 3!
y0 x y0 y0 y0 ..
21! 3! 4! x0
y0 x2 x0 x2 x0
2
y '
x2 x0 '' x2 x0
3
y
4
y0''' ...
0 0
2! 3! 4!
By: Habtamu Garoma 9/8/21
Cont’d
35
h
y0 4 y1 y 2 , by Simpson’s rule
x2
Now let A1 area x ydx
0 3
y1 y0 x1 x0 y0'
x1 x2 y '' ...
0
2!
4 2 5
2hy0 2h 2 y0' h3 y0'' h 4 y0''' h5 y0 4 ...
3 3 18
x2 4 5
ydx A1 h5 y0 4 ...
x0
15 18
h5 4
y0 ... Omitting the remaining terms involving h 6 and
90
higher powers of h .
By: Habtamu Garoma 9/8/21
Cont’d
37
h5 4
This means that the error made in x0 , x2 is y0 ...
90
h5 4
Similarly, the error made in x2 , x4 is y2 and so on.
90
nh5
E M where M is the maximum value of y0 4 , y2 4 ..., y2 4n 2
90
E
b a h4 M
180
7
Evaluate
1
x 2 dx by using
a) Trapezoidal rule
6
interval into 6 equal parts with h 1
6
x: 1 2 3 4 5 6 7
y: 1 4 9 16 25 36 49
a) By Trapezoidal rule
h
y1 y7 2 y2 y3 y4 y5 y6
7
1
x 2 dx
2
1
1 49 2 4 9 16 25 36 115
2
By: Habtamu Garoma 9/8/21
Cont’d
40
a) By Simpson’s one-third rule
1
y1 y7 2 y3 y5 ) 4( y2 y4 y6
7
1
x 2 dx
3
1
1 49 2 9 25 4 4 16 36
3
= 114
3
y1 y7 3 y2 y3 y5 y6 2 y4
7
So 1
x 2 dx
8
3
1 49 3 4 9 25 36 216
8
= 114
7
7 x3 1 1 342
x dx 73 114
2
1 3 1 3 3 3
By: Habtamu Garoma 9/8/21
Example 2
41
dx
h 0.2 , and hence
1
2. Evaluate 0 1 x 2 , using Trapezoidal rule with
obtain an approximate value of .
dx h
0 1 x 2 2 y0 y5 2 y1 y2 y3 y4
1
0. 2
1 0.5 2 0.961538461 0.862068965 0.735294117 0.6097566097
2
= 0.783731528
1 dx
0 1 x 2
1 1
tan x 0
4
0.783731528
4
3.134926112
3. From the table below, find the area bounded by the curve and
i) By Trapezoidal rule
0.01
f x dx 1.93 2.08 21.95 1.98 2.01 2.03 2.06
7.53
7.47 2
= 0.12035
0.01
f x dx 1.93 2.08 21.98 2.03 4 41.95 2.01 2.06
7.53
7.47 3
0.120366667
3(0.01)
f x dx 1.93 2.08 31.95 1.98 2.03 2.06 2 2.01
7.53
7.47 8
0.1203375
By: Habtamu Garoma 9/8/21
Example 4
46
1
4. Evaluate
0
e x dx by Simpson’s one-third rule correct to five decimal
places.
Since error E
b a h 4 M , where M = Max (e x ) in the range
180
1 4
h e
180
h 4e
10 6
180
1
180 10 6 4
h 0.090207886 0.1
e
1
e x dx
0
0.1
3
1 e 2 e0.2 e0.4 e0.6 e0.8 4 e0.1 e0.3 e0.5 e0.7 e0.9
1.718282782
1 1
0
e x dx e x e 1 1.718281828
0
1
Correct to five decimal places 0
e x dx 1.71828 which is the same as the
exact value.
t: 0 2 4 6 8 10 12
v: 4 6 16 34 60 94 136
ds dv
We know that v and a
dt dt
To get S
2
4 136 216 60 4 6 34 94
12
S 0
vdt
3
= 552 meters
dv
To find a, a first form the difference table
dt t 2
t v v 2v 3v
0 4
2
8
2 6 0
10
8
4 16
18 0
8
6 34
26 0
8 60 8
34
0
10 94
42 8
12 136
dv 1 1 1
v0 2v0 3v0
dt t 2 h 2 3
By: Habtamu Garoma 9/8/21
Cont’d
52
dv 1 1 2 1 3
v0 v0 v0 taking v0 = 6
dt t 2 h 2 3
1 1
10 8 3m / sec 2
2 2
THE END