-
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
Interval comparisons may make other packages functions behave unexpectedly #165
Comments
I believe that the problem is not the comparisons, but rather using an In general, "standard" algorithms will not work correctly for intervals. |
In the particular case of |
(And note that you should use |
I'd like to propose the same solution I described here: Comparisons are inherently questions about numbers, not intervals. Therefore they cannot be decided in some cases. For example So what do you think of this?
or, for two intervals:
(Here I use |
I think questions like these, namely Note that there exist already the functions |
This interpretation is perfectly reasonable. Indeed, intervals are not numbers, therefore the fact that for example However, one of the great things about intervals is that in most cases intervals behave as numbers. An awesome thing about this package is that it actually allows the user to use intervals in place of numbers without further modification, immediately giving correct results. This is very convenient, but implies that julia> isa(1..3, Number)
true This suggests that with the current implementation intervals actually behave as numbers (which in general they don't). Therefore, in my opinion, when it is not in contradiction with the standard, we should prefer the "convenient for user way" of having intervals that behave as numbers whenever it makes sense and otherwise throw an error. This is what the proposition of @gwater would enforce, and this overall strategy would guarantee that using intervals in place of numbers always yields correct results. (Note that correct does not implies useful, for example dividing by |
How about making comparisons return an interval? If the result of the comparison is true for all possible values left and right of the comparison operator, the result would be something like This would automatically cause errors for if-statements on interval comparisons. And we could add a method to |
I've implemented an interval type based on IntervalArithmetic's intervals which behaves more predictable and cautious in comparisons. Feel free to upstream some methods. https://github.com/gwater/NumberIntervals.jl |
@gwater, I like that approach - are you planning to register |
Alternatively - maybe that new interval type could be integrated into |
After some testing interoperatibility with other packages a bit more, yes. Safe interoperatbility is really the main goal – are we able to use NumberIntervals safely with algorithms designed for Reals without the kind of silent failures IntervalArithmetic currently produces?
I think it's ok to have two separate packages for now: One for strict IEEE conform intervals (IntervalArithmetic), and one for Number-like intervals based on the former (NumberIntervals). Nevertheless, I would also welcome upstreaming NumberIntervals; or perhaps #271 will one day make NumberIntervals obsolete. |
Can |
I haven't worked with IntervalOptimisation yet but I assume it is developed specfically for IntervalArithmetic's |
Well, my idea was that it would bring the advantages of |
I think that the idea of using Cassette is a very interesting one. But even so, there are certain types of numeric functions that could be handled, containing things like
and others that are arbitrarily difficult, like
Determining whether |
Uhm, I was actually thinking more on the lines of dual numbers and |
That's great! I've had a look at it as I intend to (at last) resume my work on #271 and I think that returning a special object (either the custom |
Is the current approach to always return true for comparisons if they might be true useful in some applications? If not, I wonder if it would make sense to return |
Discussed in triage: In the interest of simplicity and in the spirit of other recent decisions, the best course of action is probably to simply remove all these symbols for 1.0. |
Comparisons (
==
,>
,<
, etc.) between intervals or comparisons between intervals and numbers are possible, and run smoothly and silently, but they may behave in ways that may not make sense for the algorithm used.As a simple illustration, a decent implementation of sinus cardinal (sin(x)/x) may be
But
because
X != 0
(correct result is[0.999998355066745, 1]
).In particular this makes many functions of
SpecialFunctions.jl
behave incorrectly, and it may be the reason behind this issue.A possible way to mitigate it, beyond documenting it, may be to implement a debug mode that raise a warning whenever such comparison is performed.
The text was updated successfully, but these errors were encountered: