Question on valid transformations for cbrt

Robert Dewar dewar@gnat.com
Wed Mar 10 16:06:00 GMT 2004


Segher Boessenkool wrote:

>> The problem with cbrt, unlike sqrt, is that its is more expressive than
>> pow.  i.e. cbrt(-29.7) = -3.1 but pow(-29.7,1.0/3.0) => EDOM.  Hence
>> we can't normalize cbrt(x) as pow(x,1.0/3.0),
> 
> 
> You can "normalize" cbrt(x) as  sign(x) * pow(abs(x), 1.0/3)  -- maybe that
> helps some further optimizations?

Of course both these transformations are numerically horrible. I trust 
that this is understood.

>> but we can safely go the
>> other way pow(x,1.0/3.0) => cbrt(x).

Well I don't like transformations like this which change the computation
so radically and give completely different results. This is not real
arithmetic, and the compiler really has no business making 
substituations that are not meaning preserving.





More information about the Gcc mailing list