Calculating the cube root of a negative value


I am attempting to use the Math Formula (Multi Column) node to calculate the cube root of some data containing both positive and negative values. I am using the formula:


However, negative values are turned to ‘?’. Does anyone have a suggestion on how to fix this?

With kind regards

Hi @EsbenSv and welcome to the forum!

It looks like this behavior is due to how the underlying library, the Java Math Expression Parser (or JEP) works. A similar was issue was brought up to the JEP developers back in 2006 (See thread here.)

An admittedly clunky workaround might be to use the Column Expressions node instead of the Math Formula (Multi Column) node. You could implement some logic where if the value you are testing is negative, instead return


I haven’t tried this out myself yet - it’s just off the top of my head - so I may be missing some nuance here.


Hi Scott

Thanks for the fast reply! I will try this and report back with my solution. Thank you very much!


Hi Scott


I used the Column Expressions node in a loop to loop over all my columns:

The outputName flow variable was set to currentColumnName from the Column List Loop Start.

This seemed to work alright, albeit abit slow. The limiting factor seemed to be the Loop End (Column Append) node, which slowed down over the ~780 columns (~110,000 rows). Is there any faster/better way to this?

Hi Esben,
I’m not Scott but maybe this will help a little:

With a little prodding we can get the math formula node to give the correct value still which will be a bit faster than the the column expression node. Also we can use the Math Formula (Multi Column) node to get out of using the column loop.

Here’s the formula I used, the idea is similar to Scott’s in that we first take the absolute value, but then we dynamically multiply by 1 or -1 depending on if the original value was greater than or less than 0.

Cubic Roots.knwf (6.6 KB)

Workflow with a small example attached.
Best of luck, if there are any questions about the formula please ask!


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.