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

Float interval + BigFloat interval should be Float interval? #326

Closed
dpsanders opened this issue Sep 19, 2019 · 6 comments
Closed

Float interval + BigFloat interval should be Float interval? #326

dpsanders opened this issue Sep 19, 2019 · 6 comments

Comments

@dpsanders
Copy link
Member

x::Interval{Float64} + y::Interval{BigFloat} should give Interval{Float64}?

@lbenet
Copy link
Member

lbenet commented Sep 19, 2019

Thanks for bringing this up, it is really a good point.

I think that if a user takes the time to create an Interval{BigFloat} is because the user is precisely after that type of answer.

@perrutquist
Copy link

If the result is larger than prevfloat(typemax(Float64)), then the interval would have to be expanded all the way to infinity in order to be represented using Float64.

@dpsanders
Copy link
Member Author

This is (partially) analogous to a similar discussion in TaylorSeries.jl about the degree of the sum of two polynomials of different degrees.

If one of the intervals is a Float64 then you can only have information at the precision level of a Float64.

The point about prevfloat is already handled:

julia> interval(0, prevfloat(typemax(Float64))) + Interval{Float64}(interval(big(1), big(2)))
Interval(1.0, Inf)

@perrutquist
Copy link

I would argue that the precision of a Float64 is infinite in this context, since results are always rounded in the right direction. (The numbers that are stored are not approximations of the bounds. They are the bounds, albeit not always the tightest possible bounds.)

For example, if I write big"1e20" + (0..1). then I might consider that last interval to be exact, even though it happens to be stored as Float64. Therefore I would expect the result to be big"100000000000000000000" .. big"100000000000000000001". Converting to Interval{Float64} would result in 100000000000000000000 .. 100000000000000016384.

@dpsanders
Copy link
Member Author

I see your point, but while you might know that you meant an exact interval, Julia has no way of knowing that. The fact that you chose to use an Interval{Float64} there, rather than a BigFloat (or, say, an interval of rational numbers) means that Julia should assume that you only have that amount of precision.

@Kolaru
Copy link
Collaborator

Kolaru commented Jul 24, 2023

Discussed in triage, there are two reason have Interval{Float64} + BigFloat -> BigFloat

  1. It follows Base convention.
  2. The operation is still guaranteed, only the subsequent operation will be performed with higher precision.

@Kolaru Kolaru closed this as completed Jul 24, 2023
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

4 participants