Пример #1
0
 public void PartialDerivativeTest2()
 {
     // (yx) ^ 3
     IExpression exp = new Pow(new Mul(new Variable("y"), new Variable("x")), new Number(3));
     IExpression deriv = exp.Differentiate(new Variable("y"));
     Assert.AreEqual("(1 * x) * (3 * ((y * x) ^ (3 - 1)))", deriv.ToString());
 }
Пример #2
0
        public void DerivativeTest3()
        {
            // x ^ 3
            Variable x = new Variable("x");
            Number num1 = new Number(3);

            IExpression exp = new Pow(x, num1);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("1 * (3 * (x ^ (3 - 1)))", deriv.ToString());

            num1.Value = 4;
            Assert.AreEqual("x ^ 4", exp.ToString());
            Assert.AreEqual("1 * (3 * (x ^ (3 - 1)))", deriv.ToString());

            // 2 ^ (3x)
            Number num2 = new Number(2);
            num1 = new Number(3);
            Mul mul = new Mul(num1, x.Clone());

            exp = new Pow(num2, mul);
            deriv = exp.Differentiate();

            Assert.AreEqual("(ln(2) * (2 ^ (3 * x))) * (3 * 1)", deriv.ToString());

            num1.Value = 4;
            Assert.AreEqual("2 ^ (4 * x)", exp.ToString());
            Assert.AreEqual("(ln(2) * (2 ^ (3 * x))) * (3 * 1)", deriv.ToString());
        }
Пример #3
0
        public void DerivativeTest1()
        {
            IExpression exp = new Pow(new Variable("x"), new Number(3));
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("1 * (3 * (x ^ (3 - 1)))", deriv.ToString());
        }
Пример #4
0
        public void DerivativeTest2()
        {
            // 2 ^ (3x)
            IExpression exp = new Pow(new Number(2), new Mul(new Number(3), new Variable("x")));
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(ln(2) * (2 ^ (3 * x))) * (3 * 1)", deriv.ToString());
        }
Пример #5
0
 public void PartialDerivativeTest3()
 {
     IExpression exp = new Pow(new Variable("x"), new Number(3));
     IExpression deriv = exp.Differentiate(new Variable("y"));
     Assert.AreEqual("0", deriv.ToString());
 }