Exemplo n.º 1
0
        public void S_xx_10_0()
        {
            //arrange
            double      expected = -333.333;
            double      a        = 10;
            double      b        = 0;
            int         n        = 10000;
            ICalculator calcul   = new Simpson();

            //act
            double actual = calcul.Calculate(a, b, n, x => x * x);

            //assert
            Assert.AreEqual(expected, actual, 0.001);
        }
Exemplo n.º 2
0
        public void S_Step_0()
        {
            //arrange
            double      expected = 0;
            double      a        = 10;
            double      b        = 10;
            int         n        = 10000;
            ICalculator calcul   = new Simpson();

            //act
            double actual = calcul.Calculate(a, b, n, x => x * x);

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void Simpson_Integrate_with_switched_variables()
        {
            //arrange
            double  expected        = -333_333.3333;
            double  a               = 100;
            double  b               = 0;
            long    n               = 100000;
            Simpson simpson         = new Simpson();
            Func <double, double> f = x => x * x;

            //act
            double actual = simpson.Calculate(a, b, n, f);

            //assert
            Assert.AreEqual(expected, actual, 0.0001);
        }
Exemplo n.º 4
0
        public void Simpson_Intergrate_xx_Gives_Correct_Result()
        {
            //arrange
            double  expected        = 333_333.3333;
            double  a               = 0;
            double  b               = 100;
            long    n               = 100000;
            Simpson simpson         = new Simpson();
            Func <double, double> f = x => x * x;

            //act
            double actual = simpson.Calculate(a, b, n, f);

            //assert

            Assert.AreEqual(expected, actual, 0.0001);
        }