资源描述:
《数值分析上机题作业》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、数值分析上机题作业电器学院交通信息工程及控制罗宁20050290010110第一章源程序:REALSS=1DO1=1,71S=S*29/IENDDOWRITE"*)nY=*SEND结果:Y=79.5416第三章源程序:REALX,Y,N,K,DX,NEWTON,NE,S,XKDIMENSIONX(6),Y(6),NE(6,6),NEWTON(21)DATAX/0.2,0.24,0.28,0.32,0.36,0.4/DATAY/0.1987,0.2377,0.2764,0.3146,0.3523,03894/!计算差商表:
2、DX=0.04DO1=1,6NE(I,1)=Y(I)ENDDODOJ=2,6DO上J,6NE(I,J)=(NE(IJ-1)-NE(I-1,J-1))/(DX*(J-1))ENDDOENDDODO1=1,21XK=0.2+(I-l)*0.01NEWTON(I)=NE(1,1)S=1DOJ=2,6S=S*(XK-X(J-1))NEWTON(D=NEWTON(D+S*NE(JJ)ENDDOENDDOWRITE(*,*),,NEWTON=M,NEWTONENDNEWTON=0.1987000.2084510.2182090.227
3、90.2474170.2571080.2667700.2764000.2859980.3050970.3146000.3240720.3335130.3429230.3523000.3709430.3801990.389400结果:0.2377000.2955640.361642第四章源程序:REALA,B,ANS,DDIMENSIONA(4,4),B(4),ANS(4),D(4,5)DATAA/4197,6.8,88.6,1.45,305,71.3,76.4,5.9,-206,&&-47.4,-10.8,6.13,-84
4、0,52,80236.5/DATAB/136,11.5,25.7,6.6/CALLLGAUS(A,B,4,D)CALLGAUSQ(D,4,ANS)WRITE(**)*ANS=ANSEND-1.684955E-02结果:ANS=3.226190E-020.3223860.291290第五章源程序:REALA1,B1,A2,B2,E1,E2Al=0;A2=0B1=3.141592654/2;B2=1El=0.00()001;E2=0.001CALLSIMPB1(A1,B1,E1,S)VVRITE(*,*),第一题simpso
5、n:1,SCALLSIMPB2(A2,B2,E1,S)WRITER*),第二题simpson:SCALLROMBERG1(A1,B1,E2,R)WRITER,*),第一题ROMBERG,RCALLROMBERG2(A2,B2,E2,R)VVRITE(*,*),第二题ROMBERG,RENDSUBROUTINESIMPB1(A,B,E,S)F(X)=SIN(X)/XH=(B-A)/2S2=0;N=lSO=1+F(B)S1=F(A+H)S=(S0+4.0*Sl)*H/3.060N=2*N;H=H/2.0S2=S2+S1SI=
6、0.0X=A+HDO1=1,NS1=S1+F(X)X=X+H+HENDDOS2N=(S0+2.0*S2+4.0*Sl)*H/3.0IF(ABS(S2N-S)>E)THENS=S2NGOTO60ENDIFENDSUBROUTINESUBROUTINESIMPB2(A,B,E,S)F(X)=LOG(1+X)/XH=(B-A)/2S2=0;N=lSO=1+F(B)S1=F(A+H)S=(S0+4.0*Sl)*H/3.060N=2*N;H=H/2.0S2=S2+S1Sl=0.0X=A+HDO1=1,NS1=S1+F(X)X二X+H
7、+HENDDOS2N=(S0+2.0*S2+4.0*Sl)*H/3.0IF(ABS(S2N-S)>E)THENS=S2NGOTO60ENDIFENDSUBROUTINESUBROUTINEROMBERG1(A,B,E,R)F(X)=SIN(X)/XREALS,DS,TINTEGERK,UDIMENSIONS(100,100)S(l,l)=(B-A)*(F(B)+l)/2K=1T=0100K=K+1S(K,1)=1/2*S((K-1),1)U=2**(K・2)・1DOJ=0,UT=T+F(A+(2*J+1)*(B-A)/(2
8、**(K-1)))ENDDOS(K,1)=S(K,1)+T*(B-A)/2**(K-1)DOJ=2,KS((K.J+l)J)=(4**(J-l)*S((K-J+2),(J-l))+S((K-J+l),(J-l)))/&&(4**(J-1)-1)ENDDODS=S(1K)・S(1K・1)IF(ABS(DS