Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/11/19 11:20:58 (5 years ago)
Author:
gkronber
Message:

#2948: added support for tanh in DerivativeCalculator and a unit test case

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs

    r16905 r17125  
    179179        var u = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
    180180        return Div(fxp, Square(Cosine(u)));
     181      }
     182      if (branch.Symbol is HyperbolicTangent) {
     183        // tanh(f(x))' = f(x)'sech²(f(x)) = f(x)'(1 - tanh²(f(x)))
     184        var fxp = Derive(branch.GetSubtree(0), variableName);
     185        var tanh = (ISymbolicExpressionTreeNode)branch.Clone();
     186        return Product(fxp, Subtract(CreateConstant(1.0), Square(tanh)));
    181187      }
    182188      throw new NotSupportedException(string.Format("Symbol {0} is not supported.", branch.Symbol));
Note: See TracChangeset for help on using the changeset viewer.