Friday, November 26, 2010

write a program to do numerical integration of any given function (by trapizoidal method)

implicit double precision (a-h,o-z)
 f(x)=x*x
 sum=0.0
 
 write(*,*) 'x'
 read(*,*) x
 h=1/x
 do i=0,x
      sum=sum+f(i*h)
 
 enddo
 xsum=(sum+0.5*(f(0)+f(1)))*h
 write(*,*) xsum
 
      stop
      end
 

No comments:

Post a Comment