Function seeku(b1 As Single) As Single
Dim ls As Single
Dim cs As Single
Dim us As Single
Dim l1 As Single
Dim c1 As Single
Dim u1 As Single
Dim l2 As Single
Dim c2 As Single
Dim u2 As Single
Dim th As Single
Dim h As Single
Dim lp As Single
Dim t1 As Single
Dim t2 As Single
Dim e As Single
Dim s As Single
e = 10 ^ (-5)
h = 0.1
th = 1
ls = (b1 + 0.5) / th
cs = th * ls - b1
us = Log(cs) + Log(1 - ls)
t2 = 0
Do Until t2 > 10
t1 = 0
Do Until t1 > 100
l1 = ls + h
If l1 > 0.99 Then l1 = ls
c1 = th * l1 - b1
u1 = Log(c1) + Log(1 - l1)
l2 = ls - h
If l2 < 0.01 Then l2 = ls
c2 = th * l2 - b1
If c2 < 0.01 Then l2 = ls
c2 = th * l2 - b1
u2 = Log(c2) + Log(1 - l2)
If u1 > us Then ls = l1
If u1 > us Then us = u1
If u2 > us Then ls = l2
If u2 > us Then us = u2
If (lp - ls) ^ 2 < e Then t1 = 1000
lp = ls
t1 = t1 + 1
Loop
h = h / 2
t2 = t2 + 1
Loop
seeku = us
End Function
Private Sub Command1_Click()
Debug.Print seeku(0.01)
End Sub
最終更新:2009年08月05日 07:38