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

Unbounded isapprox #132

Open
aplavin opened this issue Dec 19, 2022 · 6 comments
Open

Unbounded isapprox #132

aplavin opened this issue Dec 19, 2022 · 6 comments

Comments

@aplavin
Copy link
Contributor

aplavin commented Dec 19, 2022

Currently, isapprox relative tolerance is based on the maximum of interval endpoints. This makes a lot of sense for finite intervals, but is kinda weird for infinities:

julia> (-1e10..Inf)  (1e10..Inf)
true

Do you think this can be fixed/improved in a consistent manner?

@dlfivefifty
Copy link
Member

I guess the real question is what is "relative" wrt what?

I assume you are happy that (0..1) ≈ (1e(-13)..1) returns true even though 0 ≈ 1e(-13) returns false. So this means we can't just check if both endpoints are approximately equal.

But I agree your example returning true is not right.

@aplavin
Copy link
Contributor Author

aplavin commented Dec 19, 2022

Yes, I think the behavior for finite intervals is correct and totally expected.

I guess the real question is what is "relative" wrt what?

Agree, and don't have a solution ready. That's why an issue and not a PR.

@dlfivefifty
Copy link
Member

It doesn't actually help with this problem but looking at the code the choice of relative tolerance looks wrong: I think maxabs should be based on the widths of the intervals not the size of the endpoints...

@aplavin
Copy link
Contributor Author

aplavin commented Dec 19, 2022

Then we'd get weird situations when L1 ≈ L2 and R1 ≈ R2, but (L1..R1) ≉ (L2..R2).
Eg for 1e10...(1e10+3) and (1e10+1)..(1e10+2).

@dlfivefifty
Copy link
Member

I don't think that's a "weird situation" at all... and in fact those two intervals do not look approximately equal.

@aplavin
Copy link
Contributor Author

aplavin commented Dec 19, 2022

What about 1e10..(1e10+1) and nextfloat(1e10)..(1e10+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

No branches or pull requests

2 participants