Skip to content

Instantly share code, notes, and snippets.

program simpson
!Summary: Integral from a to b of f(x) = h/3( f(a) + 4*f(a+h) + 2*f(a+2h) + 4*f(a+3h) + ...4*f(b-h) + f(b))
implicit none
integer, parameter :: dp = selected_real_kind(15, 307)
real, parameter :: pi = 3.1415927
real (kind=dp) :: h1, h2, part1, part2, exact, approx, diff, FUNC_1, FUNC_2, a, b, c, d, arg, temp
integer, parameter :: nn=50
integer :: N, cntr, coord
character(len=nn) :: stars=REPEAT('*',nn)