-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible bug in powers #441
Comments
Real (noninteger) powers of negative numbers are undefined, so the input interval is truncated to 0. |
What is the context in which this calculation occurs? |
Maybe it is indeed a bug, but a problem arises with |
Cool, thanks. I'm just computing powers of intervals, the truncation works for me. I guess it could return something imaginary in some situations? |
I like how the empty set is returned for 1/0 |
I guess the correct result should be |
It can't return complex numbers since that would be type-unstable. That's the same reason that Julia does not do this: julia> (-1.0)^-2.1
ERROR: DomainError with -1.0:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.
Stacktrace:
[1] throw_exp_domainerror(x::Float64)
@ Base.Math ./math.jl:37
[2] ^(x::Float64, y::Float64)
@ Base.Math ./math.jl:901
[3] top-level scope
@ REPL[6]:1 |
I think whether to include negative numbers is just a choice, not a bug. |
I think the chose to not include negative numbers: IntervalArithmetic.jl/src/intervals/functions.jl Lines 209 to 211 in b70940d
If I recall correctly, we simply avoided the cases like |
Yes, I agree on both points. julia> using IntervalArithmetic
julia> @format true; # show decdorations
julia> x = DecoratedInterval(-1..1)
[-1, 1]_com
julia> x^x
[0, ∞]_trv
|
I believe we can close this, now that decorations are the default #590. |
If
x = [-1,1], y = [-1,1]
The program gives me
x^y => [0, Inf]
.But
(-1)^(-1) = -1
, which is lower than 0.Is my understanding wrong, but I think -1 should be in the result.
The text was updated successfully, but these errors were encountered: