Professional Documents
Culture Documents
Numerical Integration: Joko Wintoko Matematika Teknik Kimia 2 JTK/FT/UGM/2011
Numerical Integration: Joko Wintoko Matematika Teknik Kimia 2 JTK/FT/UGM/2011
Joko Wintoko
Matematika Teknik Kimia 2
JTK/FT/UGM/2011
Numerical integration
• There are two main reasons to do numerical
integration:
– analytical integration may be impossible or infeasible,
or
– you may wish to integrate tabulated data rather than
known functions.
• Methods:
– Trapezoidal rule
– Simpson's rule
– Gauss quadrature
Manual method
f 2 ( x ) a0 a1 x a2 x 2
Basis of Simpson’s 1/3 Rulerd
b b
I f ( x )dx f 2 ( x )dx
a a
f 2 ( x ) a0 a1 x a2 x 2
f(x)
f2(x)
Basis of Simpson’s 1/3 Rule rd
Choose
a b a b
( a , f ( a )), ,f , and ( b , f ( b ))
2 2
as the three points of the function to evaluate a0, a1 and a2.
f ( a ) f 2 ( a ) a 0 a1 a a 2 a 2
2
a b a b a b a b
f f2 a 0 a1 a2
2 2 2 2
f ( b ) f 2 ( b ) a 0 a1b a 2 b 2
Basis of Simpson’s 1/3 Rule rd
2 a b 2
a f ( b ) abf ( b ) 4abf abf ( a ) b f ( a )
a0 2
a 2 2ab b 2
a b a b
af ( a ) 4af 3af ( b ) 3bf ( a ) 4bf bf ( b )
a1 2 2
a 2 2ab b 2
a b
2 f ( a ) 2 f f ( b )
2
a2
a 2 2ab b 2
Basis of Simpson’s 1/3 Rule
rd
Then b
If2(x)dx
a
a 2 dx
b
2
a
x
0 1ax
a
3b
x 2
x
ax
0
a1 a
2
2 3
a
22 33
bab a
a
0(
b
a
)a
1
a2
2 3
Basis of Simpson’s 1/3 Rule rd
b
ba a b
f 2 ( x )dx f(a) 4 f f ( b )
a 6 2
• Gaussian Quadratures
– select functional values at non-uniformly distributed
points to achieve higher accuracy
– change of variables so that the interval of integration
is [-1,1]
– Gauss-Legendre formulae
Gaussian Quadratures
f ( x )dx c i f ( x i ) c 1 f ( x 1 ) c 2 f ( x 2 ) c n f ( x n )
1
i 1
1
n2: 1
f(x)dx
c 1 f(x 1 ) c 2 f(x 2 )
-1 x1 x2 1
• Choose (c1, c2, x1, x2) such that the method
yields “exact integral” for f(x) = x0, x1, x2, x3
Gaussian Quadrature on [-1, 1]
1
n2:
1
f(x)dx c 1 f(x 1 ) c 2 f(x 2 )
Exact integral for f = x0, x1, x2, x3
– Four equations for four unknowns
f 1
1 1dx 2 c 1 c 2 c 1 1
1
c 1
1
2
f x xdx 0 c 1 x 1 c 2 x 2 1
1
12 x1
f x x dx c 1 x 12 c 2 x 22
2 2
3
1 3 1
f 1
x x 3 dx 0 c 1 x 13 c 2 x 23
3 x2 3
1
1 1 1
I f ( x )dx f ( ) f ( )
1
3 3
Gaussian Quadrature on [-1, 1]
1
n3:
1
f ( x )dx c 1 f ( x 1 ) c 2 f ( x 2 ) c 3 f ( x 3 )
-1 x1 x2 x3 1
• Choose (c1, c2, c3, x1, x2, x3) such that
the method yields “exact integral” for
f(x) = x0, x1, x2, x3,x4, x5
Gaussian Quadrature on [-1, 1]
1
f 1 x 0 dx 2 c1 c2 c3
1
1
f x xdx 0 c1 x1 c2 x2 c3 x3
1 c1 5 / 9
1 c 8 / 9
2 2
f x x dx c1 x12 c2 x22 c3 x32
2 2
1
3 c3 5 / 9
x1 3 / 5
1
f x 3 x 3 dx 0 c1 x13 c2 x23 c3 x33
1
x2 0
1
2 x3 3 / 5
f x x dx c1 x14 c2 x24 c3 x34
4 4
1
5
1
f x 5 x 5 dx 0 c1 x15 c2 x25 c3 x35
1
Gaussian Quadrature on [-1, 1]
1 5 3 8 5 3
I f ( x )dx f ( ) f (0 ) f ( )
1 9 5 9 9 5
Gaussian Quadrature on [a, b]
Coordinate transformation from [a,b] to [-1,1]
ba ba
t x
2 2
x 1 t a
x 1 t b
a t1 t2 b
b 1 ba ba ba 1
a
f ( t )dt
1
f(
2
x
2
)(
2
)dx g ( x )dx
1
Example: Gaussian Quadrature
4
Evaluate I te 2 t dt 5216.926477
0
Coordinate transformation
ba ba
t x 2 x 2 ; dt 2dx
2 2
4 1 1
I te dt ( 4 x 4 )e
2t 4 x4
dx f ( x )dx
0 1 1
Two-point formula
4 4
1 1 1 4 4 4 4
I f ( x )dx f ( ) f ( ) (4 )e 3
(4 )e 3
1
3 3 3 3
9.167657324 3468.376279 3477.543936 ( 33.34%)
Example: Gaussian Quadrature
Three-point formula
1 5 8 5
I f ( x )dx f ( 0.6 ) f ( 0 ) f ( 0.6 )
1 9 9 9
5 4 0.6 8 5
( 4 4 0.6 )e ( 4 )e ( 4 4 0.6 )e 4 0.6
4
9 9 9
5 8 5
( 2.221191545 ) ( 218.3926001 ) ( 8589.142689 )
9 9 9
4967.106689 ( 4.79%)
Four-point formula
I f ( x )dx 0.34785 f ( 0.861136 ) f ( 0.861136 )
1
1
0.652145 f ( 0.339981 ) f ( 0.339981 )
5197.54375 ( 0.37%)
Integration with unequal
segments
• Trapezoidal rule with unequal segments
Contoh
• Kerja yang dilakukan oleh sebuah proses termodinamis
dengan suhu tetap dapat dihitung dengan persamaan:
W pdV
dengan W = kerja, p = tekanan, dan V = volume.
Hitunglah kerja yang dilakukan dengan data sebagai
berikut:
Tekan 336 494.4 266.4 260.8 260.5 249.6 193.6 165.6
an,
kPa
Volum 0.5 2 3 4 6 8 10 11
e, m3
Memakai aturan trapezoidal
336 0.5
294.4 2 1.5 630.4 472.8
266.4 3 1 560.8 280.4
260.8 4 1 527.2 263.6
260.5 6 2 521.3 521.3
249.6 8 2 510.1 510.1
193.6 10 2 443.2 443.2
165.6 11 1 359.2 179.6
I 2671
Memakai aturan trapezoidal
• Jadi kerja yang dilakukan adalah 2671 kJ
Memakai aturan Simpson 1/3
Faktor utk
P
V P DV (Simpson'
Faktor * P Pi+1 + Pi Ii Metode
s rule)
0.5 336
Trapz
2 294.4 1.5 630.4 472.8
2 294.4 1 294.4
3 266.4 1 4 1065.6 540.2667 Simps
4 260.8 1 1 260.8
4 260.8 1 260.8
6 260.5 2 4 1042 1034.933 Simps
8 249.6 2 1 249.6
8 249.6
10 193.6 2 443.2 443.2 Trapz
11 165.6 1 359.2 179.6
I 2670.8
Memakai aturan Simpson 1/3
• Jadi kerja yang dilakukan adalah 2670,8
kJ