AnderGray / IntervalUnionArithmetic.jl

An implementation of interval union arithmetic in Julia
MIT License
11 stars 4 forks source link

Interval unions not combining #25

Open AnderGray opened 2 years ago

AnderGray commented 2 years ago

I was expecting the output of this union to just have two elements, but it has 51.

using IntervalUnionArithmetic, IntervalArithmetic

f(x) = x > 1 ? x-1 : x;

X = 0.9..1.1

outU = intervalUnion( f.( mince(X, 100) ) )
[0.002, 0.00600001] ∪ [0.006, 0.0100001] ∪ [0.01, 0.0140001] ∪ [0.014, 0.0180001] ∪ [0.018, 0.0220001] ∪ [0.022, 0.0260001] ∪ [0.026, 0.0300001] ∪ [0.03, 0.0340001] ∪ [0.034, 0.0380001] ∪ [0.038, 0.0420001] ∪ [0.042, 0.0460001] ∪ [0.046, 0.0500001] ∪ [0.05, 0.0540001] ∪ [0.054, 0.0580001] ∪ [0.058, 0.0620001] ∪ [0.062, 0.0660001] ∪ [0.066, 0.0700001] ∪ [0.07, 0.0740001] ∪ [0.074, 0.0780001] ∪ [0.078, 0.0820001] ∪ [0.082, 0.0860001] ∪ [0.086, 0.0900001] ∪ [0.09, 0.0940001] ∪ [0.094, 0.0980001] ∪ [0.098, 0.100001] ∪ [0.899999, 0.904] ∪ [0.903999, 0.908] ∪ [0.907999, 0.912] ∪ [0.911999, 0.916] ∪ [0.915999, 0.92] ∪ [0.919999, 0.924] ∪ [0.923999, 0.928] ∪ [0.927999, 0.932] ∪ [0.931999, 0.936] ∪ [0.935999, 0.94] ∪ [0.939999, 0.944] ∪ [0.943999, 0.948] ∪ [0.947999, 0.952] ∪ [0.951999, 0.956] ∪ [0.955999, 0.96] ∪ [0.959999, 0.964] ∪ [0.963999, 0.968] ∪ [0.967999, 0.972] ∪ [0.971999, 0.976] ∪ [0.975999, 0.98] ∪ [0.979999, 0.984] ∪ [0.983999, 0.988] ∪ [0.987999, 0.992] ∪ [0.991999, 0.996] ∪ [0.995999, 1] ∪ [1, 1.00201]

On inspection

julia> outU[1].hi == outU[2].lo
true
AnderGray commented 2 years ago

I believe that condense! is the culprit

https://github.com/AnderGray/IntervalUnionArithmetic.jl/blob/e472255efaa9d3e9863ca4ef32022ef4273a875b/src/interval_unions.jl#L97