Changeset 18086 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs
- Timestamp:
- 11/19/21 16:07:45 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs
r17226 r18086 149 149 return Product(Product(CreateConstant(3.0), Square(f)), Derive(f, variableName)); 150 150 } 151 if (branch.Symbol is Power) { 152 // 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 154 var exponent = branch.GetSubtree(1) as ConstantTreeNode; 155 if (exponent != null && Math.Truncate(exponent.Value) == exponent.Value) { 156 var newPower = (ISymbolicExpressionTreeNode)branch.Clone(); 157 var f = (ISymbolicExpressionTreeNode)newPower.GetSubtree(0).Clone(); 158 var newExponent = (ConstantTreeNode)newPower.GetSubtree(1); 159 newExponent.Value -= 1; 160 return Product(Product(CreateConstant(exponent.Value), newPower), Derive(f, variableName)); 161 } else throw new NotSupportedException("Cannot derive non-integer powers"); 162 } 151 163 if (branch.Symbol is Absolute) { 152 164 var f = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone(); … … 263 275 !(n.Symbol is Cube) && 264 276 !(n.Symbol is CubeRoot) && 277 !(n.Symbol is Power) && 265 278 !(n.Symbol is Absolute) && 266 279 !(n.Symbol is AnalyticQuotient) && 280 !(n.Symbol is HyperbolicTangent) && 267 281 !(n.Symbol is Sine) && 268 282 !(n.Symbol is Cosine) &&
Note: See TracChangeset
for help on using the changeset viewer.