Chapter 5 - Approximation of Derivative and Integral
Chapter 5 - Approximation of Derivative and Integral
SoICT 2023
2
Content
1. Approximation of Derivative
2. Approximation of Integral
3
APPROXIMATION OF DERIVATIVE
4
Derivative Problem
• The first order Derivative :
f ( x + h) − f ( x)
f ( x ) = lim
'
h →0 h
• Geometric meaning:
• f’(x) is the slope
of tangent at point x f(x+h)
(solid – line) f(x)
• Approximation:
• h≠0
• f’(x) is the slope
x x+h
of secant (dashed – line)
5
Forward Difference Method (FD)
h≈ ε
7
FD: Example
8
Result
h Derivative Error
10-1 0.455901885410761 -0.044098114589239
10-2 0.495661575773687 -0.004338424226313
10-3 0.499566904000770 -0.000433095999230
10-4 0.499956697895820 -0.000043302104180
10-5 0.499995669867026 -0.000004330132974
10-6 0.499999566971887 -0.000000433028113
10-7 0.499999956993236 -0.000000043006764
10-8 0.499999996961265 -0.000000003038736
10-9 0.500000041370186 0.000000041370185
9
Backward Difference Method (BD)
11
CD: Error Analysis
• Truncation error:
1 '''
− f (ζ )h 2 , ζ ∈ [x − h, x + h ]
6
• CD method has accuracy order of 2;
• Error minimal when h = ε1/3
12
Compare error of: FD, BD, CD
h FD BD CC
10-1 ~10-2 ~10-2 ~10-4
10-2 ~10-3 ~10-3 ~10-6
10-3 ~10-4 ~10-4 ~10-8
10-4 ~10-5 ~10-5 ~10-10
10-5 ~10-6 ~10-6 ~10-12
10-6 ~10-7 ~10-7 ~10-11
10-7 ~10-8 ~10-8 ~10-10
10-8 ~10-9 ~10-9 ~10-9
10-9 ~10-8 ~10-8 ~10-8
13
Approximation of second order derivative
2! 3! 4! 5!
• From (1) and (2), we have the approximate formula
for 2nd order derivative
f ( x + h) − 2 f ( x) + f ( x − h)
f ( x) =
''
(3)
h2
• Truncation error:
• Minimum when h = ε1/4
1 ''''
− f (ζ )h 2 , ζ ∈ [x − h, x + h ]
12
14
Approximation of partial derivative
∂f ( x, y ) f ( x + h, y ) − f ( x − h, y )
=
∂x 2h
∂f ( x, y ) f ( x, y + h ) − f ( x, y − h )
=
∂y 2h
15
APPROXIMATION OF INTEGRAL
16
Integral Problem
• Integral formula: b
I = ∫ f ( x )dx,
a
f(x)
a b
17
Riemann Sum
∑
k =1
f ( c k ) ∆ x k = f ( c1 ) ∆ x1 + f ( c 2 ) ∆ x 2 + ... + f ( c n ) ∆ x n
18
Approximating Integral
∫ f ( x ) dx = lim
n→ ∞
∑
k =1
f ( ck ) ∆ xk ,
a
19
Properties of definite integrals
a
∫ a
f ( x ) dx = 0
b a
∫ a
f ( x ) dx = − ∫
b
f ( x ) dx
b b
∫C.f
a
( x ) dx = C . ∫ f ( x ) dx
a
b b b
∫(
a
f ( x ) + g ( x )) dx = ∫
a
f ( x ) dx + ∫
a
g ( x ) dx
b c b
∫ f ( x ) dx = ∫ f ( x ) dx + ∫ f ( x ) dx , c ∈ [a , b ]
a a c
20
Theorems
∫a
f ( x ) dx = F ( b ) − F ( a )
• Theorem 2 (Theorem about mean value): If f is
continuous on [a,b], there exists a number c in the
interval [a,b] such that :
b
1
f (c ) =
b−a ∫
a
f ( x ) dx
21
Newton-Cotes formula
22
Newton-Cotes formula
23
Newton-Cotes formula
24
Newton-Cotes formula
25
Trapezoidal rule
f (b) − f ( a )
p1 ( x ) = f (a ) + ( x − a)
b−a
b b b
f (b) − f ( a )
⇒ I = ∫ f ( x )dx ≈ ∫ p1 ( x )dx = ∫ f ( a ) + ( x − a ) dx
a a a
b−a
⇒I=
( f ( a ) + f (b) )
(b − a ) (1)
2
• (1) is called the Trapezoidal formula for approximating the
integral
26
Trapezoidal rule
b − a ''
− f (ζ )h 2 , h = b − a, ζ ∈ [a, b]
12
• Geometrical meaning:
fb
fa `
f(x)
a b
27
Trapezoidal rule: Extension
fb
fb
fa fa
f(x) f(x)
a b a b
28
Trapezoidal rule: Extension
30
Simpson 1/3 formula: Extension
b f ( x0 ) + 4 ∑ f (x ) + 2 ∑ f (x ) + f (x )
i j n
a
3n
x0 = a, xi = a + ih, i = 1,..., n, (1)
31
Simpson 3/8 formula
32
33