program simpson implicit none double precision,parameter::a=-1.0d0,b=1.0d0 double precision f,x integer i,n double precision ii,xi,yi,y0,yn,h f(x)=8.0d0/3.0d0*(1.0d0-x*x)**1.5d0 write(*,*) 'input num of partitions' read(*,*) n if(mod(n,2)/=0)then write(*,*) 'error!' stop end if y0=f(a) yn=f(b) ii=y0+yn h=dabs(b-a)/dble(n) do i=1,n-1 xi=a+dble(i)*h yi=f(xi) if(mod(i,2)==0)then ii=ii+2.0d0*yi else ii=ii+4.0d0*yi end if end do ii=ii*h/3.0d0 write(*,100) ii 100 format(1x,'I=',f20.13) stop end