Пример #1
0
        public void ContentAllNegative()
        {
            var p = new PolyL(-3, -6, -6);
            var n = p.Content();

            Assert.AreEqual(-3, n);
        }
Пример #2
0
        public void FactorsNoContent()
        {
            var p = new PolyL(2, 3).Factors().ToList();

            Assert.AreEqual(1, p.Count);
            Assert.AreEqual(new PolyL(2, 3), p[0]);
        }
Пример #3
0
        public void ContentWithZeros()
        {
            var p = new PolyL(2, 0, 4, 0, 2);
            var n = p.Content();

            Assert.AreEqual(2, n);
        }
Пример #4
0
        public void ContentAllPositive()
        {
            var p = new PolyL(3, 9, 6);
            var n = p.Content();

            Assert.AreEqual(3, n);
        }
Пример #5
0
        public void ContentMixed()
        {
            var p = new PolyL(3, -9, 6);
            var n = p.Content();

            Assert.AreEqual(3, n);
        }
Пример #6
0
        public void Derivative()
        {
            var p = new PolyL(5, -4, 3, -2, 1);
            var d = p.Derivative();

            Assert.AreEqual(new PolyL(-4, 6, -6, 4), d);
        }
Пример #7
0
        public void Evaluate()
        {
            var p = new PolyL(60, -37, -25, 1, 1);
            var x = p.At(-7);

            Assert.AreEqual(60 - 7 * (-37 - 7 * (-25 - 7 * (1 - 7))), x);
        }
Пример #8
0
        public void FactorWithMonomial()
        {
            var p = new PolyL(0, 2, 4).Factors().ToList();

            Assert.AreEqual(2, p.Count);
            Assert.AreEqual(new PolyL(0, 2), p[0]);
            Assert.AreEqual(new PolyL(1, 2), p[1]);
        }
Пример #9
0
        public void Subtract()
        {
            var a = new PolyL(3, 1);
            var b = new PolyL(-1, 1);
            var c = new PolyL(4, 1);
            var d = new PolyL(-5, 1);
            var p = a * b - c * d;

            Assert.AreEqual("17 + 3𝑛", p.ToString());
        }
Пример #10
0
        public void Multiply()
        {
            var a = new PolyL(3, 1);
            var b = new PolyL(-1, 1);
            var c = new PolyL(4, 1);
            var d = new PolyL(-5, 1);
            var p = a * b * c * d;

            Assert.AreEqual("60 − 37𝑛 − 25𝑛² + 𝑛³ + 𝑛⁴", p.ToString());
        }
Пример #11
0
        public void DivNoRem()
        {
            var x = new PolyL(2, 1);
            var y = new PolyL(1, -5, 3);
            var p = x * y;  // (2 + n)(1 - 5n + 3n^2) = 2 - 9n + n^2 + 3n^3
            var d = p.DivRem(x, out var r);

            Assert.AreEqual(y, d);
            Assert.AreEqual(PolyL.Zero, r);
            d = p.DivRem(y, out r);
            Assert.AreEqual(x, d);
            Assert.AreEqual(PolyL.Zero, r);
        }
Пример #12
0
        public void DivRem()
        {
            var x = new PolyL(2, 1);
            var y = new PolyL(1, -5, 3);
            var z = new PolyL(7);
            var p = x * y + z;  // (2 + n)(1 - 5n + 3n^2) + 7 = 9 - 9n + n^2 + 3n^3
            var d = p.DivRem(x, out var r);

            Assert.AreEqual(y, d);
            Assert.AreEqual(z, r);
            d = p.DivRem(y, out r);
            Assert.AreEqual(x, d);
            Assert.AreEqual(z, r);
        }
Пример #13
0
        public void PrimitivePart()
        {
            var p = new PolyL(3, 0, -6, 6).PrimitivePart();

            Assert.AreEqual(new PolyL(1, 0, -2, 2), p);
        }
Пример #14
0
        public void Pow()
        {
            var p = new PolyL(-3, 1) ^ 7;

            Assert.AreEqual(new PolyL(-2187, 5103, -5103, 2835, -945, 189, -21, 1), p);
        }