public static void MethodTeilor(double x0, double y0, double h, int n) { DFun f = new DFun(y0); int l = 0; for (int i = -2; i <= 2; ++i) { xx[l] = x0 + i * h; for (int j = 0; j <= 5; ++j) { yy[l] += f.Reval(j) / (factorial(j)) * Math.Pow(xx[l] - x0, j); } ++l; } Console.WriteLine(" X Y R"); for (int i = 0; i <= 4; ++i) { if (xx[i] < 0) Console.Write("{0:f6}", xx[i]); else Console.Write(" {0:f6}", xx[i]); if (yy[i] < 0) Console.Write("{0:f6} ", yy[i]); else Console.Write(" {0:f6} ", yy[i]); Console.WriteLine("{0:f8}", f.Reval(6) / factorial(6) * Math.Pow(Math.Abs(xx[i] - x0), 6)); } }
public static void Ailer3(double x0, double y0, double h, int n) { double[] x = new double[2 * n]; double[] y = new double[2 * n]; x[0] = x0; y[0] = y0; for (int i = 1; i <= n; ++i) { x[i] = x[i - 1] + h; Fun f1 = new Fun(y[i - 1]); Fun f = new Fun(y[i - 1] + h * f1.ReVal()); y[i] = y[i - 1] + h/2 * (f1.ReVal() + f.ReVal()); } DFun g = new DFun(y0); Console.WriteLine(" X Y R"); for (int i = 0; i <= n; ++i) { double ri = Math.Abs(r[i] - y[i]); if (x[i] < 0) Console.Write("{0:f6}", x[i]); else Console.Write(" {0:f6}", x[i]); if (y[i] < 0) Console.Write("{0:f6} ", y[i]); else Console.Write(" {0:f6} ", y[i]); Console.WriteLine("{0:f8}", ri); } }