Anda di halaman 1dari 15

MODUL 04 - 2019

DIFERENSIASI NUMERIK
Anastasia Martha Kenek Udak
90218003
anastasiaudak27@gmail.com

Praktikum : 27 Februari 2019


Pengumpulan : 4 Maret 2019
Asisten : Muhammad Nashih Amien (10214011)
: Prian Jaya (10214015)
: Naufal Ismail K. (10214051)
: Rifqi Alfi Muhani (10214068)

Abstrak
Praktikum ini bertujuan untuk menggunakan metode forward differerence, backward difference,
central difference, dan five point stencil untuk diferensiasi numerik pada pemrograman VBA Excel.
Metode dalam praktikum ini menggunakan pemrograman VBA Excel dengan menjalankan source code
yang telah dibuat di bagian visual basic. Hasil yang diperoleh adalah nilai perhitungan diferensiasi
numerik dari persamaan yang diberikan dan kesalahan relatif (galat). Hasil praktikum menunjukkan
bahwa keempat metode dapat digunakan untuk menyelesaikan diferensiasi numerik dari suatu
persamaan pada pemrograman VBA Excel dengan metode five point stencil adalah yang paling valid
dan teliti karena memiliki nilai galat yang paling kecil. Selain itu, untuk bisa menghasilkan nilai
perhitungan dengan galat yang lebih kecil maka pengguna harus memperkecil nilai h.
Kata kunci: Backward Difference, Central Difference, Forward Difference, Five Point Stencil.

1. TUJUAN
a. Menggunakan metode forward differerence, backward difference, central difference, dan five
point stencil untuk diferensiasi numerik pada pemrograman VBA Excel.

2. DASAR TEORI
Diferensiasi suatu fungsi y = f(x) didefenisikan sebagai perbandingan perubahan fungsi y
terhadap perubahan input (variabel x), dengan perubahan x yang sangat kecil. Secara matematik
dapat dituliskan:
𝑓(𝑥+ℎ)−𝑓(𝑥) ∆𝑦
𝑓 ′ (𝑥) = = lim ∆𝑥 (1)
ℎ ∆𝑥 → 0
bila dipilih ∆x = h, maka:
𝑓(𝑥+ℎ)−𝑓(𝑥)
𝑓 ′ (𝑥) = lim ℎ
(2)
ℎ→0
Diferensiasi numerik digunakan untuk mnegevaluasi turunan sebuah fungsi kontinu.
Diferensiasi numerik berangkat dari deret Taylor yang menyatakan bahwa jika kita tahu fungsi
f(x) di titik x, dan turunan-turunannya pada titik tersebut, maka kita bisa mengetahui titik
selanjutnya.
𝑛
𝑓 (𝑎)
𝑓(𝑥) = ∑∞
𝑛=0 (𝑥 − 𝑎)𝑛 (3)
𝑛!
𝑓′′ (𝑎)
𝑓(𝑥) = 𝑓(𝑎) + 𝑓 ′ (𝑎)(𝑥 − 𝑎) + (𝑥 − 𝑎)2 + ...
2!
Pada modul ini, diferensiasi numerik yang akan dibahas adlaah metode Beda Maju (forward
difference), metode Beda Tengah (central difference), metode Beda Mundur (backward difference),
dan metode Stencil Lima Titik (five points stencil).
METODE BEDA MAJU (Forward Difference)
Metode ini mengadopsi langsung definisi diferensial dengan h berhingga. Metode ini juga
dapat diturunakn dari deret Taylor dengan mensubstitusi x = xi + 1, a = xi, dan ∆x ≡ xi + 1 – xi = h.
𝑓′′ (𝑥𝑖 ) 𝑓′′′(𝑥𝑖 )
𝑓(𝑥𝑖+ 1 ) = 𝑓(𝑥𝑖 ) + 𝑓 ′ (𝑥𝑖 )(ℎ) + (ℎ)2 + (ℎ)3 + ... (4)
2! 3!
Suku ke-4 selanjutnya bernilai mendekati nol, maka:
𝑓′′ (𝑥𝑖 )
𝑓(𝑥𝑖+ 1 ) = 𝑓(𝑥𝑖 ) + 𝑓 ′ (𝑥𝑖 )(ℎ) + (ℎ)2
2!
sehingga diperoleh diferensial pertama dari fungsi f(x):
𝑓(𝑥𝑖+1 )−𝑓(𝑥𝑖 ) 𝑓′′ (𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) = − (ℎ2 )
ℎ 2
Subtitusi xi = x dan xi + 1 = x + h ke dalam persamaan tersebut memberikan:
𝑓(𝑥+ℎ)+𝑓(𝑥)
𝑓 ′ (𝑥) ≅ (5)

dengan error
2

𝜀(𝑓) = − 2 𝑓 ′′ (𝑥) (6)
Dengan cara yang sama diperoleh diferensial kedua dari fungsi f(x):
𝑓(𝑥+2ℎ)−𝑓(𝑥+ℎ) 𝑓(𝑥+ℎ)−𝑓(𝑥)
𝑓′ (𝑥+ℎ)−𝑓′ (𝑥) − 𝑓(𝑥+2ℎ)−2𝑓(𝑥−ℎ)+𝑓(𝑥)
𝑓 ′′ (𝑥)
≅ = ℎ ℎ
= (7)
ℎ ℎ ℎ2
Metode ini disebut beda maju karena mengambil titik di depan x untuk menemukan nilai f’(x) dan
f’’(x). Pemilihan nilai h harus kecil supaya error-nya kecil.

METODE BEDA MUNDUR (Backward Difference)


Dengan mensubstitusi x = xi – 1, a = xi, dan ∆x ≡ xi – xi – 1 = h pada deret Taylor diperoleh:
𝑓′′ (𝑥𝑖 ) 𝑓′′′(𝑥𝑖 )
𝑓(𝑥𝑖− 1 ) = 𝑓(𝑥𝑖 ) − 𝑓 ′ (𝑥𝑖 )(ℎ) + (ℎ)2 − (ℎ)3 + ... (8)
2! 3!
Suku ke-4 dan selanjutnya bernilai mendekati nol, maka
𝑓′′ (𝑥𝑖 )
𝑓(𝑥𝑖− 1 ) = 𝑓(𝑥𝑖 ) − 𝑓 ′ (𝑥𝑖 )(ℎ) + (ℎ)2
2!
sehingga diperoleh diferensial pertama dari fungsi f(x):
𝑓(𝑥𝑖 )−𝑓(𝑥𝑖− 1 ) 𝑓′′ (𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) = − (ℎ2 )
ℎ 2
Substitusikan x = x dan xi – 1 = x – h ke dalam persamaan tersebut sehingga didapat
𝑓(𝑥)−𝑓(𝑥−ℎ)
𝑓 ′ (𝑥) ≅ (9)

dengan error
ℎ2 ′′
𝜀(𝑓) = 𝑓 (𝑥) (10)
2
Dengan cara yang sama diperoleh diferensial kedua dari fungsi f(x):
𝑓(𝑥)−𝑓(𝑥−ℎ) 𝑓(𝑥−ℎ)−𝑓(𝑥−2ℎ)
𝑓′ (𝑥)−𝑓′ (𝑥−ℎ) − 𝑓(𝑥)−2𝑓(𝑥−ℎ)+𝑓(𝑥−2ℎ)
𝑓 ′′ (𝑥)
≅ = ℎ ℎ
= (11)
ℎ ℎ ℎ2
Metode ini disebut beda mundur karena mengambil titik di belakang x untuk menemukan nilai
f’(x) dan f’’(x).

METODE BEDA TENGAH (Central Difference)


Metode ini mengambil perubahan dari dua titik di sekitar yang diukur. Metode selisih tengah
mengambil perbedaan pada nilai fungsi beda maju dan beda mundur. Dengan mengurangi
persamaan (4) dan (8) serta dipilih ∆x ≡ xi + 1 – xi = h, diperoleh
𝑓′′ (𝑥𝑖 )
𝑓(𝑥𝑖 + 1 ) − 𝑓(𝑥𝑖− 1 ) = 2𝑓 ′ (𝑥𝑖 )(ℎ) + (ℎ)3 + ... (12)
3!
sehingga diperoleh diferensial pertama dari fungsi f(x):
𝑓(𝑥𝑖 + 1 )−𝑓(𝑥𝑖− 1 ) 𝑓′′ (𝑥𝑖 )
𝑓 ′ (𝑥𝑖 ) = − (ℎ2 ) + ...
2ℎ 6
Suku ke-3 dan seterusnya bernilai mendekati nol sehingga
𝑓(𝑥+ℎ)−𝑓(𝑥−ℎ)
𝑓 ′ (𝑥𝑖 ) ≅ (13)
2ℎ
dengan error
2
ℎ ′′′
𝜀(𝑓) = − 𝑓 (𝑥) (14)
6
Selanjutnya, dapat diperoleh diferensial kedua dari fungsi f(x) dengan menjumlahkan f ( x + h) dan
f ( x – h) sehingga didapatkan
𝑓(𝑥+2ℎ)−2𝑓(𝑥)+𝑓(𝑥−ℎ)
𝑓 ′′ (𝑥) ≅ (15)
ℎ2
Berikut turunan orde lebih tinggi untuk metode beda tengah
𝑓(𝑥+2ℎ)−2𝑓(𝑥+ℎ)+2𝑓(𝑥−ℎ)−𝑓(𝑥−2ℎ)
𝑓 (3) (𝑥) = (16)
2ℎ3

METODE STENCIL LIMA TITIK (Five Point Stencil)


Metode five point stencil merupakan metode diferensiasi numerik dengan orde lebih tinggi
dengan menggunakan empat buah titik untuk mengaproksimasi turunan di suatu titik. Titik yang
digunakan merupakan x – 2h, x – h, x + h, dan x + 2h. Persamaan dari f (x ± 2h) bisa dicari
menggunakan metode deret Taylor sehingga didapatkan persamaan turunan berikut.
𝑓(𝑥+2ℎ)+8𝑓(𝑥+ℎ)−8𝑓(𝑥−ℎ)+𝑓(𝑥−2ℎ)
𝑓 ′ (𝑥) ≅ (17)
12ℎ
dengan error
ℎ4 (5)
𝜀(𝑓) = 𝑓 (𝑥) (18)
20
dan berikut merupakan turunan dengan orde lebih tingginya
−𝑓2 + 16𝑓1 − 30𝑓0 + 16𝑓−1 −𝑓−2
𝑓 ′′ (𝑥) = (19)
12ℎ2
−𝑓3 + 8𝑓2 − 13𝑓1 + 13𝑓−1 −8𝑓−2 + 𝑓−3
𝑓 (3) (𝑥) = (20)
8ℎ3
3. DATA
3
a. 𝑟⃗(𝑡) = 2 sin(5𝑡)𝑖̂ + ( 𝑡 2 + 4𝑡 − 5)𝑗̂
2
No. t h
1. 0 0,01
2. 3 0,01
3. 6 0,01
Tabel 1. Nilai t dan h yang digunakan dalam percobaan metode beda maju, beda mundur, beda
tengah, dan stencil lima titik.
4. PENGOLAHAN DATA
a. Percobaan Metode Beda Maju
 Source Code
Function rx(t) As Double
rx = 2 * (Sin(5 * t))
End Function
Function ry(t) As Double
ry = ((3 / 2) * t ^ 2) + 4 * t - 5
End Function
Sub Forward()
'Deklarasi Variabel
Dim t As Double, h As Double, vy As Double, ay As Double, vx As Double,
ax As Double, v As Double, a As Double, e As Double, r As Double
Cells(1, 1) = "t"
Cells(1, 2) = "h"
Cells(1, 3) = "rx"
Cells(1, 4) = "ry"
Cells(1, 5) = "vx"
Cells(1, 6) = "ax"
Cells(1, 7) = "vy"
Cells(1, 8) = "ay"
Cells(1, 9) = "v"
Cells(1, 10) = "a"
Cells(1, 11) = "e"
Cells(1, 12) = "r"
'Input nilai t dan h
For i = 1 To 3
t = InputBox("Masukkan nilai t")
Cells(i + 1, 1) = t
h = InputBox("Masukkan nilai h")
Cells(i + 1, 2) = h
'Hitung nilai rx dan ry
Cells(i + 1, 3) = rx(t)
Cells(i + 1, 4) = ry(t)
'Hitung kecepatan dan percepatan sb-x
vx = (rx(t + h) - rx(t)) / h
Cells(i + 1, 5) = vx
ax = (rx(t + 2 * h) - 2 * rx(t + h) + rx(t)) / h ^ 2
Cells(i + 1, 6) = ax
'Hitung kecepatan dan percepatan sb-y
vy = (ry(t + h) - ry(t)) / h
Cells(i + 1, 7) = vy
ay = (ry(t + 2 * h) - 2 * ry(t + h) + ry(t)) / h ^ 2
Cells(i + 1, 8) = ay
'Hitung besar kecepatan dan percepatan
v = Sqr(vx ^ 2 + vy ^ 2)
Cells(i + 1, 9) = v
a = Sqr(ax ^ 2 + ay ^ 2)
Cells(i + 1, 10) = a
'Hitung error
e = -(h ^ 2 * a) / 2
Cells(i + 1, 11) = e
'Hitung r
r = Sqr(rx(t) ^ 2 + ry(t) ^ 2)
Cells(i + 1, 12) = r
Next i
End Sub
b. Percobaan Metode Beda Mundur
 Source Code
Function rx(t) As Double
rx = 2 * (Sin(5 * t))
End Function
Function ry(t) As Double
ry = ((3 / 2) * t ^ 2) + 4 * t - 5
End Function
Sub Backward()
'Deklarasi Variabel
Dim t As Double, h As Double, vy As Double, ay As Double, vx As Double,
ax As Double, v As Double, a As Double, e As Double, r As Double
Cells(1, 1) = "t"
Cells(1, 2) = "h"
Cells(1, 3) = "rx"
Cells(1, 4) = "ry"
Cells(1, 5) = "vx"
Cells(1, 6) = "ax"
Cells(1, 7) = "vy"
Cells(1, 8) = "ay"
Cells(1, 9) = "v"
Cells(1, 10) = "a"
Cells(1, 11) = "e"
Cells(1, 12) = "r"
'Input nilai t dan h
For i = 1 To 3
t = InputBox("Masukkan nilai t")
Cells(i + 1, 1) = t
h = InputBox("Masukkan nilai h")
Cells(i + 1, 2) = h
'Hitung nilai rx dan ry
Cells(i + 1, 3) = rx(t)
Cells(i + 1, 4) = ry(t)
‘Hitung kecepatan dan percepatan sb-x
vx = (rx(t) - rx(t - h)) / h
Cells(i + 1, 5) = vx
ax = (rx(t) - 2 * rx(t - h) + rx(t - 2 * h)) / h ^ 2
Cells(i + 1, 6) = ax
'Hitung kecepatan dan percepatan sb-y
vy = (ry(t) - ry(t - h)) / h
Cells(i + 1, 7) = vy
ay = (ry(t) - 2 * ry(t - h) + ry(t - 2 * h)) / h ^ 2
Cells(i + 1, 8) = ay
'Hitung besar kecepatan dan percepatan
v = Sqr(vx ^ 2 + vy ^ 2)
Cells(i + 1, 9) = v
a = Sqr(ax ^ 2 + ay ^ 2)
Cells(i + 1, 10) = a
'Hitung error
e = (h ^ 2 * a) / 2
Cells(i + 1, 11) = e
'Hitung r
r = Sqr(rx(t) ^ 2 + ry(t) ^ 2)
Cells(i + 1, 12) = r
Next i
End Sub
c. Percobaan Metode Beda Tengah
 Source Code
Function rx(t) As Double
rx = 2 * (Sin(5 * t))
End Function
Function ry(t) As Double
ry = ((3 / 2) * t ^ 2) + 4 * t - 5
End Function
Sub Central()
'Deklarasi Variabel
Dim t As Double, h As Double, vy As Double, ay As Double, vx As Double,
ax As Double, v As Double, a As Double, zx As Double, zy As Double, z As
Double, e As Double, r As Double
Cells(1, 1) = "t"
Cells(1, 2) = "h"
Cells(1, 3) = "rx"
Cells(1, 4) = "ry"
Cells(1, 5) = "vx"
Cells(1, 6) = "ax"
Cells(1, 7) = "vy"
Cells(1, 8) = "ay"
Cells(1, 9) = "v"
Cells(1, 10) = "a"
Cells(1, 11) = "zx"
Cells(1, 12) = "zy"
Cells(1, 13) = "z"
Cells(1, 14) = "e"
Cells(1, 15) = "r"
'Input nilai t dan h
For i = 1 To 3
t = InputBox("Masukkan nilai t")
Cells(i + 1, 1) = t
h = InputBox("Masukkan nilai h")
Cells(i + 1, 2) = h
'Hitung nilai rx dan ry
Cells(i + 1, 3) = rx(t)
Cells(i + 1, 4) = ry(t)
'Hitung kecepatan dan percepatan sb-x
vx = (rx(t + h) - rx(t - h)) / (2 * h)
Cells(i + 1, 5) = vx
ax = (rx(t + h) - 2 * rx(t) + rx(t - h)) / h ^ 2
Cells(i + 1, 6) = ax
'Hitung kecepatan dan percepatan sb-y
vy = (ry(t + h) - ry(t - h)) / (2 * h)
Cells(i + 1, 7) = vy
ay = (ry(t + h) - 2 * ry(t) + ry(t - h)) / h ^ 2
Cells(i + 1, 8) = ay
'Hitung besar kecepatan dan percepatan
v = Sqr(vx ^ 2 + vy ^ 2)
Cells(i + 1, 9) = v
a = Sqr(ax ^ 2 + ay ^ 2)
Cells(i + 1, 10) = a
'Hitung besar turunan ketiga
zx = (rx(t + 2 * h) - 2 * rx(t + h) + 2 * rx(t - h) - rx(t - 2 * h))
/ (2 * h ^ 3)
Cells(i + 1, 11) = zx
zy = (ry(t + 2 * h) - 2 * ry(t + h) + 2 * ry(t - h) - ry(t - 2 * h))
/ (2 * h ^ 3)
Cells(i + 1, 12) = zy
z = Sqr(zx ^ 2 + zy ^ 2)
Cells(i + 1, 13) = z
'Hitung error
e = -(h ^ 2 * z) / 6
Cells(i + 1, 14) = e
'Hitung r
r = Sqr(rx(t) ^ 2 + ry(t) ^ 2)
Cells(i + 1, 15) = r
Next i
End Sub
d. Percobaan Metode Stencil Lima Titik
 Source Code
Function rx(t) As Double
rx = 2 * (Sin(5 * t))
End Function
Function ry(t) As Double
ry = ((3 / 2) * t ^ 2) + 4 * t - 5
End Function
Sub Stencil()
'Deklarasi Variabel
Dim t As Double, h As Double, vy As Double, ay As Double, vx As Double,
ax As Double, v As Double, a As Double, zx As Double, zy As Double, z As
Double, e As Double, r As Double
Cells(1, 1) = "t"
Cells(1, 2) = "h"
Cells(1, 3) = "rx"
Cells(1, 4) = "ry"
Cells(1, 5) = "vx"
Cells(1, 6) = "ax"
Cells(1, 7) = "vy"
Cells(1, 8) = "ay"
Cells(1, 9) = "v"
Cells(1, 10) = "a"
Cells(1, 11) = "zx"
Cells(1, 12) = "zy"
Cells(1, 13) = "z"
Cells(1, 14) = "e"
Cells(1, 15) = "r"
'Input nilai t dan h
For i = 1 To 3
t = InputBox("Masukkan nilai t")
Cells(i + 1, 1) = t
h = InputBox("Masukkan nilai h")
Cells(i + 1, 2) = h
'Hitung nilai rx dan ry
Cells(i + 1, 3) = rx(t)
Cells(i + 1, 4) = ry(t)
'Hitung kecepatan dan percepatan sb-x
vx = (-rx(t + 2 * h) + 8 * rx(t + h) - 8 * rx(t - h) + rx(t - 2 *
h)) / (12 * h)
Cells(i + 1, 5) = vx
ax = (-rx(t + (2 * h)) + 16 * rx(t + h) - 30 * rx(t) + 16 * rx(t -
h) - rx(t - (2 * h))) / (12 * (h ^ 2))
Cells(i + 1, 6) = ax
'Hitung kecepatan dan percepatan sb-y
vy = (-ry(t + 2 * h) + 8 * ry(t + h) - 8 * ry(t - h) + ry(t - 2 *
h)) / (12 * h)
Cells(i + 1, 7) = vy
ay = (-ry(t + (2 * h)) + 16 * ry(t + h) - 30 * ry(t) + 16 * ry(t -
h) - ry(t - (2 * h))) / (12 * (h ^ 2))
Cells(i + 1, 8) = ay
'Hitung besar kecepatan dan percepatan
v = Sqr(vx ^ 2 + vy ^ 2)
Cells(i + 1, 9) = v
a = Sqr(ax ^ 2 + ay ^ 2)
Cells(i + 1, 10) = a
'Hitung besar turunan keempat
zx = (rx(t + (2 * h)) - (4 * rx(t + h)) + (6 * rx(t)) - (4 * rx(t -
h)) + rx(t - (2 * h))) / h ^ 4
Cells(i + 1, 11) = zx
zy = (ry(t + (2 * h)) - (4 * ry(t + h)) + (6 * ry(t)) - (4 * ry(t -
h)) + ry(t - (2 * h))) / h ^ 4
Cells(i + 1, 12) = zy
z = Sqr(zx ^ 2 + zy ^ 2)
Cells(i + 1, 13) = z
'Hitung error
e = (h ^ 4 * z) / 30
Cells(i + 1, 14) = e
'Hitung r
r = Sqr(rx(t) ^ 2 + ry(t) ^ 2)
Cells(i + 1, 15) = r
Next i
End Sub
e. Screenshoot Tampilan Program

Gambar 1. Tampilan metode beda maju, beda mundur, beda tengah, dan stencil lima titik (1)

Gambar 2. Tampilan metode beda maju, beda mundur, beda tengah, dan stencil lima titik (2)

Gambar 3. Tampilan metode beda maju (3)

Gambar 4. Tampilan metode beda mundur (3)


Gambar 5. Tampilan metode beda tengah (3)

Gambar 6. Tampilan metode stencil lima titik (3)

f. Hasil Pengolahan Data


h Metode t (s) r (m) vx (m/s) vy (m/s) v (m/s) ax (m/s^2) ay (m/s^2) a (m/s^2) galat
Beda maju 5 9,995834 4,015 10,77204 -2,49844 3 3,904125 -0,000195
Beda mundur 5 9,995834 3,985 10,7609 2,498438 3 3,904125 0,000195
Beda tengah 0 5 9,995834 4 10,76646 0 3 3 -0,00416
Stencil 5 9,999998 4 10,77033 0 3 3 1,18E-16
Beda maju 20,54121 -7,75625 13,015 15,1509 -30,569 3 30,71582 -0,00154
Beda mundur 20,54121 -7,43118 12,985 14,96104 -34,365 3 34,49572 0,001725
0,01 Beda tengah 3 20,54121 -7,59371 13 15,05538 -32,5076 3 32,64575 -0,00316
Stencil 20,54121 -7,59688 13 15,05698 -32,5144 3 32,6525 2,71E-07
Beda maju 73,02674 1,788828 22,015 22,08756 48,94418 3 49,03603 -0,00245
Beda mundur 73,02674 1,294915 21,985 22,0231 49,71495 3 49,80539 0,00249
Beda tengah 6 73,02674 1,541872 22 22,05396 49,39129 3 49,48323 -0,00064
Stencil 73,02674 1,542514 22 22,05401 49,40158 3 49,49258 4,12E-07
Tabel 2. Hasil percobaan metode beda maju, beda mundur, beda tengah, dan stencil lima titik dengan variasi nilai t untuk h = 0,01.
5. ANALISIS
a. Hasil percobaan metode beda maju, beda mundur, beda tengah, dan stencil lima titik dengan variasi nilai h.
t (s) Metode h r (m) vx (m/s) vy (m/s) v (m/s) ax (m/s^2) ay (m/s^2) a (m/s^2) galat
Beda maju 5 9,588511 4,15 10,44806 -23,476 3 23,66693 -0,11833
Beda mundur 5 9,588511 3,85 10,33257 23,47602 3 23,66693 0,118335
Beda tengah 0,1 5 9,588511 4 10,3894 0 3 3 -0,39127
Stencil 5 9,979778 4 10,75156 0 3 3 2,96E-17
Beda maju 5 9,995834 4,015 10,77204 -2,49844 3 3,904125 -0,000195
Beda mundur 5 9,995834 3,985 10,7609 2,498438 3 3,904125 0,000195
0 Beda tengah 0,01 5 9,995834 4 10,76646 0 3 3 -0,00416
Stencil 5 9,999998 4 10,77033 0 3 3 1,18E-16
Beda maju 5 9,999958 4,0015 10,77085 -0,25 3 3,010399 -1,5E-06
Beda mundur 5 9,999958 3,9985 10,76973 0,249998 3 3,010399 1,51E-06
Beda tengah 0,001 5 9,999958 4 10,77029 0 3 3 -4,2E-05
Stencil 5 10 4 10,77033 0 3 3 5,92E-17
Tabel 3. Hasil percobaan metode beda maju, beda mundur, beda tengah, dan stencil lima titik dengan variasi nilai h untuk t = 0.

t (s) Metode h r (m) vx (m/s) vy (m/s) v (m/s) ax (m/s^2) ay (m/s^2) a (m/s^2) galat
Beda maju 20,54121 -8,87641 13,15 15,86547 -10,1101 3 10,5458 -0,05273
Beda mundur 20,54121 -5,69214 12,85 14,05429 -45,779 3 45,87718 0,229386
Beda tengah 0,1 20,54121 -7,28428 13 14,9017 -31,8426 3 31,98364 -0,29724
Stencil 20,54121 -7,58152 13 15,04923 -32,4923 3 32,63051 0,002599
Beda maju 20,54121 -7,75625 13,015 15,1509 -30,569 3 30,71582 -0,00154
Beda mundur 20,54121 -7,43118 12,985 14,96104 -34,365 3 34,49572 0,001725
3 Beda tengah 0,01 20,54121 -7,59371 13 15,05538 -32,5076 3 32,64575 -0,00316
Stencil 20,54121 -7,59688 13 15,05698 -32,5144 3 32,6525 2,71E-07
Beda maju 20,54121 -7,6131 13,0015 15,06646 -32,324 3 32,46291 -1,6E-05
Beda mundur 20,54121 -7,58059 12,9985 15,04747 -32,7038 3 32,84115 1,64E-05
Beda tengah 0,001 20,54121 -7,59685 13 15,05696 -32,5143 3 32,65243 -3,2E-05
Stencil 20,54121 -7,59688 13 15,05698 -32,5144 3 32,6525 2,71E-11
Tabel 4. Hasil percobaan metode beda maju, beda mundur, beda tengah, dan stencil lima titik dengan variasi nilai h untuk t = 3.
t (s) Metode h r (m) vx (m/s) vy (m/s) v (m/s) ax (m/s^2) ay (m/s^2) a (m/s^2) galat
Beda maju 73,02674 3,898088 22,15 22,49039 38,83704 3 38,95274 -0,19476
Beda mundur 73,02674 -0,94 21,85 21,87021 46,07946 3 46,17702 0,230885
Beda tengah 0,1 73,02674 1,479042 22 22,04966 48,38092 3 48,47384 -0,06035
Stencil 73,02674 1,539395 22 22,05379 49,36803 3 49,4591 0,003948
Beda maju 73,02674 1,788828 22,015 22,08756 48,94418 3 49,03603 -0,00245
Beda mundur 73,02674 1,294915 21,985 22,0231 49,71495 3 49,80539 0,00249
Beda tengah 0,01 73,02674 1,541872 22 22,05396 49,39129 3 49,48323 -0,00064
6
Stencil 73,02674 1,542514 22 22,05401 49,40158 3 49,49258 4,12E-07
Beda maju 73,02674 1,567209 22,0015 22,05725 49,3623 3 49,45338 -2,5E-05
Beda mundur 73,02674 1,517807 21,9985 22,0508 49,43942 3 49,53036 2,48E-05
Beda tengah 0,001 73,02674 1,542508 22 22,05401 49,40148 3 49,49248 -6,4E-06
Stencil 73,02674 1,542514 22 22,05401 49,40158 3 49,49259 4,12E-11
Tabel 5. Hasil percobaan metode beda maju, beda mundur, beda tengah, dan stencil lima titik dengan variasi nilai h untuk t = 6.

b. Untuk membandingkan penyelesaian diferensiasi numerik dengan metode beda maju, beda mundur, beda tengah, dan stencil lima titik
dapat dilakukan dengan cara memvariasikan nilai t dan h. Dari hasil pengolahan data yang ditampilkan pada tabel (2) sampai dengan
tabel (5) terlihat bahwa rata-rata nilai setiap nilai perhitungan yang diperoleh dengan menggunakan keempat metode tersebut relatif
sama, namun nilai kesalahan relatif (galat) masing-masing metode bervariatif. Jika galat suatu metode semakin kecil maka metode
tersebut lebih valid dan teliti serta nilai perhitungan yang dihasilkan semakin mendekati nilai benar. Dari hasil pengolahan data yang
ditampilkan pada tabel (2) sampai dengan tabel (5) dapat disimpulkan bahwa metode stencil lima titik (five point stencil) adalah yang
paling valid dan teliti karena memiliki nilai galat yang paling kecil, kemudian diikuti oleh metode beda tengah (central difference), dan
terakhir metode beda maju (forward difference) dan beda mundur (backward difference) dengan nilai galat yang relatif sama. Selain
itu, nilai h juga mempengaruhi besar kesalahan relatif (galat) dari keempat metode yang digunakan, dimana dari data yang ditampilkan
pada tabel (2) sampai dengan tabel (5) dapat disimpulkan bahwa semakin kecil nilai h yang digunakan maka nilai galat yang dihasilkan
juga akan semakin kecil. Hal ini berarti bahwa semakin kecil nilai yang digunakan maka nilai nilai perhitungan yang dihasilkan akan
semakin valid dan teliti. Jadi untuk menghasilkan nilai perhitungan dengan galat yang lebih kecil maka pengguna harus memperkecil
nilai h.
c. Grafik rx, ry, vx, vy, ax, ay terhadap t untuk t = 0 sampai dengan t = 10 dengan ∆t = 0,1 menggunakan metode stencil lima titik dengan
h = 0,001.
60

40

20
rx (m)
0 vx (m/s)
ax (m/s^2)
-20

-40

-60

(a)

200

150

100 ry (m)
vy (m/s)

50 ay (m/s^2)

0
0 2 4 6 8 10 12

-50

(b)
Gambar 7. Grafik hubungan antara (a) rx, vx, ax (b) ry, vy, ay terhadap t untuk metode
stencil dengan h = 0,001.
d. Metode lain yang dapat digunakan untuk memperbaiki akurasi diferensiasi numerik dengan
memperkecil error yang dihasilkan dapat dilakukan dengan menggunakan metode
Ekstrapolasi Richardson yang dirumuskan sebagai:
4 1
𝐷 ≈ 𝐷(ℎ2 ) − 𝐷(ℎ1 ) (21)
3 3
Untuk dua buah nilai aproksimasi diferensial tengah dengan 0(ℎ2 ) dapat dikombinasikan
dengan ekstrapolasi Richardson untuk memberikan estimasi dengan error 0(ℎ4 ).
6. KESIMPULAN
a. Metode forward differerence (beda maju), backward difference (beda mundur), central
difference (beda tengah), dan five point stencil (stencil lima titik) dapat digunakan untuk
menyelesaikan diferensiasi numerik dari suatu persamaan pada pemrograman VBA Excel
dengan metode five point stencil adalah yang paling valid dan teliti karena memiliki nilai galat
yang paling kecil, dimana untuk bisa menghasilkan nilai perhitungan dengan galat yang lebih
kecil maka pengguna harus memperkecil nilai h.
7. REFERENSI
[1] NN. 2019. Modul-04 2019: Diferensiasi Numerik. Bandung: Institut Teknologi Bandung.
[2] Setiawan, Agus. 2006. Pengantar Metode Numerik. Yogyakarta: CV ANDI OFFSET.
LAMPIRAN
 Source code untuk permbuatan plot rx, ry, vx, vy, ax dan ay untuk t = 0 sampai t = 10 dengan
∆t = 0,1 dan h = 0,001 menggunakan metode stencil lima titik.
Function rx(t) As Double
rx = 2 * (Sin(5 * t))
End Function
Function ry(t) As Double
ry = ((3 / 2) * t ^ 2) + 4 * t - 5
End Function
Sub Stencil()
'Deklarasi Variabel
Dim t As Double, h As Double, vy As Double, ay As Double, vx As Double, ax As
Double, v As Double, a As Double, zx As Double, zy As Double, z As Double, e
As Double, r As Double
Cells(1, 1) = "t (s)"
Cells(1, 2) = "rx (m)"
Cells(1, 3) = "ry (m)"
Cells(1, 4) = "vx (m/s)"
Cells(1, 5) = "vy (m/s)"
Cells(1, 6) = "ax (m/s^2)"
Cells(1, 7) = "ay (m/s^2)"

'Input nilai t dan h


h = InputBox("Masukkan Nilai h")
t = 0
For i = 1 To 101
Cells(1 + i, 1) = t
t = t + 0.1
'Hitung nilai rx dan ry
Cells(i + 1, 2) = rx(t)
Cells(i + 1, 3) = ry(t)
'Hitung kecepatan dan percepatan sb-x
vx = (-rx(t + 2 * h) + 8 * rx(t + h) - 8 * rx(t - h) + rx(t - 2 * h)) /
(12 * h)
Cells(i + 1, 4) = vx
ax = (-rx(t + (2 * h)) + 16 * rx(t + h) - 30 * rx(t) + 16 * rx(t - h) -
rx(t - (2 * h))) / (12 * (h ^ 2))
Cells(i + 1, 6) = ax
'Hitung kecepatan dan percepatan sb-y
vy = (-ry(t + 2 * h) + 8 * ry(t + h) - 8 * ry(t - h) + ry(t - 2 * h)) /
(12 * h)
Cells(i + 1, 5) = vy
ay = (-ry(t + (2 * h)) + 16 * ry(t + h) - 30 * ry(t) + 16 * ry(t - h) -
ry(t - (2 * h))) / (12 * (h ^ 2))
Cells(i + 1, 7) = ay
Next i
End Sub

Anda mungkin juga menyukai