变步长梯形法求积分Fortran程序programmainexternalbianbuchangtixingreala,bprint*,'输入积分上线a,下线b'read*,a,bcallbianbuchangtixing(a,b)print*,'准确结果为:0.9460831'endfunctionf(x)realx,fif(x==0)thenf=1.elsef=sin(x)/xendifendfunctionsubroutinebianbuchangtixing(a,b)reala,b,s,x,h,T1,T2,epslenepslen=10**-10;T2=0.h=b-aT1=h*(f(a)+f(b))/2dowhile(abs(T1-T2)epslen)s=0x=a+(h/2)dowhile(xb)s=s+f(x)x=x+henddoT2=(T1/2)+s*h/2h=h/2T1=T2enddoprint*,'变步长梯形法结果为',T2endsubroutine