static void Main(string[] args) { new TestWebClient(); string str = @"test""test"""; int? x = 2; int xx = x ?? 10; test2 += Program_test; test2(""); test3 += Program_test; test3(""); Program.testEvent= new func1(Program.Program_test); testEvent(""); Program.testEvent = new func1(Program.Program_test1); testEvent(""); TestOut.Delfunc += Program_test; TestOut.Delfunc += Program_test1; TestOut.Delfunc(""); // TestOut.test TestOut.test += Program_test; //TestOut.test(""); Class1 cl = new Class1(); Class2 cl2 = new Class2() { Str = "class2 str", }; func1 fun1 = new func1(Program.testDel); // System.Delegate.re string s = cl.testMethod(par2: "ste", par1: 7, class2: cl2); Console.Read(); }
public double ans1; //решение уравнения с конкретным начальным приближением public NewtonAlg(func1 f, func2 df, double eps, int count) { this.f = f; this.df = df; this.eps = eps; this.count = count; }
//method to implement richardardson extrapolation in 1 dimension public double derivative(func1 f, double x, double dx) { if (dx == 0) { Console.WriteLine("1 dimension Richardson Extrapolation: dx = 0 hence no output produced."); return 0; } else { int ntab = 10; double con = 1.4; double con2 = Math.Sqrt(con); double big = 1000000; double safe = 2.0; int i = 0, j = 0; double err = 0, errt = 0, fac = 0, hh = 0, ans = 0; double[,] a = new double[ntab, ntab]; hh = dx; // first approximation to f'(x) a[0, 0] = (f(x + hh) - f(x - hh)) / (2.0 * hh); err = big; for (i = 1; i < ntab; i++) { hh = hh / con; // approximation to f'(x) with smaller step size a[0, i] = (f(x + hh) - f(x - hh)) / (2.0 * hh); fac = con2; // extrapolate the derivative to higher orders without extra function evaluations for (j = 1; j < ntab; j++) { a[j, i] = (a[j - 1, i] * fac - a[j - 1, i - 1]) / (fac - 1.0); fac = con2 * fac; errt = Math.Max(Math.Abs(a[j, i] - a[j - 1, i]), Math.Abs(a[j, i] - a[j - 1, i - 1])); // compute the new error with the error from the previous step if (errt <= err) { err = errt; // update the derivative estimate ans = a[j, i]; } //end of j for loop which resides in i loop which resides in else section } // if error has increased significantly stop if (Math.Abs(a[i, i] - a[i - 1, i - 1]) >= safe * err) { break; } //end of i for loop which resides in the else section } //Console.WriteLine("The value of the derivative is {0}", ans); return ans; } //end of method }