IntervalArithmetic.jl icon indicating copy to clipboard operation
IntervalArithmetic.jl copied to clipboard

Improve the documentation for `pow`

Open schillic opened this issue 3 months ago • 1 comments

julia> using IntervalArithmetic

julia> x = interval(-4, -2)
[-4.0, -2.0]_com

julia> pow(x, 2)
∅_trv

The problem seems to be in these lines:

https://github.com/JuliaIntervals/IntervalArithmetic.jl/blob/544c0005b96e70c026ebc306ebeeb7e7fed63274/src/intervals/arithmetic/power.jl#L157-L159

It is unclear to me why domain should be nonnegative. Clearly you can take a power of a negative number.

schillic avatar Sep 27 '25 09:09 schillic

Thanks for opening this issue. I agree this may be odd looking; for the reasons behind this behavior refer to Table 9.1 from the IEEE standard.

The documentation can always be improved, and in particular that of pow. So I changed the title this issue accordingly.

Note that pow is not an alias for ^,

julia> interval(-4, -2)^2
[4.0, 16.0]_com

julia> pown(interval(-4, -2), 2)
[4.0, 16.0]_com

julia> pow(interval(-4, -2), 2)
∅_trv

OlivierHnt avatar Sep 27 '25 13:09 OlivierHnt