ExactReals.jl

Exact real arithmetic in Julia
Author dpsanders
Popularity
6 Stars
Updated Last
11 Months Ago
Started In
January 2020

ExactReals.jl

Build Status Build Status Codecov

This is a package for performing exact real arithmetic in Julia. The implementation uses a fast Cauchy sequence to approximate each real number.

Installation

To install the package, do

julia> using Pkg

julia> Pkg.add("https://github.com/dpsanders/ExactReals.jl")

Usage

Exact real numbers may be created from integers and rationals. Basic arithmetic (+, - and *) is implemented:

julia> using ExactReals

julia> ExactReal(3)
ExactReal in 2.9999999999999996..3.0000000000000004

julia> x = ExactReal(3)
ExactReal in 2.9999999999999996..3.0000000000000004

julia> y = ExactReal(3//5)
ExactReal in 0.6..0.6000000000000001

julia> x + y
ExactReal in 3.5999999999999996..3.6

julia> x - y
ExactReal in 2.4..2.4000000000000004

julia> x * y
ExactReal in 1.7999999999999998..1.8

See examples/logistic.jl for an example comparing exact real arithmetic to floating-point arithmetic.

Reference

Keith Briggs, Implementing exact real arithmetic in Python, C++ and C. Theor. Comp. Sci. 351 (2006), 74--81

Author

  • David P. Sanders, Departamento de Física, Facultad de Ciencias, Universidad Nacional Autónoma de México (UNAM) & Visiting researcher, MIT

Acknowledgements

Financial support is acknowledged from DGAPA-UNAM PAPIIT grant IN-117117 and a Cátedra Marcos Moshinsky (2018).