|
| 1 | +# Intervals.jl: Interval arithmetics with julia # |
| 2 | + |
| 3 | +`Intervals.jl` is a julia module to perform *validated numerics*, i.e. *rigorous* computations with finite-precision floating-point arithmetic. |
| 4 | + |
| 5 | +### Related Work ### |
| 6 | + |
| 7 | +- [MPFI.jl][1]: Wrapper of [MPFI library][http://perso.ens-lyon.fr/nathalie.revol/software.html] (multiple precision interval arithmetic library based on MPFR) for julia. |
| 8 | + |
| 9 | +### References ### |
| 10 | +- *Validated Numerics: A short introduction to rigurous computations*, W. Tucker, Princeton University Press (2010). |
| 11 | +- *Introduction to Interval Analysis*, R.E. Moore, R.B. Kearfott, M.J. Cloud, SIAM (2009). |
| 12 | + |
| 13 | +### Contributors ### |
| 14 | +- Luis Benet, Instituto de Ciencias Físicas, Universidad Nacional Autónoma de México (UNAM) |
| 15 | +- David P. Sanders, Facultad de Ciencias, Universidad Nacional Autónoma de México (UNAM) |
| 16 | + |
| 17 | +### Design and implementation ### |
| 18 | + |
| 19 | +The basic constructor is `Interval`, which is defined from pairs of `Real`-type values, or single ones. The idea of including the latter is to produce *thin intervals*, i.e., intervals which consist of a single real value. Yet, if the number is not exactly representable in base 2, rounding-off errors appear due to the finite precision floating-point arithmetic. Incorporating *directed rounding* may thus create intervals whose *diameter* or *width* is strictly positive. Directed rounding is incorporated for any `Real`-type values *except* for `BigFloat`, since this type includes rounding. Direct access to the `RoundDown` and `RoundUp` modes is obtained through the macros `@roundingDown` and `@roundingUp`. |
| 20 | + |
| 21 | +The following provides some examples. |
| 22 | +```julia |
| 23 | +julia> using Intervals ## Default precision is 53, equivalent to Float64 |
| 24 | + |
| 25 | +help> Interval |
| 26 | +DataType : Interval (constructor with 5 methods) |
| 27 | + supertype: Real |
| 28 | + fields : (:lo,:hi) |
| 29 | + |
| 30 | +julia> a = Interval(0.1) |
| 31 | + [9.9999999999999992e-02, 1.0000000000000001e-01] with 53 bits of precision |
| 32 | + |
| 33 | +julia> Interval(1//10) |
| 34 | + [9.9999999999999992e-02, 1.0000000000000001e-01] with 53 bits of precision |
| 35 | + |
| 36 | +julia> Interval(BigFloat(0.1)) |
| 37 | + [1.0000000000000001e-01, 1.0000000000000001e-01] with 53 bits of precision |
| 38 | + |
| 39 | +julia> b1 = Interval(BigFloat("0.1")) |
| 40 | + [1.0000000000000001e-01, 1.0000000000000001e-01] with 53 bits of precision |
| 41 | + |
| 42 | +julia> b2 = Interval( @roundingDown(BigFloat("0.1")), @roundingDown(BigFloat("0.1")) ) |
| 43 | + [9.9999999999999992e-02, 9.9999999999999992e-02] with 53 bits of precision |
| 44 | + |
| 45 | +julia> diam( Interval(1000.102)) == eps(1000.102) |
| 46 | +true |
| 47 | + |
| 48 | +``` |
| 49 | + |
| 50 | +Note that all possibilities above yield the same results *except* `Interval(BigFloat(0.1))`, which yields a thin interval, that noticeably *does not* contain the real value 0.1; a way to obtain a non-thin interval using `BigFloat` of strings is illustrated in the last line. |
| 51 | + |
| 52 | +The limits of the interval are accessed with the fields `lo` and `hi`. These fields are of `BigFloat` type. The diameter is obtained using `diam(a)`; note that for non-exactly representable numbers in base 2 (i.e., whose *binary* expansion is infinite) the diameter |
| 53 | +corresponds to the local `eps`. |
| 54 | +```julia |
| 55 | +julia> a.lo |
| 56 | +9.9999999999999992e-02 with 53 bits of precision |
| 57 | + |
| 58 | +julia> b1.lo.prec ## this displays the precision of the BigFloat number |
| 59 | +53 |
| 60 | + |
| 61 | +julia> diam(a) == eps(0.1) |
| 62 | +true |
| 63 | + |
| 64 | +julia> diam(b1) |
| 65 | +0e+00 with 53 bits of precision |
| 66 | + |
| 67 | +``` |
| 68 | + |
| 69 | +### Acknowledgements ### |
| 70 | +This project was developed in a masters' course in the postgraduate programs in Physics and in Mathematics at UNAM during the second half of 2013. We thank the participants of the course for putting up with the half-baked material and contributing energy and ideas. |
| 71 | + |
| 72 | +Financial support is acknowledged from DGAPA-UNAM PAPIME grants PE-105911 and PE-107114. LB acknowledges support through a *Cátedra Moshinsky* (2013). |
| 73 | + |
| 74 | +[1]: https://github.com/andrioni/MPFI.jl |
0 commit comments