




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1)用高斯列主元消元法求解下面的方程组#include #include #include using namespace std;int main()/double a45=1,-1,1,-4,2, 5,-4,3,12,4, 2, 1,1,11,3, 2,-1,7,-1,0;/int i,j,k;int Line,Row;double temp45;/中间量Row=4;Line=5;/Inintial/Result/double X5;cout最初的矩阵为:endl;for(i=0;i4;i+)for(j=0;j5;j+)coutaij ;coutendl;coutendl;/for(k=0;kRow-1;k+)/for(i=k+1;iRow;i+)/tempik=aik/akk;for(j=k;jLine;j+)aij-=tempik*akj;/cout经过消元后的增广矩阵为:endl;for(i=0;i4;i+)for(j=0;j5;j+)coutaij ;coutendl;cout=0;i-)/double temp_new;temp_new=0;for(j=i+1;j=Row-1;j+)aiRow-=aij*ajRow;aiRow/=aii;/Print;cout最后的解为:endl;for(i=0;iRow;i+)/coutXi+1=aiRowendl;/return 0;1.2 列主元方法#include #include #include using namespace std;void Print(double a5)int i,j;for(i=0;i4;i+)for(j=0;j5;j+)coutaij ;coutendl;coutendl;int main()/double a45=1,-1,1,-4,2, 5,-4,3,12,4, 2, 1,1,11,3, 2,-1,7,-1,0;/double b45=0.3e-15,int i,j,k,n;int Line,Row;double temp45;/中间量Row=4;Line=5;/Inintial/cout最初的矩阵为:endl;Print(a);/the main process is underint kk;/flagsdouble max; /bool flag=false;double t;/the temp of change;for(k=0;kRow-1;k+)/search the max_num/flag=false;max=akk;kk=k;for(i=k;imax)max=aik;kk=i;/flag=true;/change the linefor(j=0;jLine;j+)t=akj;akj=akkj;akkj=t;cout第k+1次换行结果:endl;Print(a);coutendl;cout第k+1次消元结果:endl;/消元的过程for(i=k+1;iRow;i+)/tempik=aik/akk;for(j=k;j=0;i-) / double temp_new; temp_new=0; for(j=i+1;j=n;j+) ain+1-=aij*ajn+1; ain+1/=aii;/cout经过消元后的增广矩阵为:endl;Print(a);/Print;cout最后的解为:endl;for(i=0;iRow;i+)/coutXi+1=aiRowendl;/return 0;2)分别用列主元消元法与不选主元消元法求解,分析对结果的影响#include #include #include using namespace std;void Print(double b5)int i,j;for(i=0;i4;i+)for(j=0;j5;j+)coutbij ;coutendl;coutendl;int main()double b45=0.3e-15,59.14,3,1,59.17, 5.291,-6.130,-1,2,46.78,11.2,9,5,2,1,1,2,1,1,2; int i,j,k,n;int Line,Row;double temp45;/中间量Row=4;Line=5;/Inintial/cout最初的矩阵为:endl;Print(b);/the main process is underint kk;/flagsdouble max; /bool flag=false;double t;/the temp of change;for(k=0;kRow-1;k+)/search the max_num/flag=false;max=bkk;kk=k;for(i=k;imax)max=bik;kk=i;/flag=true;/change the linefor(j=0;jLine;j+)t=bkj;bkj=bkkj;bkkj=t;cout第k+1次换行结果:endl;Print(b);coutendl;cout第k+1次消元结果:endl;/消元的过程for(i=k+1;iRow;i+)/tempik=bik/bkk;for(j=k;j=0;i-) / double temp_new; temp_new=0; for(j=i+1;j=n;j+) bin+1-=bij*bjn+1; bin+1/=bii;/cout经过消元后的增广矩阵为:endl;Print(b);/Print;cout最后的解为:endl;for(i=0;iRow;i+)/coutXi+1=biRowendl;/return 0;2、 用迭代法求解 (迭代法收敛速度实验)注意修改不同的A 、B的数组3、 /雅可比迭代法/* auther luozhengxiao*/#include #include #include using namespace std;/void Print(double x)for(int i=0;i3;i+)coutsetprecision(8)fixedxiendl;int main()/double B13=-3,2,4; double B23=100,-200,345; double A33=6,2,-1, 1,4,-2,-3,1,4; double x3,x_old3,temp;int i,j,k;for(i=0;i3;i+)cout请输入第i+1个数:;coutt xixi;/x_oldi=xi;int n;coutn;/for(k=0;kn;k+
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司松香工安全规范考核试卷及答案
- 铝土矿生产调度与质量控制方案
- 公司锻件清理工基础考核试卷及答案
- 公司数控车工协作考核试卷及答案
- 室内照明环境改进实施方案
- 建设项目勘察设计优化方案
- 政务服务笔试试题及答案
- 新生开学中医知识培训课件
- 2025江苏中国矿业大学徐海学院招聘专任教师1人考前自测高频考点模拟试题及1套参考答案详解
- 聚醚电子新材料生产线项目建设工程方案
- Creo软件基础操作培训
- 农村房产放弃协议书
- 企业内部控制培训课件
- 化物所员工安全教育考试题库
- 迎接本科教育教学审核评估
- 装卸设备安全管理制度
- 做有温度的护理人
- 消防文员的考试题及答案
- 贵州文物调查研究-从文物看中华民族共同体历史的区域实践知到智慧树章节测试课后答案2024年秋贵州民族大学
- 带状疱疹中医治疗方案
- 2024−2025学年高二上学期第一次月考数学试题含答案
评论
0/150
提交评论