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

RealNumbers vs RealLine #165

Open
Vaibhavdixit02 opened this issue May 16, 2024 · 3 comments
Open

RealNumbers vs RealLine #165

Vaibhavdixit02 opened this issue May 16, 2024 · 3 comments

Comments

@Vaibhavdixit02
Copy link

I am a little confused about what the difference between the two is meant to be? What tripped me was this subset checking of HalfLine for RealNumbers or RealLine

julia> using DomainSets

julia> d1 = DomainSets.RealNumbers()
RealNumbers()

julia> d2 = DomainSets.HalfLine()
0.0 .. Inf (closed-open) (HalfLine)

julia> issubset(d2, d1)
false

julia> d1 = DomainSets.RealLine()
-Inf .. Inf (open) (RealLine)

julia> issubset(d2, d1)
true
@daanhb
Copy link
Member

daanhb commented May 21, 2024

That's a good point, thanks for raising the issue. I guess the short answer is that these two domains were developed at different times in different contexts. But they should interoperate better.

The technical reason that one works with HalfLine does and the other one doesn't, is that RealLine is implemented as a subtype of an interval and RealNumbers isn't. One improvement may be to implement canonicaldomain for RealNumbers and have it return a RealLine. In that case various fallbacks will start to work and produce better answers.

Yet that wouldn't work for the other sets, i.e., one might also want that the rational numbers are a subset of the real line. Functionality like isequaldomain falls back to issubset, so if the various issubset dependencies are added things should improve. That's probably the way to go: to implement issubset for combinations of the number sets with an interval.

Separately, one can wonder whether the package needs both RealLine and RealNumbers. There are some subtle differences, though. The RealNumbers type really just wraps the isreal function, whereas RealLine is an interval.

@daanhb
Copy link
Member

daanhb commented May 21, 2024

I'll put this on a todo list. Feel free to have a go at it if you like @Vaibhavdixit02. I'm thinking of implementations like the one here:

intersectdomain(d1::UnitInterval{T}, d2::ChebyshevInterval{T}) where {T} = UnitInterval{T}()

Functions to look at include intersectdomain, setdiffdomain, uniondomain and issubset_domain.

@daanhb
Copy link
Member

daanhb commented May 21, 2024

Coming back to the original question/confusion:

  • use RealLine when you want to work with intervals and/or interact with other domains
  • use RealNumbers when you are looking for a representation for the set of real numbers.

For now, RealLine is better supported.

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