版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、計(jì)算方法實(shí)驗(yàn)數(shù)據(jù)Exp 1#include #define M 4#define N 3#define V 3#define Y 2int main()(FILE *fp1;float AMN,BNV,CYM,DMN,EMN,FYM;int i,j,k;if(fp1=fopen(f1.txt,r)=NULL)(printf(errorn);return 0;)for(i=0; iM; i+)for(j=0; jV; j+)fscanf(fp1,%f,&Aij);FILE *fp2;if(fp2=fopen(f2.txt,r)=NULL)(printf(errorn);return 0;)for
2、(i=0; iN; i+)for(j=0; jV; j+)fscanf(fp2,%f,&Bij);FILE *r1;r1=fopen(result1.txt,w);for(i=0; iM; i+)(for(j=0; jN; j+)(Cij=0;for(k=0; kV; k+)Ci昨Cij+A皿k*Bkj;printf(%10.6f,Cij);fprintf(r1,%10.2f ,Cij);)printf(n);fprintf(r1,n);Exp 2#include #include float D(double x)return(sqrt(3+(1/x);/return(3*x+1)/(x*x
3、);return(x*x*x-1)/3);return(1/(x*x-3);)int main()double x1,x2,x3;float eps=0.000000005;scanf(%f,&x2);dox1=x2;x2=D(x1);printf(n);printf(x=%10.6fn”,x2);while(fabs(x1-x2)=eps);Exp 3.1#include #include int main()FILE *fp1;fp1=fopen(f1.txt,r);FILE *fp2;fp2=fopen(f2.txt,r);double A1515,M1515;double B15,s,
4、X15;int i,j,k=0,n=10;for(i=0; i=n-1; i+)for(j=0; j=n-1; j+)fscanf(fp1,%lf,&AijD;fscanf(fp2,%lf,&Bi);)fclose(fp1);fclose(fp2);for(k=0; k=n-2; k+)(for(i=k+1; i=n-1; i+)(Mik=Aik/Akk;for(j=k+1; j=0; i-)(s=0;for(j=i+1; j=n-1; j+)s=s+Aij*Xj;Xi=(Bi-s)/Aii;)for(i=0; i=n-1; i+)printf(%lfn,Xi);return 0;Exp 3.
5、2 #include #define M 8int main()FILE *f1;f1=fopen(1.dat,r);FILE *f2;f2=fopen(2.dat,r);double A1515,C15,D15,B1515,Y15,X15;double sum=0;int i,j,k;if (f1=NULL)printf(Open failedn);for(i=1; i=M; i+)for(j=1; j=i; j+)fscanf(f1,%lf,&Aij);Aji=Aij; fscanf(f2,%lf,&Ci);fclose(fl);fclose(f2);for(int i = 1; i =
6、M; i+)(for(int j = 1; j = M; j+)printf(%5.1lf, Aij);printf(n);)for(i=1;i=M;i+)printf(%5.1lf,Ci);printf(n);for(i=1; iM; i+)(for(j=1; j=i-1; j+)(sum=0;for(k=1; k=j-1; k+)sum=sum+(Dk*Bik*Bjk);Bij=(Aij-sum)/Dj;sum=0;for(k=1; k=i-1; k+)(sum=0;sum=sum+(Dk*Bik*Bik);)Di=Aii卜sum;)for(i=1; i=M; i+)(sum=0;for(
7、k=1; k=1; i-)(sum=0;for(k=i+1; k=M; k+)sum=sum+(Bki*Xk);Xi=Yi/Di-sum;for(i=1; i=M; i+)printf(X%d=%lfn,i,Xi);return 0;)Exp 4#include #include #define M 3#define MAX 100int main()FILE *f1;f1=fopen(data.txt,r);FILE *f2;f2=fopen(data1.txt,r);double AMM,BM,XM=0,0,0,丫M;double sum,eps=0.000000001,max;int i
8、,j,k;for(i=0; iM; i+)for(j=0; jM; j+)fscanf(f1,%lf,&Aij);)k=1;while(kMAX)(for(i=0; iM; i+)(sum=0;for(j=0; jM; j+)if(j-i)sum+=Aij*Xj;Yi=(Bi-sum)/Aii;)max=0;for(i=0; iM; i+)if(maxfabs(Xi-Yi)max=fabs(Xi卜Yi);if(maxeps)break;printf(nk=%d,k);for(i=0; iM; i+)printf(Y%d=%lf,i+1,Yi);k+;for(i=0; iM; i+)Xi=Yi;
9、)if(k=MAX)(printf(errorn);)printf(nk=%d,k);for(i=0; iM; i+)printf(Y%d=%lf,i,丫i);/*#include #define M 3#include math.hmain()(double aMM= 10,-1,-2,-1,10,-2,-1,-1,5;double bM = 7.2,8.3, 4.2 ;double s, max, eps = 0.000000001;int k, i, j, N = 100;k = 1;while( kN )for ( i=0; iM ; i+ )s = 0;for ( j=0; jM;
10、j+ )if( j-i )s += aij * xj;yi = ( bi-s) / aii;max = 0;for ( i=0; iM; i+ )if( max fabs( xi-yi)max = fabs( xi - yi);if ( max eps )break;printf( nk=%d, k );for( i=0; iM; i+ )printf( y%d=%lf,i, yi);k+;for( i=0; iM; i+ )xi = yi;)if(k = N)(printf( ERROR!n);)printf( nk=%d, k );for ( i=0; i M; i+ )printf( y
11、%d=%lf, i, y i );)*/Exp 5#include stdio.h#define M 5#define N 6float x= 0.4,0.55,0.65,0.80,0.95,1.05;float y= 0.41075,0.57815,0.69675,0.90,1.00,1.25382;float x2= 1,2,3,4,5,6,7;float y2= 0.368,0.135,0.050,0.018,0.007,0.002,0.001;float f1(float xx)int i,k;float t=1,j=0;float sum1=0,sum2=0;for(i=0; i=M
12、; i+)t=1;sum1=1;sum2=1;for(k=0; k=M; k+)if(i!=k)sum1*=xx-xk;sum2*=xi-xk;t=sum1/sum2;j+=yi*t;return j;float f2(float xx) (int i=0,k=0;float t=1,z=0;float sum1,sum2;for(i=0; i=N; i+)(t=1;sum1=1;sum2=1;for(k=0; k=N; k+)if(k!=i)(sum1*=xx-x2k;sum2*=x2i-x2k;t=t*sum1/sum2;z+=y2i*t;return z; int main()print
13、f(the answer is %fn,f1(0.596);printf(the answer is %fn,f1(0.99);printf(the answer is %fn,f2(1.8);printf(the answer is %fn,f2(6.15);Exp6#include #include #define Num 10float sNum,xNum,yNum,faiNumNum,afaNum;float beidaNum,aNum,xfaiNum,ydNum,max,pcpfh;float inside(float bNum,float cNum)(int p;float j=0
14、;for(p=1; pNum; p+)j+=cp*bp;return j; int main()int i,j,k,n,index,flag;char conti;conti=;printf(please input data length:n);scanf(%d,&n);printf(please input x and yn);for(i=1; i=n; i+)(printf(x%d=,i);scanf(%f,&xi);printf(y%d=,i);scanf(%f,&yi);while(conti=)(printf(please input compute timen);scanf(%d
15、,&index);pcpfh=0;afa1=0;a0=0;for(i=1; i=n; i+)afa1+=xi;a0+=yi;fai0i=1;)afa1=afa1/n;a0=a0/n;for(i=1; i=n; i+)(fai1i=xi-afa1;)a1=inside(fai1,y)/inside(fai1,fai1);for(k=1; kindex; k+)(for(i=1; i=n; i+)xfaii=xi*faiki;afak+1=inside(faik,xfai)/inside(faik,faik);beidak=inside(faik,faik)/inside(faik-1,faik-
16、1);for(j=1; j=n; j+)faik+1j=(xj-afak+1)*faikj-beidak*faik-1j;ak+1=inside(faik+1,y)/inside(faik+1,faik+1);printf( the result of %d computingn,index);for(i=1; i=index; i+)printf(a%d=%fn,i,ai);for(i=1; i=index; i+)printf(afa%d=%fn,i,afai);for(i=1; i=index; i+)printf(beida%d=%fn,i,beidai);for(i=1; i=n;
17、i+)for(k=0; k=index; k+)si+=ak*faiki;ydi=float(fabs(yi-si);pcpfh+=ydi*ydi;si=0;max=0;for(i=1; imax)max=ydi;flag=i;printf(當(dāng) x=%f 時(shí),偏差最大=%f,偏差平方和為 %fn,xflag,max,pcpfh);printf(continue with space,quit with else button);conti=getchar();conti=getchar();Exp 7#include #include float C(float x)(return(exp(x)/(4+x*x);/return (log(1+x)/(1+x*x);int main()(float a=0,b=1;float h=b-a,M1,M2,s,x;int i;M1=h/2*(C(a)+C(b);for(i=0;i10;i+)printf(h=%f,T=%fn,h,M1);s=0;x=a+hwhile(xb)(s+=C(x);x+=h;M2=M1/2+h/2*s;h/=2;M1=M2;printf(h=%f,T=%fn,h,M1);return 0;Exp 8#include float C(float x,float y)return(x*x-y*y);/ret
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 專業(yè)陽光房設(shè)計(jì)與施工一體化協(xié)議版A版
- 專用商標(biāo)使用許可協(xié)議版B版
- 專業(yè)SaaS服務(wù)提供商協(xié)議范本(2024修訂版)版B版
- 專項(xiàng)咨詢與解決方案服務(wù)協(xié)議版B版
- 二零二四全新旅游服務(wù)雙向保密協(xié)議下載與體驗(yàn)合同3篇
- 二零二五年度綠色能源項(xiàng)目補(bǔ)充合同協(xié)議書2篇
- 2025年度城市綜合體戶外廣告位及攤位聯(lián)合租賃合同4篇
- 2025年休閑娛樂場(chǎng)地租賃合作協(xié)議書4篇
- 2025年度綠色能源項(xiàng)目場(chǎng)地承包經(jīng)營(yíng)合同范本4篇
- 二零二五年度自然人互聯(lián)網(wǎng)金融消費(fèi)合同3篇
- 2025年度土地經(jīng)營(yíng)權(quán)流轉(zhuǎn)合同補(bǔ)充條款范本
- 南通市2025屆高三第一次調(diào)研測(cè)試(一模)地理試卷(含答案 )
- 2025年上海市閔行區(qū)中考數(shù)學(xué)一模試卷
- 2025中國(guó)人民保險(xiǎn)集團(tuán)校園招聘高頻重點(diǎn)提升(共500題)附帶答案詳解
- 0的認(rèn)識(shí)和加、減法(說課稿)-2024-2025學(xué)年一年級(jí)上冊(cè)數(shù)學(xué)人教版(2024)001
- 醫(yī)院安全生產(chǎn)治本攻堅(jiān)三年行動(dòng)實(shí)施方案
- 法規(guī)解讀丨2024新版《突發(fā)事件應(yīng)對(duì)法》及其應(yīng)用案例
- Python試題庫(附參考答案)
- 大斷面隧道設(shè)計(jì)技術(shù)基本原理
- 41某31層框架結(jié)構(gòu)住宅預(yù)算書工程概算表
- 成都市國(guó)土資源局關(guān)于加強(qiáng)國(guó)有建設(shè)用地土地用途變更和
評(píng)論
0/150
提交評(píng)論