Index: branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeSimplifier.cs
===================================================================
--- branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeSimplifier.cs	(revision 17783)
+++ branches/3087_Ceres_Integration/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeSimplifier.cs	(revision 18006)
@@ -784,4 +784,6 @@
       } else if (IsExp(node)) {
         return MakeExp(MakeProduct(node.GetSubtree(0), MakeConstant(2.0))); // sqr(exp(x)) = exp(2x)
+      } else if (IsSquare(node)) {
+        return MakePower(node.GetSubtree(0), MakeConstant(4));
       } else if (IsCube(node)) {
         return MakePower(node.GetSubtree(0), MakeConstant(6));
@@ -809,4 +811,6 @@
       } else if (IsSquare(node)) {
         return MakePower(node.GetSubtree(0), MakeConstant(6));
+      } else if (IsCube(node)) {
+        return MakePower(node.GetSubtree(0), MakeConstant(9));
       } else {
         var cubeNode = cubeSymbol.CreateTreeNode();
@@ -933,11 +937,16 @@
         var constB = b as ConstantTreeNode;
         var constBValue = Math.Round(constB.Value);
-        if (constBValue.IsAlmost(1.0)) {
+        if (constBValue == 1.0) {
+          // root(a, 1) => a
           return a;
-        } else if (constBValue.IsAlmost(0.0)) {
-          return MakeConstant(1.0);
-        } else if (constBValue.IsAlmost(-1.0)) {
+        } else if (constBValue == 0.0) {
+          // root(a, 0) is not defined 
+          //return MakeConstant(1.0);
+          return MakeConstant(double.NaN);
+        } else if (constBValue == -1.0) {
+          // root(a, -1) => a^(-1/1) => 1/a
           return MakeFraction(MakeConstant(1.0), a);
         } else if (constBValue < 0) {
+          // root(a, -b) => a^(-1/b) => (1/a)^(1/b) => root(1, b) / root(a, b) => 1 / root(a, b)
           var rootNode = rootSymbol.CreateTreeNode();
           rootNode.AddSubtree(a);
@@ -987,11 +996,15 @@
         var constB = b as ConstantTreeNode;
         double exponent = Math.Round(constB.Value);
-        if (exponent.IsAlmost(0.0)) {
+        if (exponent == 0.0) {
+          // a^0 => 1
           return MakeConstant(1.0);
-        } else if (exponent.IsAlmost(1.0)) {
+        } else if (exponent == 1.0) {
+          // a^1 => a
           return a;
-        } else if (exponent.IsAlmost(-1.0)) {
+        } else if (exponent == -1.0) {
+          // a^-1 => 1/a
           return MakeFraction(MakeConstant(1.0), a);
         } else if (exponent < 0) {
+          // a^-b => (1/a)^b => 1/(a^b)
           var powNode = powSymbol.CreateTreeNode();
           powNode.AddSubtree(a);
@@ -1018,5 +1031,6 @@
         // fold constants
         return MakeConstant(((ConstantTreeNode)a).Value / ((ConstantTreeNode)b).Value);
-      } else if ((IsConstant(a) && !((ConstantTreeNode)a).Value.IsAlmost(1.0))) {
+      } else if ((IsConstant(a) && ((ConstantTreeNode)a).Value != 1.0)) {
+        // a / x => (a * 1/a) / (x * 1/a) => 1 / (x * 1/a)
         return MakeFraction(MakeConstant(1.0), MakeProduct(b, Invert(a)));
       } else if (IsVariableBase(a) && IsConstant(b)) {
@@ -1094,5 +1108,5 @@
         // b is not constant => make sure constant is on the right
         return MakeSum(b, a);
-      } else if (IsConstant(b) && ((ConstantTreeNode)b).Value.IsAlmost(0.0)) {
+      } else if (IsConstant(b) && ((ConstantTreeNode)b).Value == 0.0) {
         // x + 0 => x
         return a;
@@ -1210,5 +1224,5 @@
       foreach (var unchangedSubtree in unchangedSubtrees)
         sum.AddSubtree(unchangedSubtree);
-      if (!constant.IsAlmost(0.0)) {
+      if (constant != 0.0) {
         sum.AddSubtree(MakeConstant(constant));
       }
@@ -1268,8 +1282,8 @@
         if (wi < 0) throw new ArgumentException();
         return MakeBinFactor(node1.Symbol, node1.VariableName, node1.VariableValue, node1.Weight * node0.Weights[wi]);
-      } else if (IsConstant(b) && ((ConstantTreeNode)b).Value.IsAlmost(1.0)) {
+      } else if (IsConstant(b) && ((ConstantTreeNode)b).Value == 1.0) {
         // $ * 1.0 => $
         return a;
-      } else if (IsConstant(b) && ((ConstantTreeNode)b).Value.IsAlmost(0.0)) {
+      } else if (IsConstant(b) && ((ConstantTreeNode)b).Value == 0.0) {
         return MakeConstant(0);
       } else if (IsConstant(b) && IsVariableBase(a)) {
@@ -1419,5 +1433,5 @@
         prod.AddSubtree(unchangedSubtree);
 
-      if (!constantProduct.IsAlmost(1.0)) {
+      if (constantProduct != 1.0) {
         prod.AddSubtree(MakeConstant(constantProduct));
       }
