Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  simpson.f90
Language: FORTRAN
Code:
     program simpson
        implicit none
     integer,paramater::N=5
        real,dimension(N)::x,f
        real :: a,b,h,s1,s2,I
     do while(a>b)
        print*, 'donner a et b:'
        read*, a,b
        end do
        x(1)=a
        x(N)=b
        f(1)=sin(x(1))/(x(1)+1)
       f(N)=sin(x(N))/(x(N)+1)
h=(b-a)/N
s1=0
s2=0
do i=2,N-1
if(mod(i,2).eq.0) then
x(i)=x(i-1)+h
f(i)=sin(x(i))/(x(i)+1)
s1=s1+f(i)
else
x(i)=x(i-1)+h
f(i)=sin(x(i))/(x(i)+1)
s2=s2+f(i)
end if
end do
I=(h/3)*(f(a)+f(b)+2*s1+4*s2)
write*,I
stop
end program simpson

          
Comments: