Program SIMPSON_COMP_10VAR IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION X10(1000000) a=0d0 b=1d0 N=4 h=(b-a)/N do i=1,N x10(i)=a+i*h enddo sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 do i=1,nimp sum1=sum1+2*g10(x10(2*i)) enddo do i=1,np sum2=sum2+4*g10(x10(2*i-1)) enddo r=h/3d0*(g10(a)+sum1+sum2+g10(b)) open(20,File="ejerc10simp_comp_10var.xls") write(20,*)r call cpu_time(finish) write(20,30)finish-start 30 Format(e18.8) close(20) end FUNCTION g1(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) Implicit Double Precision (A-H,O-Z) ! parameter (a,b) g1=exp(-(x1*x1)-(x2*x2)-(x3*x3)-(x4*x4)-(x5*x5)-(x6*x6)-(x7*x7)- & (x8*x8)-(x9*x9)-(x10*x10))* &cos(x1*x2+x2*x3+x3*x4+x4*x5+x5*x6+x6*x7+x7*x8+x8*x9+x9*x10+x10*x1) END Function g2(x2,x3,x4,x5,x6,x7,x8,x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x1(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x1(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g1(x1(2*i),x2,x3,x4,x5,x6,x7,x8,x9,x10) enddo do i=1,np sum2=sum2+4*g1(x1(2*i-1),x2,x3,x4,x5,x6,x7,x8,x9,x10) enddo g2=h/3d0*(g1(a,x2,x3,x4,x5,x6,x7,x8,x9,x10)+sum1+sum2+ & g1(b,x2,x3,x4,x5,x6,x7,x8,x9,x10)) END Function g3(x3,x4,x5,x6,x7,x8,x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x2(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x2(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g2(x2(2*i),x3,x4,x5,x6,x7,x8,x9,x10) enddo do i=1,np sum2=sum2+4*g2(x2(2*i-1),x3,x4,x5,x6,x7,x8,x9,x10) enddo g3=h/3d0*(g2(a,x3,x4,x5,x6,x7,x8,x9,x10)+sum1+sum2+ & g2(b,x3,x4,x5,x6,x7,x8,x9,x10)) END Function g4(x4,x5,x6,x7,x8,x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x3(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x3(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g3(x3(2*i),x4,x5,x6,x7,x8,x9,x10) enddo do i=1,np sum2=sum2+4*g3(x3(2*i-1),x4,x5,x6,x7,x8,x9,x10) enddo g4=h/3d0*(g3(a,x4,x5,x6,x7,x8,x9,x10)+sum1+sum2+ & g3(b,x4,x5,x6,x7,x8,x9,x10)) END Function g5(x5,x6,x7,x8,x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x4(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x4(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g4(x4(2*i),x5,x6,x7,x8,x9,x10) enddo do i=1,np sum2=sum2+4*g4(x4(2*i-1),x5,x6,x7,x8,x9,x10) enddo g5=h/3d0*(g4(a,x5,x6,x7,x8,x9,x10) & +sum1+sum2+g4(b,x5,x6,x7,x8,x9,x10)) END Function g6(x6,x7,x8,x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x5(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x5(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g5(x5(2*i),x6,x7,x8,x9,x10) enddo do i=1,np sum2=sum2+4*g5(x5(2*i-1),x6,x7,x8,x9,x10) enddo g6=h/3d0*(g5(a,x6,x7,x8,x9,x10) & +sum1+sum2+g5(b,x6,x7,x8,x9,x10)) END Function g7(x7,x8,x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x6(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x6(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g6(x6(2*i),x7,x8,x9,x10) enddo do i=1,np sum2=sum2+4*g6(x6(2*i-1),x7,x8,x9,x10) enddo g7=h/3d0*(g6(a,x7,x8,x9,x10) & +sum1+sum2+g6(b,x7,x8,x9,x10)) END Function g8(x8,x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x7(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x7(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g7(x7(2*i),x8,x9,x10) enddo do i=1,np sum2=sum2+4*g7(x7(2*i-1),x8,x9,x10) enddo g8=h/3d0*(g7(a,x8,x9,x10) & +sum1+sum2+g7(b,x8,x9,x10)) END Function g9(x9,x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x8(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x8(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g8(x8(2*i),x9,x10) enddo do i=1,np sum2=sum2+4*g8(x8(2*i-1),x9,x10) enddo g9=h/3d0*(g8(a,x9,x10) & +sum1+sum2+g8(b,x9,x10)) END Function g10(x10) IMPLICIT DOUBLE PRECISION (A-H,O-Z) DOUBLE PRECISION x9(1000000) N=4 sum1=0d0 sum2=0d0 nimp= n/2-1 np = n/2 a=0d0 b=1d0 h=(b-a)/N do i=1,N x9(i)=a+i*h enddo do i=1,nimp sum1=sum1+2*g9(x9(2*i),x10) enddo do i=1,np sum2=sum2+4*g9(x9(2*i-1),x10) enddo g10=h/3d0*(g9(a,x10) & +sum1+sum2+g9(b,x10)) END