版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
《数值分析》作业学院:机械学院专业:机械工程姓名:赵博学号:2014520024日期:2
第二章作业P48_2给出的数值表如下:x0.40.50.60.70.8lnx-0.916291-0.693147-0.510826-0.356675-0.223144问:用线性插值及二次插值计算ln0.54的近似值。答:VB程序如下:OptionExplicitSubczfl(ByRefx()AsSingle,y()AsSingle,nAsInteger,x1AsDouble,fAsDouble)Dimi,jAsIntegerDimpAsSingleDimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.Addf=0Fori=0Tonp=1Forj=0TonIfi<>jThenp=p*(x1-x(j))/(x(i)-x(j))EndIfNextjwsmysheet.cells(i+1,1)=Str(p)wsmysheet.cells(i+1,2)=Str(p*y(i))f=f+p*y(i)Nextiwsmysheet.cells(n+1,3)="最终结果"+Str(f)appexcel.Visible=TrueEndSubPrivateSubCommand1_Click(IndexAsInteger)Dimx()AsSingleDimy()AsSingleDimnAsIntegerDimkAsIntegerDimfAsDoublek=0n=Val(Text1.Text)ReDimx(n)ReDimy(n)Open"czfl.txt"ForOutputAs#1Print#1,Text3.TextClose#1Open"czfl.txt"ForInputAs#1DoWhileNotEOF(1)Input#1,x(k),y(k)'Printx(k),y(k)k=k+1LoopClose#1SelectCaseIndexCase0Callczfl(x(),y(),Text1.Text,Text2.Text,f)Case1Callczfnt(x(),y(),Text1.Text,Text2.Text,f)EndSelectEndSubSubczfnt(ByRefx()AsSingle,y()AsSingle,nAsInteger,x1AsDouble,fAsDouble)Dimi,jAsIntegerDimk,lAsIntegerDimsAsDoubleDimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.Addf=y(0)s=1Forj=1TonFori=nTojStep-1y(i)=(y(i)-y(i-1))/(x(i)-x(i-j))wsmysheet.cells(i,j)=Str(y(i))NextiNextjFork=1Tons=s*(x1-x(l))f=f+s*y(k)Nextkwsmysheet.cells(n,n+1)="最终结果"+Str(f)appexcel.Visible=TrueEndSub结果:线性插值0.6-0.415890.4-0.20433最终结果-.620218614056672二次插值-0.120.1099550.84-0.582240.28-0.14303最终结果-.615319814966043
第三章作业P95_16.观测物体的直线运动,得到一下数据:时间t(s)00.91.93.03.95.0距离s(m)010305080110求运动方程。答:vb程序如下:(窗体见工程文件)OptionExplicitOptionBase1Sublufj(nAsInteger,a()AsSingle,b()AsSingle)DimiAsInteger,jAsInteger,kAsIntegerDimsAsSingleFori=2Tona(i,1)=a(i,1)/a(1,1)NextiFori=2TonForj=iTons=0Fork=1Toi-1s=s+a(i,k)*a(k,j)Nextka(i,j)=a(i,j)-sNextjForj=i+1Tons=0Fork=1Toi-1s=s+a(j,k)*a(k,i)Nextka(j,i)=(a(j,i)-s)/a(i,i)NextjNextiFori=1Tons=0Forj=1Toi-1s=s+a(i,j)*b(j)Nextjb(i)=b(i)-sNextiFori=nTo1Step-1s=0Forj=i+1Tons=s+a(i,j)*b(j)Nextjb(i)=(b(i)-s)/a(i,i)NextiEndSubSubdxnh(nAsInteger,mAsInteger,x()AsSingle,y()AsSingle,a()AsSingle,c()AsSingle)DimiAsInteger,jAsInteger,kAsSingleDimsAsSingleFori=1Tom+1Forj=iTom+1s=0Fork=1Tons=s+x(k)^(i+j-2)Nextka(i,j)=sa(j,i)=sNextjNextiFori=1Tom+1s=0Fork=1Tons=s+y(k)*x(k)^(i-1)Nextkc(i)=sNextiFori=1Tom+1a(i,m+2)=c(i)NextiCalllufj(m+1,a(),c())EndSubSubxy(nAsInteger,x()AsSingle,y()AsSingle,z()AsSingle,aAsSingle,bAsSingle)DimsumAsSingle,sumxAsSingle,sumyAsSingleDimsumxyAsSingle,sumxxAsSingleDimxavAsSingle,yavAsSingle,iAsIntegerFori=1Tonsum=sum+z(i)sumx=sumx+x(i)*z(i)sumy=sumy+y(i)*z(i)sumxy=sumxy+x(i)*y(i)*z(i)sumxx=sumxx+x(i)^2*z(i)Nextixav=sumx/sumyav=sumy/sumb=(sum*sumxy-sumx*sumy)/(sum*sumxx-sumx^2)a=yav-b*xavEndSubPrivateSubCombo1_Click()DimIndexAsIntegerIndex=Combo1.ListIndexSelectCase(Index)Case0:Command2.Visible=FalseLabel4.Visible=FalseText3.Visible=FalseLabel1.Caption="请输入实验数据x(i),y(i),及每组数据出现的次数z(i):n=1,2,3,4,5...如:"Text1.Text="3.2,4,2"&vbCrLf&"3.7,4.5,4"Label3.Visible=TrueText2.Visible=TrueCommand1.Visible=TrueCase1:Command1.Visible=FalseText2.Text="0"Text3.Text="0"Label1.Caption="请输入实验数据x(i),y(i):n=1,2,3,4,5...如:"Text1.Text="3.2,4"&vbCrLf&"3.7,4.5"Label3.Visible=TrueText2.Visible=TrueLabel4.Visible=TrueText3.Visible=TrueCommand2.Visible=TrueEndSelectEndSubPrivateSubCommand1_Click()Dimx()AsSingle,y()AsSingle,z()AsSingleDimnAsInteger,iAsIntegerDimbAsSingle,aAsSingleDimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.AddOpen"shuju.txt"ForOutputAs#1Print#1,Text1.TextClose#1n=Val(Text2.Text)Open"shuju.txt"ForInputAs#1ReDimx(n)ReDimy(n)ReDimz(n)Fori=1TonInput#1,x(i),y(i),z(i)wsmysheet.cells(1,i)=Str(x(i))wsmysheet.cells(2,i)=Str(y(i))wsmysheet.cells(3,i)=Str(z(i))NextiClose#1Callxy(n,x(),y(),z(),a,b)Open"yicijigeuo.txt"ForOutputAs#1Print#1,"所求的一元线性拟合方程为:"+"Y=";a;"+";b;"X"Close#1wsmysheet.cells(4,n+1)="最终结果:"+"Y="+Str(a)+"+"+Str(b)+"X"appexcel.Visible=TrueEndSubPrivateSubCommand2_Click()Dimx()AsSingle,y()AsSingle,a()AsSingle,c()AsSingleDimiAsInteger,jAsInteger,mAsInteger,nAsInteger,fstrAsStringn=Val(Text2.Text)m=Val(Text3.Text)DimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.AddOpen"shuju.txt"ForOutputAs#1Print#1,Text1.TextClose#1Open"shuju.txt"ForInputAs#1ReDimx(n)ReDimy(n)ReDimc(m+1)ReDima(m+1,m+2)Fori=1TonInput#1,x(i),y(i)wsmysheet.cells(1,i)=Str(x(i))wsmysheet.cells(2,i)=Str(y(i))'Printx(i);y(i)'PrintNextiClose#1Calldxnh(n,m,x(),y(),a(),c())fstr="Y="Fori=1Tom+1wsmysheet.cells(3,i)=Str(c(i))Ifi=m+1Thenfstr=fstr+Str(c(i))&"x^"&(i-1)Elsefstr=fstr+Str(c(i))&"x^"&(i-1)&"+"EndIfNextiOpen"duocijigeuo.txt"ForOutputAs#1Print#1,"所求的多次拟合方程为:"+fstrClose#1wsmysheet.cells(4,n+1)="最终结果:"+fstrappexcel.Visible=TrueEndSubPrivateSubForm_Load()Label1.Caption="下面的文本框为实验数据输入框"Combo1.AddItem"一次线性拟合",0Combo1.AddItem"多项式拟合",1EndSub结果:一次多项式拟合结果00.91.933.950.610305080110111111最终结果:Y=-7.550592+22.25376X第四章作业P135_2.(1).分别用梯形公式和辛普森公式计算下列积分答:vb程序如下:OptionExplicitDimindexAsIntegerPrivateSubCombo1_Click()index=Combo1.ListIndexSelectCase(index)Case0:Label3.Visible=TrueText1.Visible=TrueLabel1.Caption="你选择的是复化梯形求积公式"Case1:Label3.Visible=TrueText1.Visible=TrueLabel1.Caption="你选择的是复化辛普森积公式"Case2:Label3.Visible=FalseText1.Visible=FalseLabel1.Caption="你选择的是柯斯特求积公式"EndSelectEndSubPrivateSubCommand1_Click()Dima,bAsIntegerDimfAsDoubleDimnAsIntegera=0b=1n=Val(Text1.Text)SelectCase(index)Case0:Calltx(a,b,f,n)Case1:Callxps(a,b,f,n)Case2:Callkst(a,b,f)EndSelectEndSubSubtx(ByRefa,b,f1AsDouble,nAsInteger)DimiAsIntegerDimc()AsDoubleDimsumAsDoubleDimhAsDoubleReDimc(n-1)DimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.Addwsmysheet.cells(1,1)=Str(a)wsmysheet.cells(1,2)=Str(f(a))wsmysheet.cells(n+1,1)=Str(b)wsmysheet.cells(n+1,2)=Str(f(b))h=(b-a)/nFori=1Ton-1c(i)=a+i*hwsmysheet.cells(i+1,1)=Str(c(i))wsmysheet.cells(i+1,2)=Str(f(c(i)))sum=sum+f(c(i))Nextif1=(b-a)*(f(a)+2*sum+f(b))/16wsmysheet.cells(n+1,3)=Str(f1)appexcel.Visible=TrueEndSubSubxps(ByRefa,b,f2AsDouble,nAsInteger)DimiAsIntegerDimx()AsDoubleDimy()AsDoubleDimsumAsDoubleDimsum1AsDoubleDimhAsDoubleReDimx(n)ReDimy(n-1)DimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.Addwsmysheet.cells(1,1)=Str(a)wsmysheet.cells(1,2)=Str(f(a))wsmysheet.cells(2*n+1,1)=Str(b)wsmysheet.cells(2*n+1,2)=Str(f(b))h=(b-a)/nFori=0To3x(i)=a+i*h+h/2sum=sum+f(x(i))wsmysheet.cells(2*i+2,1)=Str(x(i))wsmysheet.cells(2*i+2,2)=Str(f(x(i)))NextiFori=1To3y(i)=a+i*hsum1=sum1+f(y(i))wsmysheet.cells(2*i+1,1)=Str(y(i))wsmysheet.cells(2*i+1,2)=Str(f(y(i)))Nextif2=h*(f(a)+4*sum+2*sum1+f(b))/6wsmysheet.cells(2*n+1,3)=Str(f2)appexcel.Visible=TrueEndSubSubkst(ByRefa,b,f3AsDouble)Dimc(4)DimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.AddDimiAsIntegerFori=0To4c(i)=a+i*(b-a)/4wsmysheet.cells(i+1,1)=Str(c(i))wsmysheet.cells(i+1,2)=Str(f(c(i)))Nextif3=(b-a)*(7*f(c(0))+32*f(c(1))+12*f(c(2))+32*f(c(3))+7*f(c(4)))/90wsmysheet.cells(5,3)=Str(f3)appexcel.Visible=TrueEndSubPrivateSubForm_Load()Combo1.AddItem"复化梯形求积公式",0Combo1.AddItem"复化辛普森求积公式",1Combo1.AddItem"科特斯求积公式",2EndSub结果:1.梯形公式000.1253.11E-020.256.15E-020.3759.06E-020.50.1176470.6250.1423490.750.1643840.8750.18360710.20.1114022.辛普森公式000.1253.11E-020.256.15E-020.3759.06E-020.50.1176470.6250.1423490.750.1643840.8750.18360710.20.111572
第五章作业P177_10.用平方根法解方程组,这里用的是高斯主消元法答:vb程序如下:(窗体见工程文件)OptionExplicitOptionBase1SubGS(nAsInteger,a()AsSingle,x()AsSingle)DimiAsInteger,kAsInteger,sAsInteger,jAsIntegerDimyinziAsSingle,maxAsSingle,bAsSingleDimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.AddFork=1TonFori=1Ton+1wsmysheet.cells(k,i)=Str(a(k,i))NextiNextkwsmysheet.cells(n+1,1)="消元变换的最终形式:"Fork=1Ton-1max=Abs(a(k,k))s=k'选列最大元素Fori=kTonIfAbs(a(i,k))>maxThens=imax=Abs(a(i,k))EndIfNexti'交换两列Fori=1Ton+1max=a(k,i)a(k,i)=a(s,i)a(s,i)=maxNexti'约化,进行行变换Fori=k+1Tonyinzi=a(i,k)/a(k,k)Forj=kTon+1a(i,j)=a(i,j)-a(k,j)*yinziNextjNextiNextkPrintFori=1TonForj=1Ton+1wsmysheet.cells(n+1+i,j)=Str(Format(a(i,j),"######0.0000"))NextjNextix(n)=a(n,n+1)/a(n,n)wsmysheet.cells(1,n+2)="计算的最终结果:"wsmysheet.cells(n,n+3)="x"+"("+Str(n)+")"wsmysheet.cells(n,n+4)=Str(x(n))Fori=n-1To1Step-1b=0Forj=i+1Tonb=b+a(i,j)*x(j)Nextjx(i)=(a(i,n+1)-b)/a(i,i)wsmysheet.cells(i,n+3)="x"+"("+Str(i)+")"wsmysheet.cells(i,n+4)=Str(x(i))Nextiappexcel.Visible=TrueEndSubPrivateSubCommand1_Click()Dima()AsSingle,x()AsSingle,nAsInteger,iAsInteger,jAsIntegern=Val(Text2.Text)Open"shuju.txt"ForOutputAs#1Print#1,Text1.TextClose#1Open"shuju.txt"ForInputAs#1ReDima(n,n+1)ReDimx(n)Fori=1TonForj=1TonInput#1,a(i,j)NextjPrintNextiFori=1TonInput#1,a(i,n+1)NextiClose#1CallGS(n,a(),x())EndSub结果:2-114计算的最终结果:x(1)1.111111-1-235x(2)0.7777781316x(3)2.555556消元变换的最终形式:2-11403.50.54003.85719.8571第六章作业P209_1.设方程组用雅可比迭代法及高斯—塞德尔迭代法解此方程组,要求当时迭代终止。答:vb程序如下:OptionExplicitOptionBase1DimindexAsIntegerSubykb(nAsInteger,a()AsSingle,x()AsSingle,flatAsDouble)DimiAsInteger,jAsInteger,kAsIntegerDimsum1AsSingle,sum2AsSingleDimmaxAsSingleDimy()AsSingle,z()AsSingleReDimy(n)ReDimz(n)DimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.AddFori=1TonForj=1Ton+1wsmysheet.cells(i,j)=Str(a(i,j))NextjNextiwsmysheet.cells(n+1,1)="初始向量为:"Fori=1Tonwsmysheet.cells(n+2,i)=Str(x(i))Nextik=0DoFori=1Tonsum1=0sum2=0Forj=1Toi-1sum1=sum1+a(i,j)*x(j)NextjForj=i+1Tonsum2=sum2+a(i,j)*x(j)Nextjy(i)=(a(i,n+1)-sum1-sum2)/a(i,i)NextiFori=1Tonz(i)=Abs(y(i)-x(i))x(i)=y(i)Nextimax=z(1)Fori=1TonIfz(i)>maxThenmax=Abs(z(i))EndIfNextik=k+1LoopUntilmax<flatwsmysheet.cells(1,n+2)="最终结果为:"Fori=1Tonwsmysheet.cells(i,n+3)=Str(x(i))Nextiwsmysheet.cells(n+3,1)="迭代次数:"wsmysheet.cells(n+3,2)=Str(k)appexcel.Visible=TrueEndSubSubGS(nAsInteger,a()AsSingle,x()AsSingle,flatAsDouble)DimiAsInteger,jAsInteger,kAsIntegerDimsum1AsSingle,sum2AsSingleDimmaxAsSingleDimy()AsSingle,z()AsSingleReDimy(n)ReDimz(n)DimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.AddFori=1TonForj=1Ton+1wsmysheet.cells(i,j)=Str(a(i,j))NextjNextiwsmysheet.cells(n+1,1)="初始向量为:"Fori=1Tonwsmysheet.cells(n+2,i)=Str(x(i))Nextik=0DoFori=1Tonsum1=0sum2=0Forj=1Toi-1sum1=sum1+a(i,j)*x(j)NextjForj=i+1Tonsum2=sum2+a(i,j)*x(j)Nextjy(i)=(a(i,n+1)-sum1-sum2)/a(i,i)z(i)=Abs(y(i)-x(i))x(i)=y(i)Nextimax=z(1)Fori=1TonIfz(i)>maxThenmax=Abs(z(i))EndIfNextik=k+1LoopUntilmax<flatwsmysheet.cells(1,n+2)="最终结果为:"Fori=1Tonwsmysheet.cells(i,n+3)=Str(x(i))Nextiwsmysheet.cells(n+3,1)="迭代次数:"wsmysheet.cells(n+3,2)=Str(k)appexcel.Visible=TrueEndSubPrivateSubCombo1_Click()index=Combo1.ListIndexSelectCase(index)Case0:Command1.Caption="高斯—赛德尔迭代法"Case1:Command1.Caption="雅可比迭代法"EndSelectEndSubPrivateSubCommand1_Click()Dima()AsSingle,x()AsSingle,nAsInteger,iAsInteger,jAsInteger,flatAsDoublen=Val(Text2.Text)flat=Val(Text3.Text)Open"shuju.txt"ForOutputAs#1Print#1,Text1.TextClose#1Open"shuju.txt"ForInputAs#1ReDima(n,n+1)ReDimx(n)'Fori=1TonForj=1TonInput#1,a(i,j)NextjNextiFori=1TonInput#1,a(i,n+1)NextiFori=1TonInput#1,x(i)NextiClose#1SelectCase(index)Case0:CallGS(n,a(),x(),flat)Case1:Callykb(n,a(),x(),flat)EndSelectEndSubPrivateSubForm_Load()Combo1.AddItem"高斯—赛德尔迭代法",0Combo1.AddItem"雅可比迭代法",1EndSub结果:1、高斯-赛德尔迭代法521-12最终结果为:-4.00003-142202.9999832-31032.000001初始向量为:000迭代次数:82、雅可比迭代法521-12最终结果为:-4-142202.9999742-31032初始向量为:000迭代次数:18
第七章P238_7.用下列方法求在x0=2附近的根,根的准确值x*=1.87938524···,要求计算结果精确到四位有效数字。(1)用牛顿法;(2)用弦截法,取x0=2,x1=1.9;答:vb程序如下:DimindexAsIntegerPrivateSubCombo1_Click()index=Combo1.ListIndexSelectCase(index)Case0:Label1.Caption="你选择的是牛顿法:"Label3.Visible=FalseText3.Visible=FalseCase1:Label1.Caption="你选择的是弦截法:"Label3.Visible=TrueText3.Visible=TrueEndSelectEndSubPrivateSubCommand1_Click()DimaAsSingle,bAsSingle,flatAsSingleflat=Val(Text1.Text)SelectCase(index)Case0:a=Val(Text2.Text)Callnd(a,flat)Case1:a=Val(Text2.Text)b=Val(Text3.Text)Callxj(a,b,flat)EndSelectEndSubSubxj(aAsSingle,bAsSingle,flatAsSingle)DimiAsInteger,kAsIntegerDimx(0To20)AsDoubleDimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.Addx(0)=ax(1)=bk=0Dok=k+1x(k+1)=x(k)-(x(k)-x(k-1))/(hanshu(x(k))-hanshu(x(k-1)))*hanshu(x(k))LoopUntilAbs(x(k+1)-x(k))/Abs(x(k+1))<flatFori=0Tok+1wsmysheet.cells(i+1,1)=Str(i)wsmysheet.cells(i+1,2)=Str(x(i))Nextiappexcel.Visible=TrueEndSubSubnd(aAsSingle,flatAsSingle)DimiAsIntegerDimx(0To100)AsDoubleDimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.Addx(0)=a'x(1)=bk=-1Dok=k+1x(k+1)=x(k)-hanshu1(x(k))LoopUntilAbs(x(k+1)-x(k))/Abs(x(k+1))<flatFori=0Tok+1wsmysheet.cells(i+1,1)=Str(i)wsmysheet.cells(i+1,2)=Str(x(i))Nextiappexcel.Visible=TrueEndSubPrivateSubForm_Load()Combo1.AddItem"牛顿法",0Combo1.AddItem"弦截法",1EndSub运行结果:1、牛顿法:0211.88888921.87945231.87938541.8793852、弦截法:0211.921.88109431.87941141.87938551.879385第八章P276_3_(1).用幂法计算下列矩阵的主特征值及对应的特征向量当特征值有3位小数稳定时迭代终止。答:vb程序如下:OptionExplicitOptionBase1DimindexAsIntegerSubcm(ByRefNAsInteger,x()AsSingle,A()AsSingle,z()AsSingle,_epsAsSingle,sAsInteger,v2AsSingle)Dimv1AsSingle,iAsInteger,jAsInteger,sumAsSingle,b()AsSingleReDimb(N)v1=x(1)DoWhileAbs(v2-v1)>=epsv1=v2s=s+1Fori=1ToNsum=0Forj=1ToNsum=sum+A(i,j)*x(j)Nextjz(i)=sumNextiv2=z(1)Fori=1ToNIfAbs(z(i))>Abs(v2)Thenv2=z(i)EndIfb(i)=z(i)NextiIfAbs(v2-v1)<=epsThenExitDoFori=1ToNx(i)=b(i)/v2NextiLoopEndSubPrivateSubCombo1_Click()index=Combo1.ListIndexSelectCase(index)Case0Label1.Caption="你选择的是求主特征值;请输入元素A=a(i,j)(i,j=1,2,...n)及初值向量x(i)(i=1,2,...n)"Command1.Caption="求主特征值"Case1Label1.Caption="你选择的是求最小特征值;请输入元素A=a(i,j)(i,j=1,2,...n)及初值向量x(i)(i=1,2,...n)"Command1.Caption="求最小特征值"EndSelectEndSubPrivateSubCommand1_Click()DimA()AsSingle,x()AsSingle,z()AsSingleDimNAsInteger,MAsInteger,sAsInteger,iAsInteger,jAsInteger,epsAsSingle,v2AsSingleDimappexcelAsObjectDimwbmybookAsObjectDimwsmysheetAsObjectSetappexcel=CreateObject("excel.application")Setwbmybook=appexcel.workbooks.AddSetwsmysheet=appexcel.worksheets.AddN=Val(Text2.Text)Open"shuju.dat"ForOutputAs#1Print#1,Text1.TextClose#1eps=0.00001Open"shuju.dat"ForInputAs#1M=2*NReDimA(N,M)ReDimx(N)ReDimz(N)Print"矩阵A(i,j)"Fori=1ToNForj=1ToNInput#1,A(i,j)wsmysheet.cells(i,j)=A(i,j)NextjForj=N+1ToMIfi=j-NThenA(i,j)=1ElseA(i,j)=0EndIfNextjPrintNextiwsmysheet.cells(N+1,1)="初值向量:"Fori=1ToNInput#1,x(i)wsmysheet.cells(N+2,i+1)=x(i)NextiClose#1PrintSelectCase(index)Case0:Callcm(N,x(),A(),z(),eps,s,v2)wsmysheet.cells(N+3,1)="最大特征值是:"wsmysheet.cells(N+3,2)=Format(v2,"#0.######")Case1:CallNJ(N,M,A())'求逆Fori=1ToNForj=N+1ToMA(i,j-N)=A(i,j)NextjNextiCallcm(N,x(),A(),z(),eps,s,v2)wsmysheet.cells(N+3,1)="最大特征值是:"wsmysheet.cells(N+3,2)=Format(v2,"#0.######")EndSelectwsmysheet.cells(N+4,1)="对应特征向量分量是:"Fori=1ToNwsmysheet.cells(N+5,i+1)=Format(z(i)/v2,"#0.######")Nextiappexcel.Visible=TrueEndSubSubNJ(ByRefNAsInteger,MAsInteger,A()AsSingle)DimiAsInteger,jAsInteger,kAsInteger,bAsSingleFori=1ToNForj=1To2*NIf(j>N)ThenIfi=j-NThenA(i,j)=1ElseA(i,j)=0EndIfEndIfNextjNextiFork=1ToNb=A(k,k)Forj=kToMA(k,j)=A(k,j)/bNextjFori=1ToNIf(i<>k)Thenb=A(i,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024中国电子科技集团公司第三研究所校园招聘43人易考易错模拟试题(共500题)试卷后附参考答案
- 2024中国电信河北邢台分公司校园招聘8人易考易错模拟试题(共500题)试卷后附参考答案
- 2024中国烟草总公司郑州烟草研究院招收博士后研究人员易考易错模拟试题(共500题)试卷后附参考答案
- 2024中国化学工程集团限公司校园招聘500人易考易错模拟试题(共500题)试卷后附参考答案
- 字课件教学课件
- 2024上海城投水务校园招聘103人易考易错模拟试题(共500题)试卷后附参考答案
- 2024“才聚齐鲁成就未来”山东人才发展集团限公司权属企业投资经理招聘1人易考易错模拟试题(共500题)试卷后附参考答案
- 网上课件制作
- 地贫筛查的检测技术课件
- 2024年度技术开发合同:科技公司与研发团队之间的技术研发、成果分配和保密义务等规定
- 铸造机械市场分析及投资价值研究报告
- 内蒙古自治区锡林郭勒盟2024-2025学年高一上学期11月期中 生物试题(含答案)
- LOGO著作权转让协议书
- 2024年教师资格考试高级中学面试语文试题及解答参考
- 译林新版(2024)七年级英语上册Unit 5 Grammar 课件
- 关于健康的课件图片
- 2024年度上海市高校教师资格证之高等教育心理学题库与答案
- 第三章+相互作用-力+大单元教学设计 高一上学期物理人教版(2019)必修第一册
- 中国航空协会:2024低空经济场景白皮书
- 体育赛事组织服务协议
- 适合全院护士讲课
评论
0/150
提交评论