ВУЗ:
Составители:
Рубрика:
-28-
j = j + 1
K = K + 1
Xstr = Str(x1) + " " + Str(x2) +_
" " + Str(xroot) + " " + Str(K)
RootList1.AddItem (Xstr)
ElseIf FA * FB < 0 Then
x1 = x
x2 = x + d
xroot = rootfunc(x1, x2)
K = K + 1
Xstr = Str(x1) + " " + Str(x2) + _
" " + Str(xroot) + " " + Str(K)
RootList1.AddItem (Xstr)
End If
Next j
End Sub
'Функция вычисления значения функции в заданной точке
Public Function xfunc(ByVal u As Double) As Double
xfunc = u ^ 2 - 2 * u - 3
End Function
'Функция определения корня методом дихотомии:
Public Function rootfunc(ByVal xleft, xright As Dou-
ble) As Double
epsilon = 0.00000001
Dim AA As Double
Dim BB As Double
Dim FA As Double
Dim Fx As Double
Dim xx As Double
AA = xleft
BB = xright
FA = xfunc(AA)
Do
xx = (AA + BB) / 2
Fx = xfunc(xx)
If FA * Fx > 0 Then
AA = xx
Else
BB = xx
End If
-28- j = j + 1 K = K + 1 Xstr = Str(x1) + " " + Str(x2) +_ " " + Str(xroot) + " " + Str(K) RootList1.AddItem (Xstr) ElseIf FA * FB < 0 Then x1 = x x2 = x + d xroot = rootfunc(x1, x2) K = K + 1 Xstr = Str(x1) + " " + Str(x2) + _ " " + Str(xroot) + " " + Str(K) RootList1.AddItem (Xstr) End If Next j End Sub 'Функция вычисления значения функции в заданной точке Public Function xfunc(ByVal u As Double) As Double xfunc = u ^ 2 - 2 * u - 3 End Function 'Функция определения корня методом дихотомии: Public Function rootfunc(ByVal xleft, xright As Dou- ble) As Double epsilon = 0.00000001 Dim AA As Double Dim BB As Double Dim FA As Double Dim Fx As Double Dim xx As Double AA = xleft BB = xright FA = xfunc(AA) Do xx = (AA + BB) / 2 Fx = xfunc(xx) If FA * Fx > 0 Then AA = xx Else BB = xx End If
Страницы
- « первая
- ‹ предыдущая
- …
- 26
- 27
- 28
- 29
- 30
- …
- следующая ›
- последняя »