Example #1
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());
        }
Example #2
0
        public void CosDerivativeTest3()
        {
            // cos(2x)
            var num = new Number(2);
            var x = new Variable("x");
            var mul = new Mul(num, x);

            var exp = new Cos(mul);
            var deriv = Differentiate(exp);

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

            num.Value = 7;
            Assert.Equal("cos(7 * x)", exp.ToString());
            Assert.Equal("-(sin(2 * x) * 2 * 1)", deriv.ToString());
        }