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

@interval should always return an interval #169

Closed
dpsanders opened this issue Oct 19, 2016 · 7 comments
Closed

@interval should always return an interval #169

dpsanders opened this issue Oct 19, 2016 · 7 comments

Comments

@dpsanders
Copy link
Member

dpsanders commented Oct 19, 2016

julia> x = 1..2.1
[1, 2.10001]

julia> @interval mid(x)
1.55

julia> macroexpand(:(@interval mid(x)))
:(mid((ValidatedNumerics.convert)(Interval{parameters.precision_type},x)))

Maybe just wrap everything in Interval(...) in the @interval macro?

@lbenet
Copy link
Member

lbenet commented Oct 19, 2016

I see your point. Yet, I think the way it works is actually the way we wanted it to behave.

If I recall correctly, the idea was that @interval sin(0.1) computed the sin of the correctly rounded interval 0.1. This should be contrasted with Interval(sin(0.1)), which yields a thin interval.

So, @interval has to "act" inside the function, and then the function is computed. In the case of mid, it (re)computes the interval x and then computed the mid of x. So, the solution is either Interval(mid(x)), or

julia> xmid = mid(x);

julia> @interval(xx)
[1.54999, 1.55001]

@dpsanders
Copy link
Member Author

My point is that @interval mid(x) should definitely return an interval, since that was always the desired behaviour of @interval.

@lbenet
Copy link
Member

lbenet commented Jan 7, 2017

My point is that @interval f(x) yields f(@interval(x)).

@dpsanders
Copy link
Member Author

Yes, I see what is happening, but it seems to be wrong that something called interval doesn't return one!

@lbenet
Copy link
Member

lbenet commented Jan 7, 2017

I agree with you: it's strange. However, I can't figure out how to solve this. The same will happen with diam, or whatever function that returns something different from an interval...

@dpsanders
Copy link
Member Author

One way (I believe, without having tried) is just to modify the @interval macro to always wrap the result in Interval(...) at the end.

@dpsanders
Copy link
Member Author

Fixed in #188.

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