Index: /trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.h
===================================================================
--- /trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.h	(revision 16904)
+++ /trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.h	(revision 16905)
@@ -118,5 +118,5 @@
             case OpCodes::CubeRoot:
                 {
-                    in.value = hl_pow(code[in.childIndex].value, 1./3.);
+                    in.value = hl_cbrt(code[in.childIndex].value);
                     break;
                 }
@@ -272,5 +272,5 @@
             case OpCodes::CubeRoot:
                 {
-                    pow(in.buf, code[in.childIndex].buf, 1./3.);
+                    cbrt(in.buf, code[in.childIndex].buf);
                     break;
                 }
Index: /trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/vector_operations.h
===================================================================
--- /trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/vector_operations.h	(revision 16904)
+++ /trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/vector_operations.h	(revision 16905)
@@ -17,4 +17,5 @@
 #define hl_sqrt vdt::fast_sqrt
 #define hl_pow vdt::fast_pow
+#define hl_cbrt std::cbrt
 #define hl_round vdt::fast_round
 #define hl_inv vdt::fast_inv
@@ -28,4 +29,5 @@
 #define hl_sqrt std::sqrt
 #define hl_pow std::pow
+#define hl_cbrt std::cbrt
 #define hl_round std::round
 #define hl_inv(x) 1. / x;
@@ -56,4 +58,5 @@
 inline void pow(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_pow(a[i], hl_round(b[i])); };
 inline void root(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_pow(a[i], 1. / hl_round(b[i])); };
+inline void cbrt(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_cbrt(b[i]); };
 inline void square(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_pow(b[i], 2.); };
 inline void inv(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_inv(b[i]); }
@@ -81,4 +84,5 @@
 inline void round(double* __restrict a) noexcept { FOR(i) a[i] = hl_round(a[i]); }
 inline void square(double* __restrict a) noexcept { FOR(i) a[i] = hl_pow(a[i], 2.); }
+inline void cbrt(double* __restrict a) noexcept { FOR(i) a[i] = hl_cbrt(a[i]); }
 
 #undef FOR
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs	(revision 16905)
@@ -143,5 +143,5 @@
         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));
+        return Product(Div(CreateConstant(1.0), Product(CreateConstant(3.0), Square(f))), Derive(u, variableName));  // 1/3 1/cbrt(f(x))^2 d/dx f(x)
       }
       if (branch.Symbol is Cube) {
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/TreeToAutoDiffTermConverter.cs	(revision 16905)
@@ -92,4 +92,11 @@
       );
 
+    private static readonly Func<Term, UnaryFunc> cbrt = UnaryFunc.Factory(
+      eval: x => x < 0 ? -Math.Pow(-x, 1.0 / 3) : Math.Pow(x, 1.0 / 3),
+      diff: x => { var cbrt_x = x < 0 ? -Math.Pow(-x, 1.0 / 3) : Math.Pow(x, 1.0 / 3); return 1.0 / (3 * cbrt_x * cbrt_x); }
+      );
+
+
+
     #endregion
 
@@ -250,6 +257,5 @@
       }
       if (node.Symbol is CubeRoot) {
-        return AutoDiff.TermBuilder.Power(
-          ConvertToAutoDiff(node.GetSubtree(0)), 1.0/3.0);
+        return cbrt(ConvertToAutoDiff(node.GetSubtree(0)));
       }
       if (node.Symbol is Sine) {
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs	(revision 16905)
@@ -140,5 +140,7 @@
           FormatPower(node, strBuilder, "3");
         } else if (node.Symbol is CubeRoot) {
-          FormatPower(node, strBuilder, "1.0/3");
+          strBuilder.Append("Cbrt(");
+          FormatRecursively(node.GetSubtree(0), strBuilder);
+          strBuilder.Append(")");
         } else if (node.Symbol is Power) {
           FormatFunction(node, "Math.Pow", strBuilder);
@@ -252,4 +254,5 @@
       strBuilder.AppendLine("public static class Model {");
       GenerateAverageSource(strBuilder);
+      GenerateCbrtSource(strBuilder);
       GenerateIfThenElseSource(strBuilder);
       GenerateFactorSource(strBuilder);
@@ -293,4 +296,9 @@
       strBuilder.AppendLine("private static double Average(params double[] values) {");
       strBuilder.AppendLine("  return values.Average();");
+      strBuilder.AppendLine("}");
+    }
+    private void GenerateCbrtSource(StringBuilder strBuilder) {
+      strBuilder.AppendLine("private static double Cbrt(double x) {");
+      strBuilder.AppendLine("  return x < 0 ? -Math.Pow(-x, 1.0 / 3.0) : Math.Pow(x, 1.0 / 3.0);");
       strBuilder.AppendLine("}");
     }
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs	(revision 16905)
@@ -144,5 +144,6 @@
         stringBuilder.Append($"POWER({FormatRecursively(node.GetSubtree(0))}, 3)");
       } else if (symbol is CubeRoot) {
-        stringBuilder.Append($"POWER({FormatRecursively(node.GetSubtree(0))}, 1/3)");
+        var arg_expr = FormatRecursively(node.GetSubtree(0));
+        stringBuilder.Append($"IF({arg_expr} < 0, -POWER(-{arg_expr}, 1/3), POWER({arg_expr}, 1/3))");
       } else if (symbol is Division) {
         if (node.SubtreeCount == 1) {
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs	(revision 16905)
@@ -138,5 +138,5 @@
         strBuilder.Append(@"\left(");
       } else if (node.Symbol is CubeRoot) {
-        strBuilder.Append(@"\left(");
+        strBuilder.Append(@"\operatorname{cbrt}\left(");
       } else if (node.Symbol is Sine) {
         strBuilder.Append(@"\sin \left( ");
@@ -420,5 +420,5 @@
         strBuilder.Append(@"\right)^3");
       } else if (node.Symbol is CubeRoot) {
-        strBuilder.Append(@"\right)^\frac{1}{3}");
+        strBuilder.Append(@"\right)");
       } else if (node.Symbol is Sine) {
         strBuilder.Append(@" \right) ");
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs	(revision 16905)
@@ -188,7 +188,7 @@
         stringBuilder.Append(").^3");
       } else if (symbol is CubeRoot) {
-        stringBuilder.Append("(");
-        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
-        stringBuilder.Append(").^(1/3)");
+        stringBuilder.Append("NTHROOT(");
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
+        stringBuilder.Append(", 3)");
       } else if (symbol is GreaterThan) {
         stringBuilder.Append("((");
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs	(revision 16905)
@@ -115,5 +115,7 @@
           FormatPower(node, strBuilder, "3");
         } else if (node.Symbol is CubeRoot) {
-          FormatPower(node, strBuilder, "1/3");
+          strBuilder.Append("CubeRoot[");
+          FormatRecursively(node.GetSubtree(0), strBuilder);
+          strBuilder.Append("]");
         } else if (node.Symbol is Power) {
           FormatFunction(node, "Power", strBuilder);
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs	(revision 16905)
@@ -92,5 +92,6 @@
         stringBuilder.Append(FormatPower(node.GetSubtree(0), "3"));
       } else if (symbol is CubeRoot) {
-        stringBuilder.Append(FormatPower(node.GetSubtree(0), "(1/3)"));
+        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
+        stringBuilder.Append(" cbrt");
       } else if (symbol is Division) {
         if (node.SubtreeCount == 1) {
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs	(revision 16905)
@@ -101,5 +101,5 @@
     public static void CubeRoot(double[] a, double[] b) {
       for (int i = 0; i < BATCHSIZE; ++i)
-        a[i] = Math.Pow(b[i], 1d / 3d);
+        a[i] = b[i] < 0 ? -Math.Pow(-b[i], 1d / 3d) : Math.Pow(b[i], 1d / 3d);
     }
 
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs	(revision 16905)
@@ -247,5 +247,7 @@
         case OpCodes.CubeRoot: {
             var arg = MakeExpr(node.GetSubtree(0), variableIndices, row, columns);
-            return Expression.Power(arg, Expression.Constant(1.0 / 3.0));
+            return Expression.Condition(Expression.LessThan(arg, Expression.Constant(0.0)),
+              Expression.Negate(Expression.Power(Expression.Negate(arg), Expression.Constant(1.0 / 3.0))),
+              Expression.Power(arg, Expression.Constant(1.0 / 3.0)));
           }
         case OpCodes.Root: {
@@ -514,6 +516,6 @@
             var x1 = MakeExpr(node.GetSubtree(0), variableIndices, row, columns);
             var x2 = MakeExpr(node.GetSubtree(1), variableIndices, row, columns);
-            return Expression.Divide(x1, 
-              Expression.Call(Sqrt, 
+            return Expression.Divide(x1,
+              Expression.Call(Sqrt,
               Expression.Add(
                 Expression.Constant(1.0),
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs	(revision 16905)
@@ -336,6 +336,20 @@
         case OpCodes.CubeRoot: {
             CompileInstructions(il, state, ds);
+            var c1 = il.DefineLabel();
+            var end = il.DefineLabel();
+
+            il.Emit(System.Reflection.Emit.OpCodes.Dup); // x
+            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 0.0);
+            il.Emit(System.Reflection.Emit.OpCodes.Clt); // x < 0?
+            il.Emit(System.Reflection.Emit.OpCodes.Brfalse, c1);
+            il.Emit(System.Reflection.Emit.OpCodes.Neg); // x = -x
             il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 1.0 / 3.0);
             il.Emit(System.Reflection.Emit.OpCodes.Call, power);
+            il.Emit(System.Reflection.Emit.OpCodes.Neg); // -Math.Pow(-x, 1/3)
+            il.Emit(System.Reflection.Emit.OpCodes.Br, end);
+            il.MarkLabel(c1);
+            il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 1.0 / 3.0);
+            il.Emit(System.Reflection.Emit.OpCodes.Call, power);
+            il.MarkLabel(end);
             return;
           }
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeInterpreter.cs	(revision 16905)
@@ -232,5 +232,6 @@
           }
         case OpCodes.CubeRoot: {
-            return Math.Pow(Evaluate(dataset, ref row, state), 1.0 / 3.0);
+            var arg = Evaluate(dataset, ref row, state);
+            return arg < 0 ? -Math.Pow(-arg, 1.0 / 3.0) : Math.Pow(arg, 1.0 / 3.0);
           }
         case OpCodes.Root: {
Index: /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs
===================================================================
--- /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs	(revision 16904)
+++ /trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeLinearInterpreter.cs	(revision 16905)
@@ -245,5 +245,6 @@
           instr.value = Math.Sqrt(code[instr.childIndex].value);
         } else if (instr.opCode == OpCodes.CubeRoot) {
-          instr.value = Math.Pow(code[instr.childIndex].value, 1.0 / 3.0);
+          var arg = code[instr.childIndex].value;
+          instr.value = arg < 0 ? -Math.Pow(-arg, 1.0 / 3.0) : Math.Pow(arg, 1.0 / 3.0);
         } else if (instr.opCode == OpCodes.Root) {
           double x = code[instr.childIndex].value;
