您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 能源与动力工程 > 变步长梯形法求积分Fortran程序
变步长梯形法求积分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
本文标题:变步长梯形法求积分Fortran程序
链接地址:https://www.777doc.com/doc-1817749 .html