Index: /branches/2520_PersistenceReintegration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/HeuristicLab.NativeInterpreter-0.1.csproj
===================================================================
--- /branches/2520_PersistenceReintegration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/HeuristicLab.NativeInterpreter-0.1.csproj (revision 16550)
+++ /branches/2520_PersistenceReintegration/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/HeuristicLab.NativeInterpreter-0.1.csproj (revision 16551)
@@ -39,9 +39,4 @@
-
- False
- ..\..\..\..\bin\HeuristicLab.PluginInfrastructure-3.3.dll
- False
-
@@ -69,4 +64,11 @@
+
+
+ {94186a6a-5176-4402-ae83-886557b53cca}
+ HeuristicLab.PluginInfrastructure-3.3
+ False
+
+
Index: /branches/2520_PersistenceReintegration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs
===================================================================
--- /branches/2520_PersistenceReintegration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs (revision 16550)
+++ /branches/2520_PersistenceReintegration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs (revision 16551)
@@ -48,4 +48,6 @@
private static readonly Cosine cosSy = new Cosine();
private static readonly Square sqrSy = new Square();
+ private static readonly Absolute absSy = new Absolute();
+ private static readonly SquareRoot sqrtSy = new SquareRoot();
public static ISymbolicExpressionTreeNode Derive(ISymbolicExpressionTreeNode branch, string variableName) {
@@ -138,4 +140,26 @@
return Product(Div(CreateConstant(1.0), Product(CreateConstant(2.0), f)), Derive(u, variableName));
}
+ if (branch.Symbol is CubeRoot) {
+ var f = (ISymbolicExpressionTreeNode)branch.Clone();
+ var u = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
+ return Product(Div(CreateConstant(1.0), Product(CreateConstant(3.0), Square(f))), Derive(u, variableName));
+ }
+ if (branch.Symbol is Cube) {
+ var f = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
+ return Product(Product(CreateConstant(3.0), Square(f)), Derive(f, variableName));
+ }
+ if (branch.Symbol is Absolute) {
+ var f = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
+ var absf = Abs((ISymbolicExpressionTreeNode)f.Clone());
+ return Product(Div(f, absf), Derive(f, variableName));
+ }
+ if (branch.Symbol is AnalyticQuotient) {
+ // aq(a(x), b(x)) = a(x) / sqrt(b(x)²+1)
+ var a = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
+ var b = (ISymbolicExpressionTreeNode)branch.GetSubtree(1).Clone();
+
+ var definition = Div(a, SquareRoot(Sum(Square(b), CreateConstant(1.0))));
+ return Derive(definition, variableName);
+ }
if (branch.Symbol is Sine) {
var u = (ISymbolicExpressionTreeNode)branch.GetSubtree(0).Clone();
@@ -195,8 +219,18 @@
return cos;
}
+ private static ISymbolicExpressionTreeNode Abs(ISymbolicExpressionTreeNode f) {
+ var abs = absSy.CreateTreeNode();
+ abs.AddSubtree(f);
+ return abs;
+ }
private static ISymbolicExpressionTreeNode Square(ISymbolicExpressionTreeNode f) {
var sqr = sqrSy.CreateTreeNode();
sqr.AddSubtree(f);
return sqr;
+ }
+ private static ISymbolicExpressionTreeNode SquareRoot(ISymbolicExpressionTreeNode f) {
+ var sqrt = sqrtSy.CreateTreeNode();
+ sqrt.AddSubtree(f);
+ return sqrt;
}
@@ -221,4 +255,8 @@
!(n.Symbol is Square) &&
!(n.Symbol is SquareRoot) &&
+ !(n.Symbol is Cube) &&
+ !(n.Symbol is CubeRoot) &&
+ !(n.Symbol is Absolute) &&
+ !(n.Symbol is AnalyticQuotient) &&
!(n.Symbol is Sine) &&
!(n.Symbol is Cosine) &&
Index: /branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs
===================================================================
--- /branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs (revision 16550)
+++ /branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/DeriveTest.cs (revision 16551)
@@ -59,4 +59,8 @@
Assert.AreEqual("(SIN((3*'x')) * (-3))", Derive("cos(3*x)", "x"));
Assert.AreEqual("(1 / (SQR(COS((3*'x'))) * 0.333333333333333))", Derive("tan(3*x)", "x")); // diff(tan(f(x)), x) = 1.0 / cos²(f(x)), simplifier puts constant factor into the denominator
+
+ Assert.AreEqual("((9*'x') / ABS((3*'x')))", Derive("abs(3*x)", "x"));
+ Assert.AreEqual("(SQR('x') * 3)", Derive("cube(x)", "x"));
+ Assert.AreEqual("(1 / (SQR(CUBEROOT('x')) * 3))", Derive("cuberoot(x)", "x"));
Assert.AreEqual("0", Derive("(a+b)/(x+SQR(x))", "y")); // df(a,b,x) / dy = 0