Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 2.1 KB

README.md

File metadata and controls

51 lines (36 loc) · 2.1 KB

Honest Intervals

Crate Documentation License Downloads

Honest Intervals is an arbitrary precision interval arithmetic library with correct rounding.

It implements elementary arithmetic (addition, subtraction, multiplication and division) as well as complicated mathematical functions such as logarithm and power over intervals and interval sets. Bounds of the return values are always correctly rounded up or down to ensure that all possible results are contained.

In addition to the Interval and IntervalSet structs, the library also provides the Mpfr struct that wraps the GNU MPFR library. The Mpfr struct is an ideal (and currently only) bound type for intervals.

Honest Intervals tries to be a pragmatic implementation of interval arithmetic rather than an abstract basis for all possible implementations. Users do not have to implement any traits; they can create a correctly rounding interval right away by calling IntervalSet::<Mpfr>::new().

Quick Start

Here is a code that creates two interval sets and adds them.

use honestintervals::IntervalSet;
use honestintervals::mpfr::Mpfr;
use std::str::FromStr;

let x = IntervalSet::<Mpfr>::from_str("{0; <1, 2>}").unwrap();
let y = IntervalSet::<Mpfr>::singleton(Mpfr::from(3.0));
assert_eq!("{3; <4, 5>}", format!("{}", x + y));

Here is a tricky case of interval division handled correctly by Honest Intervals.

let x = IntervalSet::<Mpfr>::from_str("<1, 2>").unwrap();
let y = IntervalSet::<Mpfr>::from_str("<-1, 1>").unwrap();
assert_eq!("{<-inf, -1>; <1, inf>}", format!("{}", x / y));

See the documentation for more details.

License

Honest Intervals is distributed under the terms of the Apache License (Version 2.0).

See LICENSE for details.