Beruflich Dokumente
Kultur Dokumente
Syeilendra Pramuditya
Physics Program
Institut Teknologi Bandung
1
2
Numerical Integration
Definite integral dari f(t)
pada selang [a,b]
Metode analitik: anti-
derivatif
F dimana F’(t) = f(t)
Iab = F(b) – F(a)
b
F (t ) I ab f (t ) dt
a
3
Hand Calculation?
Calculate until 2 decimal numbers?
a = 88/17
b = square-root of 23
c = ln(7)
4
Numerical Integration
1
f (t )
t ln7 = ???
7
1 ln5 = ???
I ab dt ln 7 ln 5
5
t
1.2
1
ln(1.2) dt
1
t
b
I ab f (t )dt f (ti ) wi f ( a ) (b a )
a
8
Do The Code
Buatlah sebuah program yang menghitung
ln(x) menggunakan rectangular rule
Input: batas kiri, batas kanan, jumlah partisi
Output: hasil integrasi
Seberapa akurat hasilnya?
9
Midpoint Rule
b
ab
I ab f (t )dt f (ti ) wi f (b a )
a 2
10
Trapezoid Rule
b
f a f b
I ab f (t )dt f (ti ) wi (b a )
a
2
11
Simpson Rule
b
ba ab
I ab f (t )dt f (ti ) wi f (a ) 4 f f (b )
a
6 2
12
Practice
Hitung nilai numerik ln7.23 (untuk jumlah
partisi 5, 10, 25, 50)
rectangle rule
midpoint rule
trapezoid rule
Bandingkan hasil antara ketiga metode tsb
Bandingkan dengan hasil hitungan
kalkulator/komputer
13
More Complex Integral
7.6
I ab f (t )dt
3.2
ln( x)
f (t )
2
x 5
14
Monte Carlo Integration
b
f ( x)dx
a 1
b
b 1 N
f ( x) a
b
ba a
f ( x )dx f ( x) a
N
f (x )
i 1
i
dx
a
b
b ba N
f ( x)dx (b a) f ( x) a
N i 1
f ( xi )
a
15
Do The Code: Monte Carlo Integration
5.7
1
ln(5.7) dt 1.74
1
t
16
Do The Code: Monte Carlo Integration
1.950
5.7
1
ln(5.7) 1 t dt 1.74 1.900
1.850
Numerical Value
N ln(5.7) 1.800
10 1.669
20 1.914 1.750
40 1.622
80 1.872
1.700
160 1.819
320 1.690
1.650
640 1.693
1280 1.723
1.600
2560 1.739
1 10 100 1000 10000
N points
17
Do The Code: Monte Carlo Integration
5.7
1
ln(5.7) dt 1.74
1
t 2.200
2.100
N ln(5.7) ln(5.7) ln(5.7)
10 1.669 2.087 1.651
20 1.914 1.936 1.670 2.000
Numerical value
40 1.622 2.043 1.901
80 1.872 1.787 1.759 1.900
160 1.819 1.675 1.789
320 1.690 1.777 1.653
1.800
640 1.693 1.726 1.705
1280 1.723 1.751 1.712
2560 1.739 1.738 1.740 1.700
1.600
1.500
1 10 100 1000 10000
N points
18
Do The Code: Monte Carlo Integration
5.7
1
ln(5.7) dt 1.74
1
t
2.8
2.6 N=10
N=160
2.4 N=2560
2.2
1.8
1.6
1.4
1.2
1
0 20 40 60 80 100
19
Do The Code: Monte Carlo Integration
7.6
I ab f (t )dt
3.2
ln( x)
f (t )
2
x 5
20
Physics Problem
Pendulum
d 2 (t )
2 (t ) SHM
dt
g
2 f
l
1 l
How Easy! T
f
2
g
21
Physics Problem
Large Amplitude Pendulum..?
d g sin d
l
23
Large Amplitude Pendulum
24
Large Amplitude Pendulum
25
Large Amplitude Pendulum
Input
g, l, 0
Process
Evaluate the integral
Output
Period of the pendulum
Small Amplitude
1 l
T 2
f g
26
Do The Code
Benchmark your integrator code first