Exemplo n.º 1
0
        public override double Integrate(double x1, double x2, Equasion equasion, int N)
        {
            if (equasion == null || N == 0)
            {
                throw new ArgumentNullException();
            }
            double h   = (x2 - x1) / N;
            double sum = 0;

            for (int i = 1; i < N; i++)
            {
                sum += equasion.Value(x1 + i * h);
            }
            double result = h * ((equasion.Value(x1) + equasion.Value(x2)) / 2.0 + sum);

            return(result);
        }
Exemplo n.º 2
0
        public override double Integrate(double x1, double x2, Equasion equasion, int N)
        {
            if (equasion == null || N == 0)
            {
                throw new ArgumentNullException();
            }
            else if (x1 >= x2)
            {
                throw new ArgumentException("Pravaya graniza integrirovaniya doljna bit bolshe levoy!");
            }
            double h   = (x2 - x1) / N;
            double sum = 0;

            for (int i = 0; i < N; i++)
            {
                sum = sum + equasion.Value(x1 + i * h) * h;
            }
            return(sum);
        }