Option Strict On
Module Module1
    Function f(ByVal x As Double) As Double
        Return 1 / x
    End Function
    Sub Main()
        Console.WriteLine("введите число элементарных отрезков")
        Dim n As Integer = Integer.Parse(Console.ReadLine())
        Console.WriteLine("введите нижний предел интегрирования")
        Dim a As Double = Double.Parse(Console.ReadLine())
        Console.WriteLine("введите верхний предел интегрирования")
        Dim b As Double = Double.Parse(Console.ReadLine())
        Dim h As Double = (b - a) / n
        Dim intsum As Double = 0
        Dim int As Double = h / 3 * (f(a) + f(b))
        For i As Integer = 1 To n - 1
            If i Mod 2 = 0 Then
                intsum = h / 3 * 2 * f(a + i * h)
            Else
                intsum = h / 3 * 4 * f(a + i * h)
            End If
            int = int + intsum
        Next i
        Dim precise As Double = Math.Log(b) - Math.Log(a)
        Dim delta As Double = precise - int
        Console.WriteLine(" Результат численного интегрирования")
        Console.WriteLine(" по методу парабол")
        Console.WriteLine(" значение интеграла          |        погрешность ")
        Console.WriteLine(" {0}                               {1}", int, delta)
        Console.ReadLine()
    End Sub

End Module
