Minggu, 01 Januari 2012
vb_matrix
1. Menyelesaikan Fungsi Turunan
a. Metode 2 Titik Maju
b. Metode 2 Titik Mundur
c. Metode 3 Titik
d. Metode 5 Titik
Mencari Turunaari Fungsi F(x)= 3 X^2, Untuk X =3 dengan Visual Basic 6.0
Atur Properti Seperti Pada Gambar Di Bawah :
Masukan Kode Program Seperti Di Bawah Ini :
Private Sub Command1_Click()
'Grid.Rows = 10
Grid.Cols = 9
Grid.ColWidth(0) = 2000
Grid.TextMatrix(0, 0) = "h"
Grid.ColWidth(1) = 1500
Grid.TextMatrix(0, 1) = "2 Titik Maju"
Grid.ColWidth(2) = 700
Grid.TextMatrix(0, 2) = "er"
Grid.ColWidth(3) = 2000
Grid.TextMatrix(0, 3) = "2 Titik Mundur"
Grid.TextMatrix(0, 4) = "er"
Grid.ColWidth(5) = 1500
Grid.TextMatrix(0, 5) = "3 Titik"
Grid.TextMatrix(0, 6) = "er"
Grid.ColWidth(7) = 1500
Grid.TextMatrix(0, 7) = "5 Titik"
Grid.TextMatrix(0, 8) = "er"
'Mencari Turunan Dari f(x)= 3 x^2, Diaman x=3
x = 3
exact = 6 * x
h = 0.1
i = 1
Do
Grid.Rows = i + 1
'2 Titik Maju
Grid.TextMatrix(i, 0) = h
Hasil1 = ((3 * ((x + h) ^ 2)) - (3 * ((x) ^ 2))) / h
Grid.TextMatrix(i, 1) = Format(Hasil1, "0.00000")
Ralat1 = Abs((exact - Hasil1) / exact)
Grid.TextMatrix(i, 2) = Format(Ralat1, "0.00%")
'2 Titik Mundur
Hasil2 = ((3 * (x) ^ 2) - (3 * (x - h) ^ 2)) / h
Grid.TextMatrix(i, 3) = Format(Hasil2, "0.00000")
Ralat2 = Abs((exact - Hasil2) / exact)
Grid.TextMatrix(i, 4) = Format(Ralat2, "0.00%")
'3 Titik
Hasil3 = ((3 * ((x + h) ^ 2)) - ((3 * (x - h) ^ 2))) / (2 * h)
Grid.TextMatrix(i, 5) = Format(Hasil3, "0.00000")
Ralat3 = Abs((exact - Hasil3) / exact)
Grid.TextMatrix(i, 6) = Format(Ralat3, "0.00%")
'5 Titik
k1 = (3 * ((x + h) ^ 2)) - (3 * ((x - h) ^ 2))
k2 = (3 * ((x + (2 * h)) ^ 2)) - (3 * ((x - (2 * h)) ^ 2))
Hasil4 = (8 * k1 - k2) / (12 * h)
Grid.TextMatrix(i, 7) = Format(Hasil4, "0.00000")
Ralat4 = Abs((exact - Hasil4) / exact)
Grid.TextMatrix(i, 8) = Format(Ralat4, "0.00%")
h = h / 2
i = i + 1
Loop Until Format(Ralat1, "0.00%") = Text1.Text
Exit Sub
End Sub
Terimakasi :
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar