[quote=“Axel”]Hi,
as you cans see in root.cern.ch/root/html/TMath#TMath:Power it just calls pow. “man pow” states for me:
[quote=“man pow”]The pow() function can return the following error:
EDOM The argument x is negative and y is not an integral value. This would result in a complex number.[/quote] I disagree with their definition of complex numbers, but we’ll have to live with that.
[/quote]
When ‘x is negative and y is not an integral value’, you can always come up with complex roots (as well as possibly a real one as well).
In any case, if you want ‘cuberoot (-27.)’ to give you ‘-3’, you’ll want to keep track of the sign of the argument and appy it after
double cuberoot (x)
{
return (x / fabs (x)) * pow ( fabs(x), 1/3. );
}