public IterateMethod() { Table = new Sol[5]; for(int i=0;i<5;i++) { Table[i] = new Sol(); } Table[0].Eps = 0.01; for(int i=1;i<5;i++) { Table[i].Eps = Table[i-1].Eps * 0.001; } for(int i=0;i<5;i++) { double eps = Table[i].Eps; double xn1 = x0; double xn = Func(xn1); int n = 1; while(Math.Abs(xn-xn1)*q*(1-q)>eps) { xn1 = xn; xn = Func(xn1); n++; } Table[i].X = xn; Table[i].Acc = Math.Abs((xn - xn1) * q * (1 - q)); Table[i].N = n; } }
public TouchingMethod() { Table = new Sol[5]; for (int i = 0; i < 5; i++) { Table[i] = new Sol(); } Table[0].Eps = 0.01; for (int i = 1; i < 5; i++) { Table[i].Eps = Table[i-1].Eps / 1000; } for (int i = 0; i < 5; i++) { double eps = Table[i].Eps; double xn1 = x0; double xn = xn1 - f(xn1) / df(xn1); int n = 1; while (Math.Abs(f(xn)/2.42)> eps) { xn1 = xn; xn = xn1 - f(xn1) / df(xn1); n++; } Table[i].X = xn; Table[i].Acc = Math.Abs(f(xn) / 2.42); Table[i].N = n; } }