Changeset 18120 for branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4
- Timestamp:
- 12/15/21 09:53:31 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3140_NumberSymbol/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs
r17180 r18120 35 35 var formatter = new InfixExpressionFormatter(); 36 36 var parser = new InfixExpressionParser(); 37 Assert.AreEqual("0", Derive(" 3", "x"));37 Assert.AreEqual("0", Derive("<num=3>", "x")); 38 38 Assert.AreEqual("1", Derive("x", "x")); 39 Assert.AreEqual("10", Derive(" 10*x", "x"));40 Assert.AreEqual("10", Derive("x* 10", "x"));39 Assert.AreEqual("10", Derive("<num=10>*x", "x")); 40 Assert.AreEqual("10", Derive("x*<num=10>", "x")); 41 41 Assert.AreEqual("(2*'x')", Derive("x*x", "x")); 42 42 Assert.AreEqual("((('x' * 'x') * 2) + ('x' * 'x'))", Derive("x*x*x", "x")); // simplifier does not merge (x*x)*2 + x*x to 3*x*x 43 Assert.AreEqual("0", Derive(" 10*x", "y"));44 Assert.AreEqual("20", Derive(" 10*x+20*y", "y"));45 Assert.AreEqual("6", Derive(" 2*3*x", "x"));46 Assert.AreEqual("(10*'y')", Derive(" 10*x*y+20*y", "x"));43 Assert.AreEqual("0", Derive("<num=10>*x", "y")); 44 Assert.AreEqual("20", Derive("<num=10>*x+<num=20>*y", "y")); 45 Assert.AreEqual("6", Derive("<num=2>*<num=3>*x", "x")); 46 Assert.AreEqual("(10*'y')", Derive("<num=10>*x*y+<num=20>*y", "x")); 47 47 Assert.AreEqual("(1 / (SQR('x') * (-1)))", Derive("1/x", "x")); 48 48 Assert.AreEqual("('y' / (SQR('x') * (-1)))", Derive("y/x", "x")); … … 51 51 Assert.AreEqual("((((-2*'x') + (-1)) * ('a' + 'b')) / SQR(('x' + SQR('x'))))", Derive("(a+b)/(x+SQR(x))", "x")); 52 52 Assert.AreEqual("EXP('x')", Derive("exp(x)", "x")); 53 Assert.AreEqual("(EXP((3*'x')) * 3)", Derive("exp( 3*x)", "x"));53 Assert.AreEqual("(EXP((3*'x')) * 3)", Derive("exp(<num=3>*x)", "x")); 54 54 Assert.AreEqual("(1 / 'x')", Derive("log(x)", "x")); 55 Assert.AreEqual("(1 / 'x')", Derive("log( 3*x)", "x")); // 3 * 1/(3*x)56 Assert.AreEqual("(1 / ('x' + (0.333333333333333*'y')))", Derive("log( 3*x+y)", "x")); // simplifier does not try to keep fractions57 Assert.AreEqual("(1 / (SQRT(((3*'x') + 'y')) * 0.666666666666667))", Derive("sqrt( 3*x+y)", "x")); // 3 / (2 * sqrt(3*x+y)) = 1 / ((2/3) * sqrt(3*x+y))58 Assert.AreEqual("(COS((3*'x')) * 3)", Derive("sin( 3*x)", "x"));59 Assert.AreEqual("(SIN((3*'x')) * (-3))", Derive("cos( 3*x)", "x"));60 Assert.AreEqual("(1 / (SQR(COS((3*'x'))) * 0.333333333333333))", Derive("tan( 3*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator55 Assert.AreEqual("(1 / 'x')", Derive("log(<num=3>*x)", "x")); // 3 * 1/(3*x) 56 Assert.AreEqual("(1 / ('x' + (0.333333333333333*'y')))", Derive("log(<num=3>*x+y)", "x")); // simplifier does not try to keep fractions 57 Assert.AreEqual("(1 / (SQRT(((3*'x') + 'y')) * 0.666666666666667))", Derive("sqrt(<num=3>*x+y)", "x")); // 3 / (2 * sqrt(3*x+y)) = 1 / ((2/3) * sqrt(3*x+y)) 58 Assert.AreEqual("(COS((3*'x')) * 3)", Derive("sin(<num=3>*x)", "x")); 59 Assert.AreEqual("(SIN((3*'x')) * (-3))", Derive("cos(<num=3>*x)", "x")); 60 Assert.AreEqual("(1 / (SQR(COS((3*'x'))) * 0.333333333333333))", Derive("tan(<num=3>*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator 61 61 62 Assert.AreEqual("((9*'x') / ABS((3*'x')))", Derive("abs( 3*x)", "x"));62 Assert.AreEqual("((9*'x') / ABS((3*'x')))", Derive("abs(<num=3>*x)", "x")); 63 63 Assert.AreEqual("(SQR('x') * 3)", Derive("cube(x)", "x")); 64 64 Assert.AreEqual("(1 / (SQR(CUBEROOT('x')) * 3))", Derive("cuberoot(x)", "x"));
Note: See TracChangeset
for help on using the changeset viewer.