Changeset 18225
- Timestamp:
- 03/03/22 14:56:13 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs
r18172 r18225 38 38 Assert.AreEqual("10", Derive("<num=10>*x", "x")); 39 39 Assert.AreEqual("10", Derive("x*<num=10>", "x")); 40 Assert.AreEqual("2 *'x'", Derive("x*x", "x"));40 Assert.AreEqual("2 * 'x'", Derive("x*x", "x")); 41 41 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 42 42 Assert.AreEqual("0", Derive("<num=10>*x", "y")); 43 43 Assert.AreEqual("20", Derive("<num=10>*x+<num=20>*y", "y")); 44 44 Assert.AreEqual("6", Derive("<num=2>*<num=3>*x", "x")); 45 Assert.AreEqual("10 *'y'", Derive("<num=10>*x*y+<num=20>*y", "x"));45 Assert.AreEqual("10 * 'y'", Derive("<num=10>*x*y+<num=20>*y", "x")); 46 46 Assert.AreEqual("1 * -1 / SQR('x')", Derive("1/x", "x")); 47 Assert.AreEqual("-1 *'y' / SQR('x')", Derive("y/x", "x"));48 Assert.AreEqual("('a' + 'b') * (-2 *'x' + -1) / SQR('x' + 'x' * 'x')",47 Assert.AreEqual("-1 * 'y' / SQR('x')", Derive("y/x", "x")); 48 Assert.AreEqual("('a' + 'b') * (-2 * 'x' + -1) / SQR('x' + 'x' * 'x')", 49 49 Derive("(a+b)/(x+x*x)", "x")); 50 Assert.AreEqual("('a' + 'b') * (-2 *'x' + -1) / SQR('x' + SQR('x'))", Derive("(a+b)/(x+SQR(x))", "x"));50 Assert.AreEqual("('a' + 'b') * (-2 * 'x' + -1) / SQR('x' + SQR('x'))", Derive("(a+b)/(x+SQR(x))", "x")); 51 51 Assert.AreEqual("EXP('x')", Derive("exp(x)", "x")); 52 Assert.AreEqual("EXP(3 *'x') * 3", Derive("exp(<num=3>*x)", "x"));52 Assert.AreEqual("EXP(3 * 'x') * 3", Derive("exp(<num=3>*x)", "x")); 53 53 Assert.AreEqual("1 / 'x'", Derive("log(x)", "x")); 54 54 Assert.AreEqual("1 / 'x'", Derive("log(<num=3>*x)", "x")); // 3 * 1/(3*x) 55 Assert.AreEqual("1 / ('x' + 0.333333333333333 *'y')", Derive("log(<num=3>*x+y)", "x")); // simplifier does not try to keep fractions56 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))57 Assert.AreEqual("COS(3 *'x') * 3", Derive("sin(<num=3>*x)", "x"));58 Assert.AreEqual("SIN(3 *'x') * -3", Derive("cos(<num=3>*x)", "x"));59 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 denominator55 Assert.AreEqual("1 / ('x' + 0.333333333333333 * 'y')", Derive("log(<num=3>*x+y)", "x")); // simplifier does not try to keep fractions 56 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)) 57 Assert.AreEqual("COS(3 * 'x') * 3", Derive("sin(<num=3>*x)", "x")); 58 Assert.AreEqual("SIN(3 * 'x') * -3", Derive("cos(<num=3>*x)", "x")); 59 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 60 60 61 Assert.AreEqual("9 *'x' / ABS(3*'x')", Derive("abs(<num=3>*x)", "x"));61 Assert.AreEqual("9 * 'x' / ABS(3 * 'x')", Derive("abs(<num=3>*x)", "x")); 62 62 Assert.AreEqual("SQR('x') * 3", Derive("cube(x)", "x")); 63 63 Assert.AreEqual("1 / (SQR(CUBEROOT('x')) * 3)", Derive("cuberoot(x)", "x")); … … 67 67 68 68 Assert.AreEqual("'a' * 'b' * 'c'", Derive("a*b*c*d", "d")); 69 Assert.AreEqual("'b' * 'c' * -1*'a'/ (SQR('b') * SQR('c') * SQR('d'))", Derive("a/b/c/d", "d")); // TODO simplifier should be able to simplify this69 Assert.AreEqual("'b' * 'c' * (-1 * 'a') / (SQR('b') * SQR('c') * SQR('d'))", Derive("a/b/c/d", "d")); // TODO simplifier should be able to simplify this 70 70 71 71 Assert.AreEqual("'x' * (SQR(TANH(SQR('x'))) * -1 + 1) * 2", Derive("tanh(sqr(x))", "x")); // (2*'x'*(1 - SQR(TANH(SQR('x'))))
Note: See TracChangeset
for help on using the changeset viewer.