Changeset 17800


Ignore:
Timestamp:
12/22/20 12:49:01 (10 months ago)
Author:
gkronber
Message:

#3073: fixed bug in derivation of power function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs

    r17780 r17800  
    151151      if (branch.Symbol is Power) {
    152152        // HL evaluators handle power strangely (exponent is rounded to an integer)
    153         // here we only support the case when the exponent is a constant integer and
     153        // here we only support the case when the exponent is a constant integer
    154154        var exponent = branch.GetSubtree(1) as ConstantTreeNode;
    155155        if (exponent != null && Math.Truncate(exponent.Value) == exponent.Value) {
    156156          var newPower = (ISymbolicExpressionTreeNode)branch.Clone();
     157          var f = (ISymbolicExpressionTreeNode)newPower.GetSubtree(0).Clone();
    157158          var newExponent = (ConstantTreeNode)newPower.GetSubtree(1);
    158159          newExponent.Value -= 1;
    159           return Product(CreateConstant(exponent.Value), newPower);
     160          return Product(Product(CreateConstant(exponent.Value), newPower), Derive(f, variableName));
    160161        } else throw new NotSupportedException("Cannot derive non-integer powers");
    161162      }
Note: See TracChangeset for help on using the changeset viewer.