Module Module1
Sub Main()
Dim a, b, s, eps As Decimal
Dim fa, fb, fs As Decimal
Console.WriteLine("Podaj początek i koniec przedziału:")
a = Console.ReadLine()
b = Console.ReadLine()
eps = 0.1
fa = a / 2 - 5
fb = b / 2 - 5
If fa * fb < 0 Then
Do
s = (a + b) / 2
fs = s / 2 - 5
If fa * fs < 0 Then
b = s
Else
a = s
End If
Loop While (a - b) > eps
Console.WriteLine("Miejsce zerowe fukncji =" + CStr(s))
Else
Console.WriteLine("Funkcja nie ma miejsc zerowych w podanym przedziale")
End If
Console.ReadKey()
End Sub
End Module
Witam mam problem z metodom bisekcji. Funkcja może być dowolna ale przyjąłem f(x)=x/2-5, niestety mój kod nie zawsze zwraca prawidłową wartość i nie wiem co robię źle.