Sub Simpson()

Sheets("Sheet3").Select

Dim integral As Double, delta As Double, start As Double, last As Double

Dim n As Integer

start = 0

n = 20

last = 1

delta = (last - start) / n

integral = 0

For i = 1 To n / 2

integral = integral + (delta / 3) * (fval(start + (2 * i - 2) * delta) + 4 * fval(start + (2 * i - 1) * delta) + fval(start + 2 * i * delta))

Next

Cells(1, 1) = integral

End Sub

## No comments:

## Post a Comment