The Interval class

Interval x(double lb, double ub) will define the interval \([x]\). It is made of its lower and upper bounds \([x^{-},x^{+}]\).

x = Interval(0,10)                          # [0,10]
x = Interval(1,oo)                          # [1,∞]
x = Interval(-oo,-10)                       # [-∞,-10]

Some pre-defined values are also at hand:

x = Interval()                              # [-∞,∞] (default value)
x = Interval.empty()                        # ∅
x = Interval.pi()                           # [π]
x = Interval.two_pi()                       # [2π]
x = Interval.half_pi()                      # [π/2]

Note that the constant \([\pi]\) is a reliable enclosure of the \(\pi\) value, that cannot be exactly represented in a computer with a single floating-point value.

x = Interval.pi()                           # [π]
# x = [3.141592653589793, 3.141592653589794]

IntervalVector

Some specific commands in Python are provided below:

x = IntervalVector([[1,2],[2,3],[3,4]])
y = IntervalVector(3)

i = 0
for xi in x:
  y[i] = xi
  i = i+1

# x == y

a,b,c = x
# a == x[0]
# b == x[1]
# c == x[2]

v = IntervalVector([*x, [3,6]])
# v == [[1,2],[2,3],[3,4],[3,6]]