RFC extended Interval

17 views
Skip to first unread message

Chris Smith

unread,
Sep 30, 2021, 6:41:38 PM9/30/21
to sympy
I am exploring ways to implement an Interval that will contain infinite boundaries. 
I am under the assumption that we can't make `Interval(-oo, oo)` mean `[-oo, oo]`.

Currently the default is to *automatically* exclude them, so `Interval(1, oo)` means `[1, oo)`. 

My idea is to use another keyword to allow for infinities to be included, like ``Interval(1, oo, ext=True)` to get [1, oo]. The interval `(1,oo)` is already entered as `Interval.Lopen(1, oo)`; to make it close on the right would require `Interval.Lopen(1, oo, ext=True)`. But that doesn't look very good.

A more compact way to do this (and give an alternative to the functional, but not compact method, of giving 4 arguments) would be to use 2 letters to indicate closed or open status:

Interval.cc(3,4) = [3,4]
Interval.co(3,4) = [3,4)
Interval.oc(3,4) = (3,4]
Interval.oo(3,4) = (3, 4)

Lopen and Ropen could be deprecated (or kept as legacy) but the printing could be done in terms of c and o. The problem with those two letters is that they look so much alike. underscore and "L" could be used as

Interval.LL(3,4) = [3,4]
Interval.L_(3,4) = [3,4)
Interval._L(3,4) = (3,4]
Interval.__(3,4) = (3, 4)

Or "x" and "o"

/c

Aaron Meurer

unread,
Sep 30, 2021, 6:54:32 PM9/30/21
to sympy
I know this doesn't quite answer your question, but I think we should
have two separate classes, RealInterval and ExtendedRealInterval.
Interval could then act as a wrapper for the two. The issue is if an
interval can include infinities, then you can't assume an interval
with symbolic entries like Interval(x, y) is a subset of the reals,
unless the symbols are set as finite. But RealInterval(x, y) would
always act like Interval.intersect(Reals).

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/7e8d8218-32d4-4682-af22-20a47792b48dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages