Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18225


Ignore:
Timestamp:
03/03/22 14:56:13 (3 years ago)
Author:
dpiringe
Message:

#3147: fix expressions with missing spaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs

    r18172 r18225  
    3838      Assert.AreEqual("10", Derive("<num=10>*x", "x"));
    3939      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"));
    4141      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
    4242      Assert.AreEqual("0", Derive("<num=10>*x", "y"));
    4343      Assert.AreEqual("20", Derive("<num=10>*x+<num=20>*y", "y"));
    4444      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"));
    4646      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')",
    4949        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"));
    5151      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"));
    5353      Assert.AreEqual("1 / 'x'", Derive("log(x)", "x"));
    5454      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 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
     55      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
    6060
    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"));
    6262      Assert.AreEqual("SQR('x') * 3", Derive("cube(x)", "x"));
    6363      Assert.AreEqual("1 / (SQR(CUBEROOT('x')) * 3)", Derive("cuberoot(x)", "x"));
     
    6767
    6868      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 this
     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 this
    7070
    7171      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.