I'm trying to use Simpson's rule to evaluate the integral of sqrt(1-x^2) in the interval from -1 to 1. However, the sum represented by the variable "s", in the code that I developed, doesn't converge at all to pi over 2. I'm an absolute novice to fortran and programming in general, so please bear with me. What am I doing wrong?
PROGRAM integral
REAL*8 :: x
REAL*8 :: h
REAL*8 :: fodd
REAL*8 :: feven
REAL*8 :: simpson
REAL*8 :: s
x = -1
s = 0
simpson = 0
h = 0
DO WHILE (x<=1)
fodd = sqrt(1-(x+(2*h+0.1))**(2))
feven = sqrt(1-(x+2*h)**(2))
simpson = 4*fodd + 2*feven
s = s + simpson*(h/3)
WRITE(*,*) x,h, fodd, feven, simpson, s
h = 0.1
x = x + h
END DO
END PROGRAM
Here's a link to the output it generates: https://pastebin.com/mW06Z6Lq
Since this integral is just half the area of a circle of radius 1 it should converge to pi over 2, but it surpasses this value by a large amount. I thought about making the step smaller for precision, but this is not the problem as it surpassed even more the expected value when I tried this.