Module NullstellenFinden Function f(ByVal x As Double) As Double Return Math.Sin(x) End Function Sub Main() Dim a, b, m, ya, yb, ym As Double Dim str As String Dim n As Integer = 0 Console.WriteLine("a:") str = Console.ReadLine() a = Double.Parse(str) Console.WriteLine("b:") str = Console.ReadLine() b = Double.Parse(str) Console.WriteLine("Eingabe war: " + Format(a) + " und " + Format(b)) Do m = (a + b) / 2 ya = f(a) ym = f(m) yb = f(b) n = n + 1 If ya * yb > 0 Then Console.WriteLine("Keine Nullstelle im Intervall") Exit Do Else If ya * ym > 0 Then a = m Else b = m End If End If Loop Until Math.Abs(ym) < 10.0 ^ -12 Console.WriteLine("Nullstelle: " + Format(m) + " nach " + Format(n) + " Durchläufen") End Sub End Module