functionf(x)implicitnonereal*8::f,xf=dsin(x)endfunctionfprogramSimpsonimplicitnoneinteger,parameter::N=40integer::ireal*8::f!²½³¤hreal*8::h=0.1real*8::x(0:N),s,y!²åÖµµãdoi=0,Nx(i)=1+i*henddos=0!Simpson»ý·Ö¹«Ê½doi=0,N-1s=s+h/6.0*(f(x(i))+4.0*f(0.5*(x(i)+x(i+1)))+f(x(i+1)))enddoprint*,sy=cos(1.0)-cos(5.0)print*,yendprogramSimpsonfunctionf(x)implicitnonereal*8::f,xf=dsin(x)endfunctionfprogramSimpsonimplicitnoneinteger,parameter::N=40integer::ireal*8::f!²½³¤hreal*8::h1=0.1,h2=0.05real*8::x1(0:N),x2(0:2*N),s1,s2,y,error!²åÖµµãdoi=0,Nx1(i)=1+i*h1enddodoi=0,2*Nx2(i)=1+i*h2enddos1=0s2=0!Simpson»ý·Ö¹«Ê½doi=0,N-1s1=s1+h1/6.0*(f(x1(i))+4.0*f(0.5*(x1(i)+x1(i+1)))+f(x1(i+1)))enddodoi=0,2*N-1s2=s2+h2/6.0*(f(x2(i))+4.0*f(0.5*(x2(i)+x2(i+1)))+f(x2(i+1)))enddoprint*,s1print*,s2error=(s2-s1)/15.0print*,error=,errory=cos(1.0)-cos(5.0)print*,yendprogramSimpson