
On Wed, 19 May 2021, Fabrício Olivetti de França wrote:
I was using Numeric.Interval in my code and found an issue with the (**) operator, if the interval contains negative values, it will return a wrong result (as reported in this open issue https://github.com/ekmett/intervals/issues/50).
If you need negative bases you must use (^^) instead of (**).
Investigating the source of this problem, I found that it uses the default implementation of (**) from base defined as x ** y = exp (log x * y).
This default implementation is correct. Power (**) is only defined for positive reals like in mathematics. The example in the GitHub issue will not work if your interval is slightly larger than just the point 2. Think of the interval x=[-2.1,-1.9]. What should x**x be? In contrast to that x^^(-2) would be fine.