示例#1
0
        public void AbsDerivativeTest2()
        {
            var num = new Number(2);
            var x = new Variable("x");
            var mul = new Mul(num, x);

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

            Assert.Equal("2 * 1 * ((2 * x) / abs(2 * x))", deriv.ToString());

            num.Value = 3;
            Assert.Equal("abs(3 * x)", exp.ToString());
            Assert.Equal("2 * 1 * ((2 * x) / abs(2 * x))", deriv.ToString());
        }
示例#2
0
        public void AbsDerivativeTest2()
        {
            Number num = new Number(2);
            Variable x = new Variable("x");
            Mul mul = new Mul(num, x);

            IExpression exp = new Abs(mul);
            IExpression deriv = Differentiate(exp);

            Assert.AreEqual("(2 * 1) * ((2 * x) / abs(2 * x))", deriv.ToString());

            num.Value = 3;
            Assert.AreEqual("abs(3 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) * ((2 * x) / abs(2 * x))", deriv.ToString());
        }
示例#3
0
        public void AbsToStringTest()
        {
            var exp = new Abs(new ComplexNumber(3, 2));

            Assert.Equal("abs(3+2i)", exp.ToString());
        }
示例#4
0
 public void PartialDerivativeTest3()
 {
     IExpression deriv = new Abs(new Variable("x")).Differentiate(new Variable("y"));
     Assert.AreEqual("0", deriv.ToString());
 }
示例#5
0
        public void DerivativeTest1()
        {
            IExpression exp = new Abs(new Variable("x")).Differentiate();

            Assert.AreEqual("1 * (x / abs(x))", exp.ToString());
        }