Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/24/19 18:52:18 (4 years ago)
Author:
gkronber
Message:

#2520 merged r16542:16543 from trunk to branch

Location:
branches/2520_PersistenceReintegration
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2520_PersistenceReintegration

  • branches/2520_PersistenceReintegration/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/2520_PersistenceReintegration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs

    r16453 r16551  
    4848    private static readonly Cosine cosSy = new Cosine();
    4949    private static readonly Square sqrSy = new Square();
     50    private static readonly Absolute absSy = new Absolute();
     51    private static readonly SquareRoot sqrtSy = new SquareRoot();
    5052
    5153    public static ISymbolicExpressionTreeNode Derive(ISymbolicExpressionTreeNode branch, string variableName) {
     
    138140        return Product(Div(CreateConstant(1.0), Product(CreateConstant(2.0), f)), Derive(u, variableName));
    139141      }
     142      if (branch.Symbol is CubeRoot) {
     143        var f = (ISymbolicExpressionTreeNode)branch.Clone();
     144        var u = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
     145        return Product(Div(CreateConstant(1.0), Product(CreateConstant(3.0), Square(f))), Derive(u, variableName));
     146      }
     147      if (branch.Symbol is Cube) {
     148        var f = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
     149        return Product(Product(CreateConstant(3.0), Square(f)), Derive(f, variableName));
     150      }
     151      if (branch.Symbol is Absolute) {
     152        var f = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
     153        var absf = Abs((ISymbolicExpressionTreeNode)f.Clone());
     154        return Product(Div(f, absf), Derive(f, variableName));
     155      }
     156      if (branch.Symbol is AnalyticQuotient) {
     157        // aq(a(x), b(x)) = a(x) / sqrt(b(x)²+1)
     158        var a = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
     159        var b = (ISymbolicExpressionTreeNode)branch.GetSubtree(1).Clone();
     160
     161        var definition = Div(a, SquareRoot(Sum(Square(b), CreateConstant(1.0))));
     162        return Derive(definition, variableName);
     163      }
    140164      if (branch.Symbol is Sine) {
    141165        var u = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
     
    195219      return cos;
    196220    }
     221    private static ISymbolicExpressionTreeNode Abs(ISymbolicExpressionTreeNode f) {
     222      var abs = absSy.CreateTreeNode();
     223      abs.AddSubtree(f);
     224      return abs;
     225    }
    197226    private static ISymbolicExpressionTreeNode Square(ISymbolicExpressionTreeNode f) {
    198227      var sqr = sqrSy.CreateTreeNode();
    199228      sqr.AddSubtree(f);
    200229      return sqr;
     230    }
     231    private static ISymbolicExpressionTreeNode SquareRoot(ISymbolicExpressionTreeNode f) {
     232      var sqrt = sqrtSy.CreateTreeNode();
     233      sqrt.AddSubtree(f);
     234      return sqrt;
    201235    }
    202236
     
    221255          !(n.Symbol is Square) &&
    222256          !(n.Symbol is SquareRoot) &&
     257          !(n.Symbol is Cube) &&
     258          !(n.Symbol is CubeRoot) &&
     259          !(n.Symbol is Absolute) &&
     260          !(n.Symbol is AnalyticQuotient) &&
    223261          !(n.Symbol is Sine) &&
    224262          !(n.Symbol is Cosine) &&
Note: See TracChangeset for help on using the changeset viewer.