Week08&09 - Numerical Integration & Differentiation PDF
Week08&09 - Numerical Integration & Differentiation PDF
Week08&09 - Numerical Integration & Differentiation PDF
Numerical differentiation:
High accuracy differentiation formula
Richardson extrapolation
LESSON OUTCOMES
At the end of this topic, the students will be able:
To identify and apply the methods outlines
to integrate formulae and data set
To identify and apply the methods outlines to
differentiate formulae and data set
DIFFERENTIATION
Derivative represents the rate of change of a dependent
variable with respect to an independent variable given by
mathematical definition begin with a difference approximation:
y f ( xi x) f ( xi )
x
x
INTEGRATION
Integrate to bring together, as parts, into a whole; to unite; to
indicate the total amount.
Mathematical definition represented by
b
I f ( x) dx
a
which stands for the integral of the function f(x) with respect to the
independent variable x, evaluated between the limits x=a to x=b.
The integral is
equivalent to the
area under the curve
Application of a numerical
integration or quadrature
method
8
I f ( x)dx f n ( x)dx
where f n ( x) form of polynomial
f n ( x) a0 a1 x an 1 x n 1 an x n
9
(a) First-order
polynomial (straight
line) is used as an
approximation
(b) A parabola is
employed as an
approximation
The approximation of
an integral by the area
under three straightline segments
10
Open
forms
where
have
integration limits that extend
beyond the range of the data.
This formulas not generally used
for difinite integration.
However, they are utilized for
evaluating improper integrals and for
solution of ODE.
11
I f ( x)dx f1 ( x)dx
f (a) f (b)
I (b a)
2
12
I f ( x)dx f1 ( x)dx
f1 ( x) f ( x0 ) f ( x1 ) f ( x0 )
x x0
x1 x0
f1 ( x) f ( x0 )
f1 ( x) f (a )
f ( x1 ) f ( x0 )
( x x0 )
x1 x0
f (b) f (a )
( x a)
ba
f (b) f (a)
I f (a)
( x a) dx
ba
a
b
f (a) f (b)
I (b a)
2
Derivation:
Refer Box 21.1
(page 603) text book
13
I (b a) x average height
Average height = f(a) + f(b)
2
f (a) f (b)
I (b a)
2
14
12
15
16
ba
n
a x0
b xn
n segments equally
I
x1
x2
xn
x0
x1
xn1
f ( x0 ) f ( x1 )
f ( xn1 ) f ( xn )
f ( x1 ) f ( x2 )
I h
h
h
2
2
2
I
f
(
x
)
2
f
(
x
)
f
(
x
)
0
i
n
2
i 1
n 1
n 1
I (b a)
f ( x0 ) 2 f ( xi ) f ( xn )
i 1
2n
17
(b a ) 3 n
Et
f (x i )
3
12n i 1
f (x ) nf
i
(b a ) 3
Ea
f
2
12n
18
Example
Given f(x)=0.2+25x200x2+675x3900x4+400x5
Use following method to estimate the integral of given
equation from a = 0 to b = 0.8.
a) Single application of the Trapezoidal Rule
b) Multiple application of the Trapezoidal Rule (2 segments)
20
I f ( x)dx f 2 ( x)dx
a
a x0
b x2
( x x0 )( x x2 )
( x x0 )( x x1 )
I
f ( x0 )
f ( x1 )
f ( x2 )dx
( x0 x1 )( x0 x2 )
( x1 x0 )( x1 x2 )
( x2 x0 )( x2 x1 )
x0
h
ba ba
I f ( x0 ) 4 f ( x1 ) f ( x2 )
h
3
n
2
or
f ( x0 ) 4 f ( x1 ) f ( x2 )
I (b a )
6
(b a)
where a x 0 , b x 2 and x1 the point midway between a and b; x1
2
x2
Single segment application of Simpsons 1/3 rule has a truncation error of:
(b a)5 ( 4)
Et
f (x )
2880
a x b
I (b a)
f ( x0 ) 4 f ( xi ) 2
i 1, 3, 5
n2
f (x ) f (x )
j 2, 4, 6
3n
(b a)5 ( 4)
Ea
f
4
180 n
22
Example
Given f(x)=0.2+25x200x2+675x3900x4+400x5
I f ( x)dx f 3 ( x)dx
3h
I f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
8
f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
I b a
8
(b a ) 5 ( 4 )
Et
f (x )
6480
More accurate
(b a )
h
n
24
Example
Given f(x)=0.2+25x200x2+675x3900x4+400x5
Use following method to estimate the integral of given
equation from a = 0 to b = 0.8.
a) Simpsons 3/8 Rule
b) Use Simpsons 3/8 Rule in conjuction with Simpsons 1/3 Rule
to integrate the same function for five segments.
26
27
Example
Given data for f(x)=0.2+25x200x2+675x3900x4+400x5.
Given that the exact value of the integral that determined
analytically is 1.640533. Find true percent relative error.
x
f(x)
f(x)
0.0
0.200000
0.44
2.842985
0.12
1.309729
0.54
3.507297
0.22
1.305241
0.64
3.181929
0.32
1.743393
0.70
2.363000
0.36
2.074903
0.80
0.232000
0.40
2.456000
Numerical Differentiation
Forward finite divided difference
29
h O(h 2 )
h
2
So, first forward difference
(excluding second and higher derivative terms) :
f ( xi 1 ) f ( xi )
f ' ( xi )
O ( h)
h
30
O
(
h
)
Page 92 & 93
h2
into first forward difference to yield
f ( xi 1 ) f ( xi ) f ( xi 2 ) 2 f ( xi 1 ) f ( xi )
2
f ' ( xi )
O
(
h
)
2
h
2h
or, by collecting terms,
f ( xi 2 ) 4 f ( xi 1 ) 3 f ( xi )
f ' ( xi )
O(h 2 )
2h
* This equation incorporates more terms of Taylor
series expansion and more accurate.
31
Forward finite-divided difference formulas: two versions are presented for each
derivative. The latter version incorporates more terms of Taylor Series expansion
and consequently more accurate.
h4
32
33
Centered finite-divided difference formulas: two versions are presented for each
derivative. The latter version incorporates more terms of Taylor Series expansion
and consequently more accurate.
34
Example
Estimated the first derivative of
f(x) = 0.1x4 0.15x3 0.5x2 0.25x + 1.2
at x = 0.5 using finite divided differences and a step size of h = 0.25.
35
Solution
From calculatio n,
xi 2 0
xi 1 0.25
xi 0.5
xi 1 0.75
xi 2 1
f xi 2 1.2
f xi 1 1.1035
f xi 0.925
f xi 1 0.6363
f xi 2 0.2
Forward
O(h)
Backward
O(h)
Centered
O(h2)
Estimate
-1.155
-0.714
-0.934
t (%)
-26.5
21.7
-2.4
Forward
O(h2)
Backward
O(h2)
Centered
O(h4)
Estimate
-0.8594
-0.8781
-0.9125
t (%)
5.82
3.77
0
36
RICHARDSON EXTRAPOLATION
37
Example
Estimated the first derivative of
f(x) = 0.1x4 0.15x3 0.5x2 0.25x + 1.2
at x = 0.5 employing step sizes of h1 = 0.5 and h2 = 0.25.
Compute an improved estimate with Richardson extrapolation.
The true value is -0.9125.
Solution
The first derivative estimates can be computed with centered
differences
f ( xi 1 ) f ( xi 1 ) 0.2 1.2
1.0
t 9.6%
2h
2(0.5)
f ( xi 1 ) f ( xi 1 ) 0.6363 1.1035
D(h2 0.25) f ' ( xi )
0.9344 t 2.4%
2h
2(0.25)
4
1
4
1
D D(h2 ) D(h1 ) (0.9344) (1.0) 0.9125
t 0%
3
3
3
3
D(h1 0.5) f ' ( xi )
39