-
Notifications
You must be signed in to change notification settings - Fork 27
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
isapprox should work for comparing open and closed intervals #129
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportBase: 99.16% // Head: 99.16% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #129 +/- ##
==========================================
- Coverage 99.16% 99.16% -0.01%
==========================================
Files 3 3
Lines 240 239 -1
==========================================
- Hits 238 237 -1
Misses 2 2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
As discussed here (#125 (comment)), I still think |
We may have a type for the unconnected subset of |
Hmm a more interesting example is 1..2 ∪ 3..3 ≈ 1..2 In this case the difference between the two sets has measure 0 but I agree that they are not approximately the same. I think the right concept here is Hausdorff distance. We have d(1..2 ∪ 3..3 , 1..2) == 3
d(OpenInterval(0,1), 0..1) == 0
d(1..2 ∪ 2..4 , 1..4) == 0 So mathematically if the Hausdorff distance |
The julia> a = 1.000000000000001
1.000000000000001
julia> a ≈ 1
true
julia> rationalize(a) ≈ 1
false
julia> rationalize(a) ≈ 1.0
true Therefore, |
It seems there are some ways to define
I prefer the third definition for |
Note 1 and 4 are the same thing. You haven't given a usage reason not to just use Hausdorff distance, which is the most mathematically natural. |
That is a funny example. So we have julia> b = rationalize(1.000000000000001)
750599937895084//750599937895083
julia> isapprox(b, 1)
false
julia> isapprox(b, 1.0)
true
julia> isapprox(1, 1.0)
true I'm not sure I like that outcome. Because then you get things like this: julia> b ≈ 1.0 ≈ 1
true Also, julia> norm(b-1)
1.3322676295501873e-15 It seems a fair point to me that a generic meaning of |
Yes, 1 and 4 are the same for intervals, but they are different for unconnected subsets of
To me, definition 3 is the most mathematically (or engineeringly?) natural for the following reasons:
Currently, I don't have practical usage for
Note that julia> a = 1.00000001
1.00000001
julia> b = 0.99999999
0.99999999
julia> a ≈ 1
true
julia> b ≈ 1
true
julia> a ≈ b
false
julia> a ≈ 1 ≈ b
true |
True. It's a little weirder than that because |
Back on topic, I can't think of an argument in either direction for more general domains right now, as DomainSets also represents open and closedness explicitly (which makes it "discrete info" that is conveniently available). But here is a related question. DomainSets defines an approximate in, julia> using DomainSets
julia> approx_in(1+1e-15, OpenInterval(0,1))
true For an approximate On the other hand, also currently: julia> 1+1e-15 ∈ Point(1)
false So that is not consistent. |
I would say a "fuzzy circle" (e.g. the set |
It seems I was relying on approximate comparisons between open and closed intervals in BasisFunctions.jl. Easily fixed, but somewhat annoying, because it is harder to create open and closed intervals than typing |
Would it be useful to have a macro like |
Why a macro and not just a function? E.g. |
Ah, it can be a function. I was just thinking of |
|
To me |
In #125 original version I made closed and open interval approximately equal. Didn't even consider that could be controversial, but turned out there are two totally reasonable but opposite PoVs in this regard. Maybe, it's best just to keep this comparison undefined, as it is now? I would be extremely surprised by Btw, a nice and general syntax for changing closedness (or anything else!) is julia> using IntervalSets, Accessors
julia> i = 2..5;
julia> @set first(closedendpoints(i)) = false
2..5 (open–closed) Even cleaner if functions like |
Something like
OpenInterval(0,1)
should certainly be approximatelyClosedInterval(0,1)
as they are closer to each other than the following which returns true: