logo资料库

数值计算实验报告.docx

第1页 / 共13页
第2页 / 共13页
第3页 / 共13页
第4页 / 共13页
第5页 / 共13页
第6页 / 共13页
第7页 / 共13页
第8页 / 共13页
资料共13页,剩余部分请下载后查看
列选主元消元法: 程序主要代码: public class Guass { void gauss(double a[][],int m,int n,double p[]){ for(int x=0;xmax){ row=y; } } if(row!=x){//行交换 for(int i=0;i=0;i--){ p[i]=t/a[i][i]; if(i<1) break; t=a[i-1][m];
for(int j=0;j
} else l[i][k]=0; } } for(i=0;i
} } } 程序运行结果: 实验小结: 本次实验中理解了 gausss 消元以及三角分解解线性方程组的方法。
拉格朗日插值法: 程序主要代码: public class lagrange { public double lag(int n,double X[],double Y[],double x){ double result = 0; for(int i=0;i
牛顿插值法: 程序主要代码: public class newton { public double ChaShang(int n,double X[],double Y[]){ double f=0; double temp=0; for(int i=0;i
程序运行结果; 实验小结: 本次实验中掌握了用拉格朗日插值法以及牛顿插值法构造插值多项 式,掌握了代码中求差商的优化方法。
变步长梯形法: 程序主要代码: public class Multy { double function(double x){ if (x == 0.00000) return 1.0000; return Math.sin(x) / x; } double Multy(double a, double b, double eps){ double[] T = new double[2]; double h = b - a; T[0] = (function(a) + function(b))*h / 2; System.out.println(T[0]); int n = 1; do { T[1] = 0.0; for (int i = 0; i < n; i++){ T[1] += function(a + (0.5 + i)*h); } T[1] = (T[0] + h*T[1]) / 2.0; T[1] -= T[0]; T[0] += T[1]; T[1] = Math.abs(T[1]); n *= 2; h /= 2.0; } while (T[1] > eps); return T[0]; } }
分享到:
收藏