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()); }
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()); }
public void AbsToStringTest() { var exp = new Abs(new ComplexNumber(3, 2)); Assert.Equal("abs(3+2i)", exp.ToString()); }
public void PartialDerivativeTest3() { IExpression deriv = new Abs(new Variable("x")).Differentiate(new Variable("y")); Assert.AreEqual("0", deriv.ToString()); }
public void DerivativeTest1() { IExpression exp = new Abs(new Variable("x")).Differentiate(); Assert.AreEqual("1 * (x / abs(x))", exp.ToString()); }