/// <summary> /// Вычисление криволинейного интеграла первого рода по этой кривой от функции f методом трапеции /// </summary> /// <param name="f"></param> /// <returns></returns> public double FirstkindTr(Functional f)//(в программе не используется) { Get_h(ITER_INTEG); double value = 0; for (int k = 0; k <= M - 1; k++) { value += f(Transfer((a + (k + 1) * _h + a + (k) * _h) / 2)) * Point.Eudistance(Transfer(a + (k + 1) * _h), Transfer(a + (k) * _h)); } return(value); }
/// <summary> /// Создержит ли круг точку (взято с запасом) /// </summary> /// <param name="p"></param> /// <param name="RadiusCoef">Коэффициент определяющий, сколько радиусов от центра круга считаются собственностью окружности</param> /// <returns></returns> public bool ContainPoint(Point p, double RadiusCoef = 2.0) => Point.Eudistance(p, this.center) < this.radius * RadiusCoef;
public void UpVal() { double rr = 1; Curve c = new Curve(0, 2 * Math.PI, (double t, double r) => r * Math.Cos(t), (double t, double r) => r * Math.Sin(t), rr); c.S = (double tx, double ty, double r) => tx * ty * r; c.End = (double r) => 2 * Math.PI; //Functional mp = (Point g) => 1; //DoubleIntegral(mp, c, c.S, parallel: true, cy: 300, M: Method.GaussKronrod61).Show(); Func <Point, int, double> ro = (Point p, int k) => { var cc = new Complex(p.x, p.y); return(Math.Pow(cc.Abs, k) * Math.Cos(k * cc.Arg)); }; Func <Point, Point, double> E = (Point x, Point y) => Math.Log(Point.Eudistance(x, y)); int xc = 100, yc = 100; double x0 = -8, X = 8, y0 = -8, Y = 8; double hx = (X - x0) / (xc - 1), hy = (Y - y0) / (yc - 1); double[] xa = new double[xc], ya = new double[yc]; for (int i = 0; i < xc; i++) { xa[i] = x0 + hx * i; } for (int i = 0; i < yc; i++) { ya[i] = y0 + hy * i; } int[] kk = new int[] { 3, 5, 25, 50, 200, 500 }; double[][,] val = new double[kk.Length][, ]; for (int i = 0; i < kk.Length; i++) { val[i] = new double[xc, yc]; Functional fl = (Point x) => { Functional tmp = (Point y) => ro(y, kk[i]) * E(x, y); return(DoubleIntegral(tmp, c, c.S, parallel: true, cy: 200, M: Method.GaussKronrod61)); }; Functional fl2 = (Point x) => { Complex z = new Complex(x.x, x.y); Functional tmp = (Point y) => { Complex w = new Complex(y.x, y.y); return(Math.Pow(w.Abs, kk[i]) * Math.Cos(kk[i] * (w.Arg)) * Math.Log(z.Abs.Sqr() + w.Abs.Sqr() - 2 * z.Abs * w.Abs * Math.Cos(w.Arg))); }; return(DoubleIntegral(tmp, c, c.S, parallel: true, cy: 200, M: Method.GaussKronrod61) / 2 * Math.Cos(kk[i] * z.Arg)); }; Functional fr = (Point x) => { Complex z = new Complex(x.x, x.y); return(Math.PI * Math.Cos(kk[i] * z.Arg) / (kk[i] + 2) * Math.Max(Math.Log((z.Abs - 1).Sqr()).Abs(), Math.Log((z.Abs + 1).Sqr()).Abs())); }; for (int ix = 0; ix < xc; ix++) { for (int iy = 0; iy < yc; iy++) { Point t = new Point(xa[ix], ya[iy]), o = new Point(0); double rad = Point.Eudistance(t, o); // $"t = {t} fr = {fr(t)} fl = {fl(t)}".Show(); //$"{fl(t)} {fl2(t)}".Show(); //Assert.IsTrue((fl(t) - fl2(t)).Abs() < 1e-7); if (rad > 1.0) { val[i][ix, iy] = fr(t).Abs() - fl(t).Abs(); } else { val[i][ix, iy] = Double.NaN; } } } } StreamWriter args = new StreamWriter("arg.txt"); StreamWriter vals = new StreamWriter("vals.txt"); for (int i = 0; i < xc; i++) { args.WriteLine($"{xa[i]} {ya[i]}"); } for (int i = 0; i < xc; i++) { for (int j = 0; j < yc; j++) { string st = ""; for (int s = 0; s < kk.Length; s++) { st += (val[s][i, j] + " "); } vals.WriteLine(st.Replace("NaN", "NA")); } } args.Close(); vals.Close(); }