# ExInterval

ExInterval implements the interval type and range operations on the type, with rounded
directed intervals, recognize the input as strings and performs operations
between intervals.

Using intervals for the representation of real numbers, it is possible to
control the error propagation of rounding or truncation, between others, in 
numerical computational procedures.

## Installation

If [available in Hex](, the package can be installed
by adding `ex_interval` to your list of dependencies in `mix.exs`:

def deps do
    {:ex_interval, "~> 0.1.0"}

Documentation can be generated with [ExDoc](
and published on [HexDocs]( Once published, the docs can
be found at [](

## Interval
It implements the interval type.
[1.1, 1.1]
iex>, "0.1")  # recognize the input as strings too
[-1.0, 0.1]


## Interval operations
The operations of interval follow the interval arithmetic with maximum accuracy
that captures essential properties associated with rounding.

### Binary plus operator
iex> Interval.add("0.1", 0.1)
[0.2, 0.2]
iex> Interval.add([0.25, 0.5], [2.0, 2.0])
[2.25, 2.5]
Similarly, it provides minus (**sub**), multiplication (**mul**), and division (**division**) operators.

## Helpers
eps/0, is_member?/2, middle/1, absolute/1, diameter/1
iex> eps = Interval.eps
iex> Interval.is_member?(eps, [0.0, 0.1])                                  
iex> Interval.middle([0.0, 0.1])
iex> Interval.absolute([-1, 1])
iex> Interval.diameter([0.0, 0.1])
## Rounding
The error control is done by directed rounding for the interval operations, we also
can use Rounding helper functions.
iex> backup_mode = Rounding.get_mode()
iex> Rounding.set_mode(-1)
iex> 1/3                             
iex> Rounding.set_mode(1) 
iex> 1/3                             
iex> Rounding.set_mode(backup_mode)
*_It does not guarantee is preemption safe_.
## References

[1] Moore, R. E., Interval Analysis. Prentice-Hall, Englewood Cliffs, New Jersey, 1966.

[2] Moore, R. E., Methods and Applications of Interval Analysis. SIAM Studies in Applied Mathematics, Philadelphia, 1979.

[3] Kulisch, U. W., Miranker, W. L., Computer Arithmetic in Theory and Practice. Academic Press, 1981.