资源预览内容
第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
亲,该文档总共4页全部预览完了,如果喜欢就下载吧!
资源描述
分别用雅可比、高斯塞达尔、超松弛法解方程组。精度:0.001 。 5*x1 + 2*x2+ x*3=-12 -x1 + x*2+ 2*x3= 20 2*x1 -*3x2 +10*x3= 31: 雅可比迭代法(雅可比迭代法(Jacobi):): /* 5*x1 + 2*x2+ x*3=-12 -x1 + x*2+ 2*x3= 20 2*x1 -*3x2 +10*x3= 3 */#include “math.h“#include “stdio.h“main()double a33=5.0,2.0,1.0,-1.0,4.0,2.0,2.0,-3.0,10.0;double x3=0.0,0.0,0.0,y3,b3=-12.0,20.0,3.0;double eps=0.001,e,q,t,s;int i,j,k,N=0;e=eps+1.0;while (e=eps) N+; e=0.0; for(k=0;ke)e=q; printf(“n“);2: 高斯赛德尔迭代法(高斯赛德尔迭代法(G-S)/* 5*x1 + 2*x2+ x*3=-12 -x1 + x*2+ 2*x3= 20 2*x1 -*3x2 +10*x3= 3 */#include “math.h“#include “stdio.h“main()double a33=5.0,2.0,1.0,-1.0,4.0,2.0,2.0,-3.0,10.0;double x3=0.0,0.0,0.0,b3=-12.0,20.0,3.0;double eps=0.001,e,q,t,s;int i,j,k,N=0;e=eps+1.0;while (e=eps) N+; e=0.0;for (i=0; ie)e=q; printf(“n“);3: 逐次超松弛迭代法(逐次超松弛迭代法(SOR):):/* 5*x1 + 2*x2+ x*3=-12 -x1 + x*2+ 2*x3= 20 2*x1 -*3x2 +10*x3= 3 */#include “math.h“#include “stdio.h“main()double a33=5.0,2.0,1.0,-1.0,4.0,2.0,2.0,-3.0,10.0;double x3=0.0,0.0,0.0,b3=-12.0,20.0,3.0;double eps=0.001,e,q,t,s;double w=1.15;int i,j,k,N=0;printf(“w=%fn“,w);e=eps+1.0;while (e=eps) N+; e=0.0;for (i=0; ie)e=q; printf(“n“);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号