




已阅读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年智能化医疗器械安装与运营维护综合服务合同
- 2025年食品添加剂生产与使用安全监管合作协议
- 2025年节能环保型锅炉购置及安装与长期维护服务合同
- 2025年度新型疫苗研发风险管理及采购供应合作协议
- 2025年度茶叶种植基地承包与加工厂生产合作协议
- 2025年度甲级办公楼智能化清洁保养与能源管理服务合同
- 2025社区医疗站点医师派遣及家庭医生签约服务合作协议
- 2025年环保型自来水厂能效提升改造项目合同协议
- 音乐节年度艺人演出代理服务框架合同
- 2025年春季时尚周展览工程及专业灯光音响设备租赁服务合同
- 保洁大理石清洗合同范例
- 碎石买卖合同
- 2025年上海市劳务合同经典版(2篇)
- 家庭教育中的家庭规则制定
- 2025届云南省高三高考备考数学模拟检测试卷(含解析)
- 碳中和技术概论 课件 第4、5章 氢能、生物质能
- 降低患者跌倒的发生率
- 非参数统计方法创新
- 老年人排泄护理课件
- 药品经营和使用质量监督管理办法
- 中考英语高频单词(背诵版)
评论
0/150
提交评论