Anda di halaman 1dari 2

Sub setintervalh()

Dim Q, b, s, am, an, ak, h1, h2, ha As Variant


Dim fh1, fh2, ht, fht, e As Variant
Dim i As Integer

Rem masukkan data


Q = Cells(1, 2)
b = Cells(2, 2)
s = Cells(3, 2)
am = Cells(4, 2)
an = Cells(5, 2)
ak = (Q * an / (s) ^ 0.5) ^ 3
Cells(6, 2) = ak

Rem nilai awal


h1 = Cells(9, 3)
h2 = Cells(9, 4)
Range("a11:g81") = ""
Cells(10, 1) = "i"
Cells(10, 2) = "h1"
Cells(10, 3) = "h2"
Cells(10, 4) = "fh1"
Cells(10, 5) = "fh2"
Cells(10, 6) = "ht"
Cells(10, 7) = "fht"
Cells(10, 8) = "e"
ha = ht
i = 1

Do While i < 30

Call fungsi(b, am, ak, h1, fh1)


Call fungsi(b, am, ak, h2, fh2)
If (fh1 * fh2) < 0 Then
ht = 0.5 * (h1 + h2)
Cells(11 + i, 6) = ht
Call fungsi(b, am, ak, ht, fht)

Cells(10 + i, 1) = i
Cells(10 + i, 2) = h1
Cells(10 + i, 3) = h2
Cells(10 + i, 4) = fh1
Cells(10 + i, 5) = fh2
Cells(10 + i, 6) = ht
Cells(10 + i, 7) = fht
Cells(10 + i, 8) = e
If (fht * fh1) < 0 Then
h2 = ht
Else
h1 = ht
End If
Else
Cells(11 + i, 8) = "No"
End If
If ha <> 0 Then
e = (ht - ha) / ha
Else
e = (ht - ha) / ht
End If
Cells(11 + i, 7) = e
If Abs(e) > 0.0001 Then
ha = ht
Else
Exit Do
End If
i = i + 1
Loop

End Sub
Sub fungsi(b, am, ak, h, fh)

fh = ((b + am * h) * h) ^ 5
fh = fh - ak * (b + 2 * h * (1 + Abs(am) ^ 2) ^ 0.5) ^ 2

End Sub

Anda mungkin juga menyukai