public double IntegralMonteCarlo(double a, double b, double c, double d, int n) { double x, y; double result = 0.0; RandomMonteCarlo rand = new RandomMonteCarlo(); for (int i = 0; i < n; i++) { x = rand.Next(); y = rand.Next(); result += (b - a) * (d - c) * f(a + (b - a) * x, c + (d - c) * y); } return (result / n); }