Skip to content
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

Approximate equality with intervals #479

Closed
mforets opened this issue Jun 24, 2021 · 1 comment
Closed

Approximate equality with intervals #479

mforets opened this issue Jun 24, 2021 · 1 comment

Comments

@mforets
Copy link
Contributor

mforets commented Jun 24, 2021

in the comparison below, i expected m ≈ interval(0.295, 0.395) to hold.

julia> m
[0.294999, 0.395001]

julia> m.lo  0.295
true

julia> m.hi  0.395
true

julia> m  interval(0.295, 0.395)
false

julia> @which m  interval(0.295, 0.395)
isapprox(x::Number, y::Number; atol, rtol, nans, norm) in Base at floatfuncs.jl:278

see also https://github.com/lucaferranti/IntervalLinearAlgebra.jl/blob/main/src/utils.jl#L1

@schillic
Copy link
Contributor

I noticed that this crashes in the latest release. Maybe it is better that way instead of giving the (intuitively) wrong result.

# 0.20
julia> interval(2)  interval(2-1e-10)
false

# 0.21
julia> interval(2)  interval(2-1e-10)
ERROR: promotion of types Int64 and Interval{Float64} failed to change any arguments
Stacktrace:
 [1] error(::String, ::String, ::String)
   @ Base ./error.jl:44
 [2] sametype_error(input::Tuple{Int64, Interval{Float64}})
   @ Base ./promotion.jl:405
 [3] not_sametype(x::Tuple{Int64, Interval{Float64}}, y::Tuple{Int64, Interval{Float64}})
   @ Base ./promotion.jl:399
 [4] promote
   @ ./promotion.jl:382 [inlined]
 [5] max(x::Int64, y::Interval{Float64})
   @ Base ./promotion.jl:459
 [6] isapprox(x::Interval{Float64}, y::Interval{Float64}; atol::Int64, rtol::Int64, nans::Bool, norm::typeof(abs))
   @ Base ./floatfuncs.jl:307
 [7] isapprox(x::Interval{Float64}, y::Interval{Float64})
   @ Base ./floatfuncs.jl:304
 [8] top-level scope
   @ REPL[6]:1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants