On Thu, 13 Aug 2020, Alecos Papadopoulos wrote:
Well, mathematically, say, (-27)^(1/3) = 3rd root of -27, which is
equal to
-3.
But your example below clarifies that my approach with the use of the sign
function (or Sven's conditional statement) are applicable only when we have
as power a rational formed by two odd numbers: 1/3, 3/7, etc.
In such cases, with a negative base the solution will be real-valued and it
will preserve the minus sign of the base.
Certainly, these are special cases, but they are the cases for which a
real-valued solution exists, which is why the "domain error" message drew my
attention.
Granted, you're right: there's a certain subset of noninteger
floating-point numbers, y, for which there's a real-valued solution
to negative x to the power y. But it seems that no standard pow()
function taking the reals as its domain is willing to identify and
handle that subset.
Allin