## `Dom::Interval` -- intervals of real numbers

#### Introduction

`Dom::Interval` represents the set of all intervals of real numbers.

#### Introduction

`Dom::Interval(`l, r`)` creates the interval of all real numbers between `l` and `r`. If a border is given as a list with `l` or `r` as the sole element, this border will be regarded as a closed border, otherwise the interval does not contain `l` and `r`.

A border can be any arithmetical expression that could represent a real number, e.g., `sqrt(2*x)` and `a + I`. Properties are ignored.

#### Creating Elements

`Dom::Interval(l, r)`
`Dom::Interval([l], r)`
`Dom::Interval(l, [r])`
`Dom::Interval([l], [r])`
`Dom::Interval([l, r])`

#### Parameters

`l` | - | The left border. If given as a list of one element (the left border), the interval will be created as left closed.
`r` | - | The right border. If given as a list of one element (the right border), the interval will be created as right closed.

#### Categories

`Cat::Set`

, `Cat::AbelianMonoid`

#### Related Domains

`Type::Interval`

#### Details

- `Dom::Interval` creates real intervals. The domain `Dom::Interval` provides fundamental operations to combine intervals with intervals and other mathematical objects.
- The return value can be either an interval of type `Dom::Interval` or the empty set of type `DOM_SET`, if the interval is empty.
- Most mathematical operations are overloaded to work with intervals (such as `sin`). If f is a function of n real variables, its extension to intervals is defined to be f(J1, ..., Jn):= {f(j1, ..., jn) ; ji ∈Ji }. The return value of such an operation is in most cases an interval, a union of intervals, a `Dom::ImageSet` or a set. For example, the sine of an interval `[a, b]` is the interval `{sin(x), x in [a, b]}` that contains all sine values of the given interval. In general, you should expect the return value to be an interval larger than strictly necessary. Also note that, when using the same interval twice in one formula, the uses are regarded as independent, so `interval1/interval1` does not return the interval `[1, 1]` as you might expect.

  The functions overloaded in this way are:

  - `_mult`, `_divide`, `_invert`, `_power`
  - `_plus`, `_negate`, `_subtract`
  - `abs`
  - `cos`, `arccos`, `cosh`, `arccosh`, `cot`, `arccot`, `coth`, `arccoth`, `csc`, `arccsc`, `csch`, `arccsch`, `sec`, `arcsec`, `sech`, `arcsech`, `sin`, `arcsin`, `sinh`, `arcsinh`, `tan`, `arctan`, `tanh`, `arctanh`
  - `dirac`, `heaviside`
  - `exp`, `ln`
  - `sign`
- Furthermore, an interval is a special type of set. This is reflected by `Dom::Interval` having the category `Cat::Set`. Among the methods inherited from `Cat::Set`, the following are especially important: `_intersect`, `_minus` and `_union`.
- An interval can be open or closed. If one border is given as a list with one element `[x]`, then this element `x` is taken as border and the interval will be created as closed at this side. If the interval should be closed at both sides, one list with the both borders as arguments can be given.

#### Entries

one

  the unit element; it equals the one-point interval [1,1].

zero

  the zero element; it equals the one-point interval [0,0].

#### Method Im: the imaginary part of an interval (this always equals zero)

- `Im(dom interval)`
- - This method returns the imaginary part of an interval (which is zero).
  - This method overloads `Im`.

#### Method Re: the real part of an interval (this is the interval)

- `Re(dom interval)`
- - This method returns the real part of an interval (which is the interval).
  - This method overloads `Re`.

#### Method contains: containing an element

- `contains(dom interval, any element)`
- - This method returns `TRUE` if `element` is an element of `interval`, `FALSE` if `element` is not an element of `interval`, and `UNKNOWN` if the property mechanism could not prove either statement.
  - This method overloads `contains`.

#### Method max: maximum of an interval

- `max(dom interval...)`
- - This method returns the maximum of intervals. The return value is always an interval.
  - This method overloads `max`.

#### Method min: minimum of an interval

- `min(dom interval...)`
- - This method returns the minimum of intervals. The return value is always an interval.
  - This method overloads `min`.

#### Method new: create an interval

- `new(Type::Arithmetical left, Type::Arithmetical right)`
- `new(Type::Arithmetical [left], Type::Arithmetical right)`
- `new(Type::Arithmetical left, Type::Arithmetical [right])`
- `new(Type::Arithmetical [left], Type::Arithmetical [right])`
- - This method creates a new interval with the borders `left` and `right`.

#### Method borders: the borders of an interval

- `borders(dom interval)`
- - This method returns a list with the borders of an interval.

#### Method left: the left border of an interval

- `left(dom interval)`
- - This method returns the left border of an interval.

#### Method leftB: the left border of an interval

- `leftB(dom interval)`
- - This method returns the left border of an interval. If the interval is left closed, then a list with the left border as element will be returned.

#### Method isleftopen: a left open interval

- `isleftopen(dom interval)`
- - This method returns `TRUE` if the interval is left open.

#### Method isrightopen: a right open interval

- `isrightopen(dom interval)`
- - This method returns `TRUE` if the interval is right open.

#### Method iszero: null interval

- `iszero(dom interval)`
- - This method returns `TRUE` if the given interval contains only the null, otherwise `FALSE`.
  - This method overloads `iszero`.

#### Method op: the operands (borders) of an interval

- `op(dom interval)`
- - This method returns the both borders of an interval as given to create this interval, i.e., closed borders will be returned as a list with the border as operand.
  - This method overloads `op`.

#### Method subs: substitution in intervals

- `subs(dom Interval, Type::Equation equation...)`
- - This method realizes substitution in intervals. The second and more arguments are the same as for the function `subs`.
  - This method overloads `subs`.

#### Method subsleft: substitute left border

- `subsleft(dom interval, Type::Arithmetical left)`
- - This method substitutes the left border of `interval` by `left`. If the border will be given as list with one element, the border will be taken as closed.

#### Method subsright: substitute right border

- `subsright(dom interval, Type::Arithmetical right)`
- - This method substitutes the right border of `interval` by `right`. If the border will be given as list with one element, the border will be taken as closed.

#### Method subsvals: substitute both borders

- `subsvals(dom interval, Type::Arithmetical left, Type::Arithmetical right)`
- - This method substitutes both borders of `interval`. The call is the same as in `"subsleft"` and `"subsright"`.

#### Method convert: converting objects to intervals

- `convert(Any object)`
- - This method tries to convert `object` to an interval. Objects that can be converted are numbers, sets, properties, and arbitrary expressions.
  - If the conversion fails, `FAIL` is returned.

#### Method expr: convert intervals to expressions

- `expr(dom interval)`
- - Converts an interval to an expression of type `_range`.
  - This method overloads `expr`.

- `expr(dom interval, ident x)`
- - Returns a Boolean expression that is equivalent to `x in interval`.

#### Method float: convert to floating point interval

- `float(dom interval)`
- - This method maps the function `float` to the borders of the interval.
  - This method overloads `float`.

#### Method getElement: one element of an interval

- `getElement(dom interval)`
- - This method returns one element of the given interval.

#### Method simplify: simplify intervals

- `simplify(dom interval)`
- - This method tries to simplify a given interval.
  - This method overloads `simplify`.

#### Method emptycheck: check intervals

- `emptycheck(dom interval)`
- - This method returns the given interval, if it is non empty, otherwise the empty set.

#### Method equal: comparison of intervals

- `equal(dom interval, dom interval)`
- - This method compares two given intervals and returns `TRUE`, if the given intervals are equal, otherwise `FALSE`.

#### Method map: apply functions to intervals

- `map(dom interval, Type::Function function <Any argument...>)`
- - This method maps the function `function` to the given interval. Additional arguments argument... are passed to the given function (see `map`). The return value is a `Dom::ImageSet` (which may simplify to a set or a `Dom::Interval`).
  - This method overloads `map`.

#### Method mapBorders: apply functions to the borders of an interval

- `mapBorders(dom interval, Type::Function function <Any argument...>)`
- - This method maps `function` to the borders of `interval`. If additional arguments are given, `function` is called with these as second, third, etc. argument.

#### Method print: printing intervals

- `print(dom interval)`
- - This method returns a string used for displaying the interval.
  - This method overloads `print`.

#### Method random: random interval

- `random()`
- - This method returns a random interval with numbers as borders.

#### Method zip: combine intervals

- `zip(dom interval, dom interval, Type::Function function)`
- - This method combines the two intervals with the given function borderwise.
  - This method overloads `zip`.

#### Example 1

First create a closed interval between `0` and `1`.

    >> A:= Dom::Interval([0], [1])

                                      [0, 1]

Now another open interval between `-1` and `1`.

    >> B:= Dom::Interval(-1, 1)

                                      ]-1, 1[

Intervals can be handled like other objects.

    >> A + B, A - B, A*B, A/B

           ]-1, 2[, ]-1, 2[, ]-1, 1[, ]0, infinity[ union ]-infinity, 0[

    >> 2*A, 1 - A, (A - 1)^2

                              [0, 2], [0, 1], [0, 1]

#### Example 2

Standard functions are overloaded to work with intervals.

    >> sin(B), float(sin(B))

                 ]-sin(1), sin(1)[, ]-0.8414709848, 0.8414709848[

#### Example 3

The next examples shows some technical methods to access and manipulate intervals.

Get the borders and open/closed information about intervals.

    >> A:= Dom::Interval([0], [1]):
       Dom::Interval::left(A), Dom::Interval::leftB(A)

                                      0, [0]

    >> Dom::Interval::isleftopen(A), Dom::Interval::subsleft(A, -1)

                                  FALSE, [-1, 1]

#### Super-Domain

`Dom::BaseDomain`

#### Changes

- `Dom::Interval` was complete reorganized internally.
- With a new syntax closed and open intervals can be created.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000