public void DIntegralTestx2_1to2()
        {
            // p(x) = x^2
            // ∫_1^2(x^2dx) == [x^3/3]_{x=1}^2 = (8-1)/3 = 7/3

            var    p = new RealPolynomial(new double[] { 0, 0, 1 });
            double r = p.Integral(1, 2);

            Assert.IsTrue(IsSimilar(r, 7.0 / 3.0));
        }
        public void DIntegralTestx3px2_2to5()
        {
            // p(x) = x^3 + x^2
            // ∫_2^5(x^3+x^2)dx == [x^4/4+x^3/3]_{x=2}^5 = 765/4

            var    p = new RealPolynomial(new double[] { 0, 0, 1, 1 });
            double r = p.Integral(2, 5);

            Assert.IsTrue(IsSimilar(r, 765.0 / 4.0));
        }
        public void DIntegralTestx2_0to1()
        {
            // p(x) = x^2
            // ∫_0^1(x^2dx) == [x^3/3]_{x=0}^1 = 1/3

            var    p = new RealPolynomial(new double[] { 0, 0, 1 });
            double r = p.Integral(0, 1);

            Assert.IsTrue(IsSimilar(r, 1.0 / 3.0));
        }
        public void DIntegralTestx_0to1()
        {
            // p(x) = x
            // ∫_0^1(xdx) == [x^2/2]_{x=0}^1 = 1/2

            var    p = new RealPolynomial(new double[] { 0, 1 });
            double r = p.Integral(0, 1);

            Assert.IsTrue(IsSimilar(r, 1.0 / 2.0));
        }
        public void DIntegralTestx_1to2()
        {
            // p(x) = x
            // ∫_1^2(xdx) == [x^2/2]_{x=1}^2 = (4-1)/2 = 3/2

            var    p = new RealPolynomial(new double[] { 0, 1 });
            double r = p.Integral(1, 2);

            Assert.IsTrue(IsSimilar(r, 3.0 / 2.0));
        }
        public void DIntegralTest2_4to3()
        {
            // p(x) = 2
            // ∫_4^3(2dx) == [2x]_{x=4}^3 = (6-8) = -2

            var    p = new RealPolynomial(new double[] { 2 });
            double r = p.Integral(4, 3);

            Assert.IsTrue(IsSimilar(r, -2.0));
        }
        public void DIntegralTest2_3to4()
        {
            // p(x) = 2
            // ∫_3^4(2dx) == [2x]_{x=3}^4 = (8-6) = 2

            var    p = new RealPolynomial(new double[] { 2 });
            double r = p.Integral(3, 4);

            Assert.IsTrue(IsSimilar(r, 2.0));
        }
        public void IIntegralTestx()
        {
            // p(x) = x
            // ∫xdx == [x^2/2] +C

            double C  = 1.0;
            var    p  = new RealPolynomial(new double[] { 0, 1 });
            var    pI = new RealPolynomial(new double[] { C, 0, 1.0 / 2.0 });

            var r = p.Integral(C);

            Assert.IsTrue(IsSimilar(r, pI));
        }
        public void IIntegralTest2()
        {
            // p(x) = 2
            // ∫(2)dx == [2x] +C

            double C  = 1.0;
            var    p  = new RealPolynomial(new double[] { 2 });
            var    pI = new RealPolynomial(new double[] { C, 2 });

            var r = p.Integral(C);

            Assert.IsTrue(IsSimilar(r, pI));
        }