Пример #1
0
        public void DerivativeTest2()
        {
            IExpression exp = new Cos(new Mul(new Number(2), new Variable("x")));
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("-(sin(2 * x) * (2 * 1))", deriv.ToString());
        }
Пример #2
0
        public void DerivativeTest1()
        {
            IExpression exp = new Cos(new Variable("x"));
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("-(sin(x) * 1)", deriv.ToString());
        }
Пример #3
0
        public void DerivativeTest3()
        {
            // cos(2x)
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Cos(mul);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("-(sin(2 * x) * (2 * 1))", deriv.ToString());

            num.Value = 7;
            Assert.AreEqual("cos(7 * x)", exp.ToString());
            Assert.AreEqual("-(sin(2 * x) * (2 * 1))", deriv.ToString());
        }
Пример #4
0
 public void PartialDerivativeTest3()
 {
     IExpression exp = new Cos(new Variable("x"));
     IExpression deriv = exp.Differentiate(new Variable("y"));
     Assert.AreEqual("0", deriv.ToString());
 }
Пример #5
0
 public void PartialDerivativeTest2()
 {
     IExpression exp = new Cos(new Mul(new Variable("x"), new Variable("y")));
     IExpression deriv = exp.Differentiate(new Variable("y"));
     Assert.AreEqual("-(sin(x * y) * (x * 1))", deriv.ToString());
 }