void CalculGaussCoefs(int N, out double[] LegendreRoots, out double[] GaussCoefs) { LegendrePolynom Polynom = new LegendrePolynom(N, 1e-9); double[,] Matrix = new double[N, N + 1]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i == 0) { Matrix[i, j] = 1; } else { Matrix[i, j] = Math.Pow(Polynom.Roots[j], i); } } if (i % 2 == 0) { Matrix[i, N] = 2.0 / (i + 1); } else { Matrix[i, N] = 0; } } GaussCoefs = SLE.GaussSolve(Matrix, N); LegendreRoots = Polynom.Roots; }
static double Gauss(double p) { double Result = 0; double[,] Matrix = new double[N, N + 1]; LegendrePolynom.GetValueAt(0); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (i == 0) { Matrix[i, j] = 1; } else { Matrix[i, j] = Math.Pow(LegendrePolynom.Roots[j], i); } } if (i % 2 == 0) { Matrix[i, N] = 2.0 / (i + 1); } else { Matrix[i, N] = 0; } } double[] ResultColumn = SLE.GaussSolve(Matrix, N); for (int i = 0; i < N; i++) { double z = 0.5 + LegendreCoefs[i] * 0.5; Result += ResultColumn[i] * Integrand(p, z); } Result *= 0.5; return(Result); }