3.1. Numerical Integration and Differentiation
3.1. Numerical Integration and Differentiation
CHAPTER 3
NUMERICAL INTEGRATION
AND DIFFERENTIATION
OUTLINE
3.1 Numerical Integration
3.2 Numerical Differentiation
f n ( x) = a0 + a1 x + a2 x 2 + ... + an x n
where:
f (b) - f (a )
f1 ( x) = f (a ) + ( x - a)
b-a
Then:
bé f (b) - f (a ) ù f (b) + f (a )
I » ò ê f (a ) + ( x - a ) ú = (b - a )
a
ë b-a û 2
f (a ) = f (0) = 0.2
f (b) = f (2) = 50.2
f (b) + f (a ) 0, 2 + 50
I = (b - a ) = (2 - 0) = 50.4
2 2
Because 𝑓(𝑥) is a linear function, using the trapezoidal rule gets the
exact solution.
7
f ( x0 ) + 2å i =1 f ( xi ) + f ( xn )
n -1
I » (b - a )
2n
Error:
(b - a )3
Ea = - 2
f "( x)
12n
9
f "( x) =
ò 0
6dx
=6
2-0
(2 - 0)3
Ea = - 2
6 = -1
12.2
The exact solution is 59.4 − 1 = 58.4
x y 0.1
I= {[ f (0) + f (0.6) + 4[ f (0.1) + f (0.3) + f (0.5)]
0 𝑓(0) = 1 3
+ 2[ f (0.2) + f (0.4)]} = 0.470
0,1 𝑓(1) = 0.909
0,2 𝑓(2) = 0.833 0, 65
Ea = - 8.47 = -0.000003
0,3 𝑓(3) = 0.769 180 ´ 6 4
p /2
ò (6 + 3cos x)dx
0
Problem 1.
Solution:
a) Multiple-application trapezoidal rule.
𝜋
2 −0
ℎ= = 𝜋/8
4
𝑥( = 0; 𝑥) = 𝜋/8; 𝑥$ = 𝜋/4; 𝑥% = 3𝜋/8; 𝑥" = 𝜋/2
Problem 1.
Solution:
b) Multiple-application Simpson’s rule.
𝜋
2 −0
ℎ= = 𝜋/8
4
𝑥" = 0; 𝑥# = 𝜋/8; 𝑥! = 𝜋/4; 𝑥$ = 3𝜋/8; 𝑥% = 𝜋/2
Problem 1.
Solution:
c) Determine the percent relative error.
p /2 p /2 p /2
= 3p + 3 » 12.42478
Multiple-application trapezoidal rule:
12.386 - 12.42478
eT = 100% = -0.312%
12.42478
12.4252 - 12.42478
eT = 100% = 0.003%
12.42478
18
=> Using centered finite divided difference and small step size
achieves lower approximation error
22
f ( xi + 2 ) - 2 f ( xi +1 ) + f ( xi )
f "( xi ) »
h2
The second backward finite divided difference is
f ( xi ) - 2 f ( xi -1 ) + f ( xi - 2 )
f "( xi ) »
h2
The second centered finite divided difference is
f ( xi +1 ) - 2 f ( xi ) + f ( xi -1 )
f "( xi ) »
h2 23
Solution:
Time, t, s 0 2 4 6 8 10 12 14 16
Position, x, m 0 0.7 1.8 3.4 5.1 6.3 7.3 8.0 8.4
25
Solution:
• Velocity: f ( xi +1 ) - f ( xi -1 )
f '( xi ) =
2h
f ( x6 ) - f ( x4 )
f '( x5 ) =
2h
f (12) - f (8) 7.3 - 5.1
f '(10) = = = 0.55(m / s )
2´ 2 2´ 2
• Acceleration:
f ( xi +1 ) - 2 f ( xi ) + f ( xi -1 )
f "( xi ) =
h2
f ( x6 ) - 2 f ( x5 ) + f ( x4 )
f "( x5 ) =
h2
f (12) - 2 f (10) + f (8) 7.3 - 2 ´ 6.3 + 5.1
f "(10) = 2
= 2
= -0.05( m / s 2
)
2 2 26
Result:
𝑦 * 1 = −0,17824017
𝑦"(1) = 0,3573462
27